openssl/ssl
Benjamin Kaduk e3743355e8 Don't modify resumed session objects
If s->hit is set, s->session corresponds to a session created on
a previous connection, and is a data structure that is potentially
shared across other SSL objects.  As such, there are thread-safety
issues with modifying the structure without taking its lock (and
of course all corresponding read accesses would also need to take
the lock as well), which have been observed to cause double-frees.

Regardless of thread-safety, the resumed session object is intended
to reflect parameters of the connection that created the session,
and modifying it to reflect the parameters from the current connection
is confusing.  So, modifications to the session object during
ClientHello processing should only be performed on new connections,
i.e., those where s->hit is not set.

The code mostly got this right, providing such checks when processing
SNI and EC point formats, but the supported groups (formerly
supported curves) extension was missing it, which is fixed by this commit.

However, TLS 1.3 makes the suppported_groups extension mandatory
(when using (EC)DHE, which is the normal case), checking for the group
list in the key_share extension processing.  But, TLS 1.3 only [0] supports
session tickets for session resumption, so the session object in question
is the output of d2i_SSL_SESSION(), and will not be shared across SSL
objects.  Thus, it is safe to modify s->session for TLS 1.3 connections.

[0] A psk_find_session callback can also be used, but the restriction that
each callback execution must produce a distinct SSL_SESSION structure
can be documented when the psk_find_session callback documentation is
completed.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4123)
2017-08-09 14:54:47 -05:00
..
record Add a DRBG to each SSL object 2017-08-03 10:24:03 -04:00
statem Don't modify resumed session objects 2017-08-09 14:54:47 -05:00
bio_ssl.c Get pointer type right in BIO_ssl_shutdown() 2017-03-07 09:56:49 -05:00
build.info Move ssl/t1_ext.c to ssl/statem/extensions_cust.c 2017-04-07 13:41:04 +01:00
d1_lib.c Convert existing usage of assert() to ossl_assert() in libssl 2017-05-22 14:00:43 +01:00
d1_msg.c Remove special case code for SCTP reneg handling 2017-04-25 11:13:39 +01:00
d1_srtp.c Move client parsing of ServerHello extensions into new framework 2016-12-08 17:18:25 +00:00
methods.c Drop support for OPENSSL_NO_TLS1_3_METHOD 2017-06-30 09:41:46 +01:00
packet.c Move ossl_assert 2017-08-03 10:48:00 +01:00
packet_locl.h TLS1.3 Padding 2017-05-02 09:44:43 +01:00
pqueue.c Update copyright header 2017-07-30 17:42:00 -04:00
s3_cbc.c Move ossl_assert 2017-08-03 10:48:00 +01:00
s3_enc.c Move ossl_assert 2017-08-03 10:48:00 +01:00
s3_lib.c Add missing include of cryptlib.h 2017-08-06 17:06:19 -04:00
s3_msg.c Always flush the BIO when we send any alert 2017-06-06 22:39:41 +01:00
ssl_asn1.c Send and receive the ticket_nonce field in a NewSessionTicket 2017-07-07 15:02:09 +01:00
ssl_cert.c Move certificate table to header file so it can be tested. 2017-07-13 12:38:42 +01:00
ssl_cert_table.h Move certificate table to header file so it can be tested. 2017-07-13 12:38:42 +01:00
ssl_ciph.c Move ossl_assert 2017-08-03 10:48:00 +01:00
ssl_conf.c Do not allow non-dhe kex_modes by default 2017-07-07 16:08:05 +01:00
ssl_err.c make errors 2017-07-13 12:38:42 +01:00
ssl_init.c Convert existing usage of assert() to ossl_assert() in libssl 2017-05-22 14:00:43 +01:00
ssl_lib.c Add a DRBG to each SSL object 2017-08-03 10:24:03 -04:00
ssl_locl.h Add a DRBG to each SSL object 2017-08-03 10:24:03 -04:00
ssl_mcnf.c Fix misc size_t issues causing Windows warnings in 64 bit 2016-11-04 12:09:46 +00:00
ssl_rsa.c Use certificate tables instead of ssl_cert_type 2017-07-13 12:38:42 +01:00
ssl_sess.c Add an SSL_SESSION_dup() function 2017-08-09 13:37:06 +10:00
ssl_stat.c Fix errors in SSL_state_string_long 2017-07-31 08:55:37 -04:00
ssl_txt.c Merge Nokia copyright notice into standard 2017-06-21 08:59:18 -04:00
ssl_utst.c Remove heartbeat support 2016-11-13 16:24:02 -05:00
t1_enc.c Fix tls1_generate_master_secret 2017-06-22 11:54:19 -04:00
t1_lib.c Use cert tables in ssl_set_sig_mask 2017-07-13 12:38:42 +01:00
t1_trce.c Fix the names of older ciphers. 2017-07-31 09:11:18 -04:00
tls13_enc.c Fix TLSv1.3 exporter secret 2017-07-17 13:42:52 +01:00
tls_srp.c Add a DRBG to each SSL object 2017-08-03 10:24:03 -04:00