]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't issue ns_client_endrequest on a NS_CLIENTSTATE_READY client.
authorWitold Kręcicki <wpk@isc.org>
Mon, 17 Feb 2020 14:52:09 +0000 (15:52 +0100)
committerWitold Krecicki <wpk@isc.org>
Wed, 26 Feb 2020 12:15:01 +0000 (12:15 +0000)
Fix a potential assertion failure on shutdown in ns__client_endrequest.
Scenario:
1. We are shutting down, interface->clientmgr is gone.
2. We receive a packet, it gets through ns__client_request
3. mgr == NULL, return
4. isc_nmhandle_detach calls ns_client_reset_cb
5. ns_client_reset_cb calls ns_client_endrequest
6. INSIST(client->state == NS_CLIENTSTATE_WORKING ||
          client->state == NS_CLIENTSTATE_RECURSING) is not met
   - we haven't started processing this packet so
   client->state == NS_CLIENTSTATE_READY.
As a solution - don't do anything in ns_client_reset_cb if the client
is still in READY state.

lib/ns/client.c

index 63a6441ee5ca8918780ae83367c02625f83dafd8..269ebe1366504a873dcec0daef836180d285a3bb 100644 (file)
@@ -1577,6 +1577,14 @@ ns__client_reset_cb(void *client0) {
        ns_client_log(client, DNS_LOGCATEGORY_SECURITY, NS_LOGMODULE_CLIENT,
                      ISC_LOG_DEBUG(3), "reset client");
 
+       /*
+        * We never started processing this client, possible if we're
+        * shutting down, just exit.
+        */
+       if (client->state == NS_CLIENTSTATE_READY) {
+               return;
+       }
+
        ns_client_endrequest(client);
        if (client->tcpbuf != NULL) {
                isc_mem_put(client->mctx, client->tcpbuf,