]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Destroy query in killoldestquery under a lock.
authorWitold Kręcicki <wpk@isc.org>
Tue, 3 Mar 2020 09:09:17 +0000 (10:09 +0100)
committerWitold Krecicki <wpk@isc.org>
Thu, 5 Mar 2020 08:13:50 +0000 (08:13 +0000)
Fixes a race between ns_client_killoldestquery and ns_client_endrequest -
killoldestquery takes a client from `recursing` list while endrequest
destroys client object, then killoldestquery works on a destroyed client
object. Prevent it by holding reclist lock while cancelling query.

lib/ns/client.c

index 5a0a913efd7865d0db95c2561c6f58a83935176d..9900866c35600783228ea986046e0ff9308bff86 100644 (file)
@@ -170,13 +170,11 @@ ns_client_killoldestquery(ns_client_t *client) {
        oldest = ISC_LIST_HEAD(client->manager->recursing);
        if (oldest != NULL) {
                ISC_LIST_UNLINK(client->manager->recursing, oldest, rlink);
-               UNLOCK(&client->manager->reclock);
                ns_query_cancel(oldest);
                ns_stats_increment(client->sctx->nsstats,
                                   ns_statscounter_reclimitdropped);
-       } else {
-               UNLOCK(&client->manager->reclock);
        }
+       UNLOCK(&client->manager->reclock);
 }
 
 void