openssl/ssl
Neil Horman ddd57b5b1e Close small race condition on error raising in QUIC
Github issue #28501 reported an odd condition in which a double free was
occuring when a given thread was popping entries of its error stack.

It was hypothesized that, because a few places in the quic stack save
error state to a shared structure (ch->err_state, port->error_state,
qtls->error_state), that multiple threads may attempt to mutate the
shared structure during error save/restore in parallel.

Investigation showed that all paths which led to such mutations were
done under lock, so that shouldn't occur.

Except for one case, which this PR addresses.

In ossl_quic_conn_stream_conclude, we unlock our protecting mutex, prior
to calling QUIC_RAISE_NON_NORMAL_ERROR.  If that function is called with
an reason code of SHUTDOWN, it attempts to restore the channel error
state.  Given that the lock was released first, this creates a small
race condition in which two threads may manipulate the shared error
state in the channel struct in parallel.

According to the reporter, applying this patch prevents the reported
error from occuring again.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/28642)

(cherry picked from commit 1e70e8080a)
2025-09-24 12:19:26 +02:00
..
quic Close small race condition on error raising in QUIC 2025-09-24 12:19:26 +02:00
record tls_common.c: Handle inner content type properly on Big Endian 2025-09-23 16:39:11 +02:00
rio ossl_rio_poll_builder_add_fd(): Fixup pfds after reallocation 2025-06-13 12:39:20 +02:00
statem Fail immediately if we have no key shares to send 2025-08-20 09:49:57 +01:00
bio_ssl.c Copyright year updates 2025-03-12 13:35:59 +00:00
build.info Move ssl_err.c into libcrypto 2025-03-01 14:46:03 -05:00
d1_lib.c Fix: Check for wrong object. The converted sc should be checked instead of the original s 2025-08-22 11:09:18 -04:00
d1_msg.c Copyright year updates 2025-03-12 13:35:59 +00:00
d1_srtp.c Copyright year updates 2025-03-12 13:35:59 +00:00
methods.c
pqueue.c
priority_queue.c Copyright year updates 2024-09-05 09:35:49 +02:00
s3_enc.c Copyright year updates 2025-03-12 13:35:59 +00:00
s3_lib.c s3_lib.c: Use illegal_parameter for failing encapsulation in ml_kem 2025-05-16 11:11:22 +02:00
s3_msg.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_asn1.c
ssl_cert.c Ensure we pass the user SSL object for the SSL_set_verify callback 2025-06-17 16:27:30 -04:00
ssl_cert_comp.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_cert_table.h
ssl_ciph.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_conf.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_err_legacy.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_init.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_lib.c Enforce permissions 0600 for SSLKEYLOGFILE 2025-06-30 11:01:50 +01:00
ssl_local.h Preserve connection custom extensions in SSL_set_SSL_CTX() 2025-06-20 15:56:58 +01:00
ssl_mcnf.c Copyright year updates 2024-09-05 09:35:49 +02:00
ssl_rsa.c Fix the abnormal branch memory leak in ssl_set_cert_and_key function 2025-09-23 16:36:43 +02:00
ssl_rsa_legacy.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_sess.c Stop a TLSv1.3 server emitting an unsolicited PSK extension 2025-05-13 14:12:48 +02:00
ssl_stat.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_txt.c Copyright year updates 2024-09-05 09:35:49 +02:00
ssl_utst.c
t1_enc.c Copyright year updates 2025-03-12 13:35:59 +00:00
t1_lib.c ssl/t1_lib.c: Free gix if sk_TLS_GROUP_IX_push() fails to avoid memory leak 2025-05-19 08:38:39 +02:00
t1_trce.c Updated SSL Trace to display the name for all MLKEM-based groups 2025-09-18 17:27:45 +02:00
tls13_enc.c Ensure client read app data secret change occurs after write for QUIC 2025-06-03 17:08:40 +01:00
tls_depr.c Copyright year updates 2025-03-12 13:35:59 +00:00
tls_srp.c Copyright year updates 2025-03-12 13:35:59 +00:00