openssl/ssl
Neil Horman 34063dff60 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:20 +02:00
..
quic Close small race condition on error raising in QUIC 2025-09-24 12:19:20 +02:00
record tls_common.c: Handle inner content type properly on Big Endian 2025-09-23 16:39:02 +02:00
rio ossl_rio_poll_builder_add_fd(): Fixup pfds after reallocation 2025-06-13 12:37:50 +02:00
statem Fail immediately if we have no key shares to send 2025-08-20 09:48:25 +01:00
bio_ssl.c libssl: Silence warnings on Win64 builds 2025-07-02 17:26:26 +02: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:06:25 -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 2025-09-02 13:05:45 +00:00
s3_enc.c Copyright year updates 2025-03-12 13:35:59 +00:00
s3_lib.c Add support for TLS 1.3 OCSP multi-stapling for server certs 2025-07-25 17:24:37 +02:00
s3_msg.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_asn1.c RFC7250 (RPK) support 2023-03-28 13:49:54 -04:00
ssl_cert.c ssl: use array memory (re)allocation routines 2025-08-08 12:22:10 -04:00
ssl_cert_comp.c libssl: Silence warnings on Win64 builds 2025-07-02 17:26:26 +02:00
ssl_cert_table.h Make ssl_cert_info read-only 2023-11-27 07:51:33 +00:00
ssl_ciph.c ssl: use array memory (re)allocation routines 2025-08-08 12:22:10 -04:00
ssl_conf.c Introduce SSL_OP_SERVER_PREFERENCE to replace SSL_OP_CIPHER_SERVER_PREFERENCE misnomer 2025-07-09 12:10:57 +02: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 Avoid doublefree of OCSP_SINGLERESP 2025-08-20 14:59:34 +02:00
ssl_local.h Add support for TLS 1.3 OCSP multi-stapling for server certs 2025-07-25 17:24:37 +02: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:38 +02:00
ssl_rsa_legacy.c Copyright year updates 2025-03-12 13:35:59 +00:00
ssl_sess.c libssl: Silence warnings on Win64 builds 2025-07-02 17:26:26 +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 Remove the old buffer management code 2022-10-20 14:39:33 +01:00
t1_enc.c libssl: Silence warnings on Win64 builds 2025-07-02 17:26:26 +02:00
t1_lib.c set SSLfatal if tls1_set_shared_sigalgs has a malloc failure 2025-08-15 08:39:11 -04:00
t1_trce.c Updated SSL Trace to display the name for all MLKEM-based groups 2025-09-18 17:27:40 +02:00
tls13_enc.c Assert SSLFatal on keylog failure 2025-08-12 14:15:50 -04:00
tls_depr.c libssl: Silence warnings on Win64 builds 2025-07-02 17:26:26 +02:00
tls_srp.c Copyright year updates 2025-03-12 13:35:59 +00:00