]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add more zone locks
authorMatthijs Mekking <matthijs@isc.org>
Thu, 27 Feb 2020 10:59:12 +0000 (11:59 +0100)
committerMark Andrews <marka@isc.org>
Tue, 3 Mar 2020 05:28:37 +0000 (16:28 +1100)
Add more zone locks around code that touches zone timer setting
in failure modes.

(cherry picked from commit 143d1c9767e25d35dd939f43f6bae462ee9db477)

lib/dns/zone.c

index d2ce4ef2aabe07fb4dd2afcc8274458535a19adc..ccf376872c8ef654141433287843c5f56e3882bb 100644 (file)
@@ -6751,14 +6751,15 @@ zone_resigninc(dns_zone_t *zone) {
        if (version != NULL) {
                dns_db_closeversion(db, &version, false);
                dns_db_detach(&db);
-       } else if (db != NULL)
+       } else if (db != NULL) {
                dns_db_detach(&db);
+       }
+
+       LOCK_ZONE(zone);
        if (result == ISC_R_SUCCESS) {
-               LOCK_ZONE(zone);
                set_resigntime(zone);
                zone_needdump(zone, DNS_DUMP_DELAY);
                DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NEEDNOTIFY);
-               UNLOCK_ZONE(zone);
        } else {
                /*
                 * Something failed.  Retry in 5 minutes.
@@ -6767,6 +6768,7 @@ zone_resigninc(dns_zone_t *zone) {
                isc_interval_set(&ival, 300, 0);
                isc_time_nowplusinterval(&zone->resigntime, &ival);
        }
+       UNLOCK_ZONE(zone);
 
        INSIST(version == NULL);
 }
@@ -9024,6 +9026,7 @@ zone_sign(dns_zone_t *zone) {
        } else if (db != NULL)
                dns_db_detach(&db);
 
+       LOCK_ZONE(zone);
        if (ISC_LIST_HEAD(zone->signing) != NULL) {
                isc_interval_t interval;
                if (zone->update_disabled || result != ISC_R_SUCCESS)
@@ -9031,8 +9034,10 @@ zone_sign(dns_zone_t *zone) {
                else
                        isc_interval_set(&interval, 0, 10000000); /* 10 ms */
                isc_time_nowplusinterval(&zone->signingtime, &interval);
-       } else
+       } else {
                isc_time_settoepoch(&zone->signingtime);
+       }
+       UNLOCK_ZONE(zone);
 
        INSIST(version == NULL);
 }
@@ -18526,8 +18531,10 @@ zone_rekey(dns_zone_t *zone) {
         * Something went wrong; try again in ten minutes or
         * after a key refresh interval, whichever is shorter.
         */
+       LOCK_ZONE(zone);
        isc_interval_set(&ival, ISC_MIN(zone->refreshkeyinterval, 600), 0);
        isc_time_nowplusinterval(&zone->refreshkeytime, &ival);
+       UNLOCK_ZONE(zone);
        goto done;
 }