]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
TLS: Avoid accessing listener socket flags from other threads
authorArtem Boldariev <artem@boldariev.com>
Wed, 30 Nov 2022 20:58:13 +0000 (22:58 +0200)
committerArtem Boldariev <artem@boldariev.com>
Thu, 1 Dec 2022 19:07:49 +0000 (21:07 +0200)
This commit ensures that the flags inside a TLS listener socket
object (and associated worker) are accessed when accepting a
connection only from within the context of the dedicated thread, but
not other worker threads.

lib/isc/netmgr/tlsstream.c

index f8a0bc6dc2bedfa2168831e67d66128f75441160..4a2497d52617030b5d481b61328d6b60d7172e57 100644 (file)
@@ -687,10 +687,9 @@ tlslisten_acceptcb(isc_nmhandle_t *handle, isc_result_t result, void *cbarg) {
        REQUIRE(VALID_NMSOCK(tlslistensock));
        REQUIRE(tlslistensock->type == isc_nm_tlslistener);
 
-       if (isc__nmsocket_closing(handle->sock) ||
-           isc__nmsocket_closing(tlslistensock) ||
-           !atomic_load(&tlslistensock->listening))
-       {
+       if (isc__nm_closing(handle->sock->worker)) {
+               return (ISC_R_SHUTTINGDOWN);
+       } else if (isc__nmsocket_closing(handle->sock)) {
                return (ISC_R_CANCELED);
        }