]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Lock check of DNS_ZONEFLG_EXITING flag
authorMark Andrews <marka@isc.org>
Thu, 15 Oct 2020 23:42:52 +0000 (10:42 +1100)
committerMark Andrews <marka@isc.org>
Thu, 10 Dec 2020 06:31:20 +0000 (06:31 +0000)
    WARNING: ThreadSanitizer: data race
    Read of size 4 at 0x000000000001 by thread T1 (mutexes: write M1):
    #0 dns_zone_refresh lib/dns/zone.c:10447
    #1 dns_zone_notifyreceive2 lib/dns/zone.c:13646
    #2 dns_zone_notifyreceive2 lib/dns/zone.c:13497
    #3 ns_notify_start bin/named/notify.c:150
    #4 client_request bin/named/client.c:3137
    #5 dispatch lib/isc/task.c:1157
    #6 run lib/isc/task.c:1331
    #7 <null> <null>

    Previous write of size 4 at 0x000000000001 by thread T2 (mutexes: write M2):
    #0 dns_zone_refresh lib/dns/zone.c:10466
    #1 zone_maintenance lib/dns/zone.c:10236
    #2 zone_timer lib/dns/zone.c:13136
    #3 dispatch lib/isc/task.c:1157
    #4 run lib/isc/task.c:1331
    #5 <null> <null>

lib/dns/zone.c

index d3d9f32bcc122561b07949311638df280223a49d..f09805f322954c8afb2dcb8cf4cc749b5f340682 100644 (file)
@@ -10462,15 +10462,17 @@ dns_zone_refresh(dns_zone_t *zone) {
 
        REQUIRE(DNS_ZONE_VALID(zone));
 
-       if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING))
+       LOCK_ZONE(zone);
+       if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) {
+               UNLOCK_ZONE(zone);
                return;
+       }
 
        /*
         * Set DNS_ZONEFLG_REFRESH so that there is only one refresh operation
         * in progress at a time.
         */
 
-       LOCK_ZONE(zone);
        oldflags = zone->flags;
        if (zone->masterscnt == 0) {
                DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_NOMASTERS);