[openssl/openssl] 1bfdcf: Prevent freeing of parent listener in SSL_listen_ex

0 views
Skip to first unread message

Neil Horman

unread,
10:22 AM (8 hours ago) 10:22 AM
to openssl...@openssl.org
Branch: refs/heads/master
Home: https://github.com/openssl/openssl
Commit: 1bfdcf90577f4474537da6b21474c02594f5868c
https://github.com/openssl/openssl/commit/1bfdcf90577f4474537da6b21474c02594f5868c
Author: Neil Horman <nho...@openssl.org>
Date: 2025-12-16 (Tue, 16 Dec 2025)

Changed paths:
M ssl/quic/quic_impl.c
M test/quicapitest.c

Log Message:
-----------
Prevent freeing of parent listener in SSL_listen_ex

Its been reported that, when using SSL_listen_ex to obtain a new
connection from a listener, that, if the listener is freed prior to the
obtained connection, we get use-after-free conditions when freeing said
obtained connections.

This occurs because SSL_listen_ex fails to take a reference on the
parent listener SSL object (in the same way that SSL_new_from_listener
does). If the listener is freed first, then several listener resources
are freed, which the obtained connection still makes use of, hence the
use-after-free.

The fix is to do what SSL_new_from_listener does, namely:
1) Increase the reference count on the listener SSL object.
2) Ensure that the connection qc->listener points to the listener object
so that, when the connection is freed, we call SSL_free on the
listener object, dropping the reference count we take in
SSL_listen_ex.

While we're at it, this PR also modifies the quicapi test for testing
the SSL_listen_ex call, freeing the listener first to ensure that the
increased refcount holds the SSL object data stable until the connection
is freed.

Thanks to Stanislav Fort at Asile Research for pointing out this issue.

fixes openssl/project#1766

Reviewed-by: Saša Nedvědický <sas...@openssl.org>
Reviewed-by: Matt Caswell <ma...@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29398)



To unsubscribe from these emails, change your notification settings at https://github.com/openssl/openssl/settings/notifications
Reply all
Reply to author
Forward
0 new messages