]> git.ipfire.org Git - thirdparty/openssl.git/commit
Close small race condition on error raising in QUIC
authorNeil Horman <nhorman@openssl.org>
Tue, 23 Sep 2025 09:40:06 +0000 (05:40 -0400)
committerTomas Mraz <tomas@openssl.org>
Wed, 24 Sep 2025 10:21:34 +0000 (12:21 +0200)
commit7c28c5d2e64025bcb35fd4529c5305e7f1b5062b
treef4f35518fcf7c104149f43b940dcd871bb438f78
parent39960bb02bcb6ed19436e926600fc8bc2ae364cc
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 1e70e8080a5b8766cb5f8b81127f90db9081e856)
ssl/quic/quic_impl.c