openssl/ssl/quic
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
..
build.info Fixup conflict between 3rd party quic-tls api and quic-server 2025-02-17 11:27:34 -05:00
cc_newreno.c Resolve some of the TODO(QUIC) items 2023-08-08 15:58:59 +02:00
json_enc.c Begin incorporating stdbool usage when json encoding 2025-06-13 11:26:46 -04:00
qlog.c Begin incorporating stdbool usage when json encoding 2025-06-13 11:26:46 -04:00
qlog_event_helpers.c Copyright year updates 2025-09-02 13:05:45 +00:00
quic_ackm.c Copyright year updates 2025-09-02 13:05:45 +00:00
quic_cfq.c Copyright year updates 2024-09-05 09:35:49 +02:00
quic_channel.c Make SSL_poll() and SSL_shutdown() better friends 2025-08-21 14:43:03 +02:00
quic_channel_local.h Fix memory management in port_make_channel 2025-05-07 15:08:21 +02:00
quic_demux.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_engine.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_engine_local.h Minor updates 2023-12-21 08:12:06 +00:00
quic_fc.c Copyright year updates 2024-04-09 13:43:26 +02:00
quic_fifd.c Copyright year updates 2024-04-09 13:43:26 +02:00
quic_impl.c Close small race condition on error raising in QUIC 2025-09-24 12:19:20 +02:00
quic_lcidm.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_local.h Copyright year updates 2025-03-12 13:35:59 +00:00
quic_method.c Fix SSL_accept() 2025-04-14 08:52:18 +01:00
quic_obj.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_obj_local.h Copyright year updates 2025-03-12 13:35:59 +00:00
quic_port.c Ensure that the largest_pn values are migrated to our channel qrx 2025-08-07 13:16:25 -04:00
quic_port_local.h Copyright year updates 2025-03-12 13:35:59 +00:00
quic_rcidm.c Rename list macros 2024-09-26 10:02:30 +02:00
quic_reactor.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_reactor_wait_ctx.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_record_rx.c Ensure that the largest_pn values are migrated to our channel qrx 2025-08-07 13:16:25 -04:00
quic_record_shared.c ossl_qrl_enc_level_set_provide_secret(): Avoid leaking keyslot in error condition 2023-11-06 07:47:17 +00:00
quic_record_shared.h TX key update support, RX time and PN reporting, general refactoring 2022-09-02 10:03:55 +02:00
quic_record_tx.c Fix reallocation failure condition in qtx_resize_txe() 2025-08-22 09:11:15 -04:00
quic_record_util.c Copyright year updates 2024-09-05 09:35:49 +02:00
quic_rstream.c Copyright year updates 2023-09-07 09:59:15 +01:00
quic_rx_depack.c QUIC receiver may accidentally ACK packet it fails to process 2025-07-10 12:05:44 +02:00
quic_sf_list.c Copyright year updates 2023-09-07 09:59:15 +01:00
quic_srt_gen.c QUIC SRT GEN: Minor updates 2023-11-25 09:14:05 +00:00
quic_srtm.c Copyright year updates 2024-04-09 13:43:26 +02:00
quic_sstream.c QUIC SSTREAM: Fix bug in ossl_quic_sstream_is_totally_acked 2023-11-02 08:49:01 +00:00
quic_statm.c Copyright year updates 2023-09-07 09:59:15 +01:00
quic_stream_map.c Copyright year updates 2025-09-02 13:05:45 +00:00
quic_thread_assist.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_tls.c Reset qtls->local_transport_params_consumed to 0 on SSL_clear() 2025-06-03 18:29:21 +02:00
quic_tls_api.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_trace.c Copyright year updates 2025-03-12 13:35:59 +00:00
quic_tserver.c libssl: Silence warnings on Win64 builds 2025-07-02 17:26:26 +02:00
quic_txp.c crypto/params_dup.c: add overflow check to ossl_param_buf_alloc 2025-08-08 12:22:10 -04:00
quic_txpim.c Copyright year updates 2023-09-07 09:59:15 +01:00
quic_types.c Copyright year updates 2025-09-02 13:05:45 +00:00
quic_wire.c Copyright year updates 2024-04-09 13:43:26 +02:00
quic_wire_pkt.c libssl: Silence warnings on Win64 builds 2025-07-02 17:26:26 +02:00
uint_set.c Copyright year updates 2023-09-07 09:59:15 +01:00