]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Lock access to flags in dns__zone_loadpending
authorMark Andrews <marka@isc.org>
Thu, 20 Aug 2020 00:55:58 +0000 (10:55 +1000)
committerMark Andrews <marka@isc.org>
Wed, 2 Sep 2020 09:35:43 +0000 (09:35 +0000)
==================
WARNING: ThreadSanitizer: data race (pid=1938)
  Read of size 4 at 0x7b7800000dd4 by main thread:
    #0 dns__zone_loadpending /builds/isc-projects/bind9/lib/dns/zone.c:2308:10 (libdns.so.1110+0x1da342)
    #1 asyncload_zone /builds/isc-projects/bind9/lib/dns/tests/zt_test.c:204:9 (zt_test+0x4b8303)
    #2 <null> <null> (libcmocka.so.0+0x50d8)
    #3 __libc_start_main /build/glibc-vjB4T1/glibc-2.28/csu/../csu/libc-start.c:308:16 (libc.so.6+0x2409a)

  Previous write of size 4 at 0x7b7800000dd4 by thread T16 (mutexes: write M2181):
    #0 zone_asyncload /builds/isc-projects/bind9/lib/dns/zone.c:2237:3 (libdns.so.1110+0x1da08d)
    #1 dispatch /builds/isc-projects/bind9/lib/isc/task.c:1157:7 (libisc.so.1107+0x50845)
    #2 run /builds/isc-projects/bind9/lib/isc/task.c:1331:2 (libisc.so.1107+0x4d799)

lib/dns/zone.c

index c8e880f4c1d180bf81ea35a417aeca1ee9fd4a88..97e24c7e7fdf02158b974a47b71d7740349a0abf 100644 (file)
@@ -2303,9 +2303,14 @@ dns_zone_asyncload2(dns_zone_t *zone, dns_zt_zoneloaded_t done, void * arg,
 
 bool
 dns__zone_loadpending(dns_zone_t *zone) {
+       bool result;
+
        REQUIRE(DNS_ZONE_VALID(zone));
 
-       return (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING));
+       LOCK_ZONE(zone);
+       result = DNS_ZONE_FLAG(zone, DNS_ZONEFLG_LOADPENDING) != 0;
+       UNLOCK_ZONE(zone);
+       return (result);
 }
 
 isc_result_t