]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_10] fix dispatch.c shutdown race
authorEvan Hunt <each@isc.org>
Fri, 21 Apr 2017 00:42:03 +0000 (17:42 -0700)
committerEvan Hunt <each@isc.org>
Fri, 21 Apr 2017 00:42:03 +0000 (17:42 -0700)
4952. [bug] A race condition on shutdown could trigger an
assertion failure in dispatch.c. [RT #43822]

(cherry picked from commit 019132b70c368bc9abca0034d07b324bb7cb6eb2)

CHANGES
lib/dns/dispatch.c
lib/dns/include/dns/dispatch.h

diff --git a/CHANGES b/CHANGES
index baeec24538ccca0acf2bf115a0f4192a181e0863..23675c0e998a233c270989a9f55c73b8c6ebe534 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4952.  [bug]           A race condition on shutdown could trigger an
+                       assertion failure in dispatch.c. [RT #43822]
+
 4591.  [port]          Addressed some python 3 compatibility issues.
                        Thanks to Ville Skytta. [RT #44955] [RT #44956]
 
index 3371af0baa46e4a84c9617a68d439dd7b4a35a1a..8122a743d8594a153d2baaaa24cca757b2e4e9f1 100644 (file)
@@ -3688,9 +3688,12 @@ dns_dispatch_importrecv(dns_dispatch_t *disp, isc_event_t *event) {
        REQUIRE((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) != 0);
        REQUIRE(event != NULL);
 
-       sevent = (isc_socketevent_t *)event;
+       if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) == 0)
+               return;
 
+       sevent = (isc_socketevent_t *)event;
        INSIST(sevent->n <= disp->mgr->buffersize);
+
        newsevent = (isc_socketevent_t *)
                    isc_event_allocate(disp->mgr->mctx, NULL,
                                      DNS_EVENT_IMPORTRECVDONE, udp_shrecv,
index f936f68c345f134e4d895a370d9a51df231733da..a692de4ca8a1a003cd3605c37749e41edebe3d3e 100644 (file)
@@ -524,6 +524,9 @@ dns_dispatch_importrecv(dns_dispatch_t *disp, isc_event_t *event);
  * shared between dispatchers and clients.  If the dispatcher fails to copy
  * or send the event, nothing happens.
  *
+ * If the attribute DNS_DISPATCHATTR_NOLISTEN is not set, then
+ * the dispatch is already handling a recv; return immediately.
+ *
  * Requires:
  *\li  disp is valid, and the attribute DNS_DISPATCHATTR_NOLISTEN is set.
  *     event != NULL