]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
make sure new_zone_lock is locked before unlocking it
authorEvan Hunt <each@isc.org>
Sun, 12 Jul 2020 04:30:53 +0000 (21:30 -0700)
committerEvan Hunt <each@isc.org>
Mon, 13 Jul 2020 23:53:14 +0000 (23:53 +0000)
it was possible for the count_newzones() function to try to
unlock view->new_zone_lock on return before locking it, which
caused a crash on shutdown.

(cherry picked from commit ed37c63e2bbc4afe299dbe38ae98871dcc1d3470)

bin/named/server.c

index 43b1e78af710475e4a9cccd598294dfee4dbb7f0..c1667235d1211c82faa58aba1c9071eafa545683 100644 (file)
@@ -7575,6 +7575,8 @@ count_newzones(dns_view_t *view, ns_cfgctx_t *nzcfg, int *num_zonesp) {
 
        REQUIRE(num_zonesp != NULL);
 
+       LOCK(&view->new_zone_lock);
+
        CHECK(migrate_nzf(view));
 
        isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
@@ -7583,8 +7585,6 @@ count_newzones(dns_view_t *view, ns_cfgctx_t *nzcfg, int *num_zonesp) {
                      "for view '%s'",
                      view->new_zone_db, view->name);
 
-       LOCK(&view->new_zone_lock);
-
        CHECK(nzd_count(view, &n));
 
        *num_zonesp = n;
@@ -12913,6 +12913,10 @@ cleanup:
        return (result);
 }
 
+/*
+ * Migrate zone configuration from an NZF file to an NZD database.
+ * Caller must hold view->new_zone_lock.
+ */
 static isc_result_t
 migrate_nzf(dns_view_t *view) {
        isc_result_t result;
@@ -12928,8 +12932,6 @@ migrate_nzf(dns_view_t *view) {
        MDB_val key, data;
        ns_dzarg_t dzarg;
 
-       LOCK(&view->new_zone_lock);
-
        /*
         * If NZF file doesn't exist, or NZD DB exists and already
         * has data, return without attempting migration.
@@ -13065,8 +13067,6 @@ cleanup:
                result = nzd_close(&txn, commit);
        }
 
-       UNLOCK(&view->new_zone_lock);
-
        if (text != NULL) {
                isc_buffer_free(&text);
        }