]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Don't use view->resolver directly when priming in dns_view_find()
authorOndřej Surý <ondrej@isc.org>
Wed, 9 Nov 2022 17:04:23 +0000 (18:04 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 11 Nov 2022 10:47:44 +0000 (11:47 +0100)
When starting priming from dns_view_find(), the dns_view shutdown could
be initiated by different thread, detaching from the resolver.  Use
dns_view_getresolver() to attach to the resolver under view->lock, so we
don't try to call dns_resolver_prime() with NULL pointer.

There are more accesses to view->resolver, (and also view->adb and
view->requestmgr that suffer from the same problem) in the dns_view
module, but they are all done in exclusive mode or under a view->lock.

lib/dns/view.c

index 38fb06a66564b5a447c6da849c071260f99a5cbd..e2cd0c1577b3100a5f31fd757dfca132ab907b6b 100644 (file)
@@ -1037,9 +1037,14 @@ db_find:
                         * We just used a hint.  Let the resolver know it
                         * should consider priming.
                         */
-                       dns_resolver_prime(view->resolver);
-                       dns_db_attach(view->hints, &db);
-                       result = DNS_R_HINT;
+                       dns_resolver_t *res = NULL;
+                       result = dns_view_getresolver(view, &res);
+                       if (result == ISC_R_SUCCESS) {
+                               dns_resolver_prime(res);
+                               dns_db_attach(view->hints, &db);
+                               dns_resolver_detach(&res);
+                               result = DNS_R_HINT;
+                       }
                } else if (result == DNS_R_NXRRSET) {
                        dns_db_attach(view->hints, &db);
                        result = DNS_R_HINTNXRRSET;