From: Mark Andrews Date: Tue, 10 Nov 2020 04:53:06 +0000 (+1100) Subject: Lock zone before calling zone_namerd_tostr() X-Git-Tag: v9.16.9~7^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5340176c3671f426217680f8cd9aa01f722be0fe;p=thirdparty%2Fbind9.git Lock zone before calling zone_namerd_tostr() WARNING: ThreadSanitizer: data race Read of size 8 at 0x000000000001 by thread T1: #0 inline_raw lib/dns/zone.c:1375 #1 zone_namerd_tostr lib/dns/zone.c:15316 #2 dns_zone_name lib/dns/zone.c:15391 #3 xfrin_log lib/dns/xfrin.c:1605 #4 xfrin_destroy lib/dns/xfrin.c:1477 #5 dns_xfrin_detach lib/dns/xfrin.c:739 #6 xfrin_connect_done lib/dns/xfrin.c:970 #7 tcpdnsconnect_cb netmgr/tcpdns.c:786 #8 tcp_connect_cb netmgr/tcp.c:292 #9 #10 Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M1): #0 zone_shutdown lib/dns/zone.c:14462 #1 dispatch lib/isc/task.c:1152 #2 run lib/isc/task.c:1344 #3 Location is heap block of size 2769 at 0x000000000013 allocated by thread T3: #0 malloc #1 default_memalloc lib/isc/mem.c:713 #2 mem_get lib/isc/mem.c:622 #3 mem_allocateunlocked lib/isc/mem.c:1268 #4 isc___mem_allocate lib/isc/mem.c:1288 #5 isc__mem_allocate lib/isc/mem.c:2453 #6 isc___mem_get lib/isc/mem.c:1037 #7 isc__mem_get lib/isc/mem.c:2432 #8 dns_zone_create lib/dns/zone.c:984 #9 configure_zone bin/named/server.c:6502 #10 do_addzone bin/named/server.c:13391 #11 named_server_changezone bin/named/server.c:13788 #12 named_control_docommand bin/named/control.c:207 #13 control_command bin/named/controlconf.c:392 #14 dispatch lib/isc/task.c:1152 #15 run lib/isc/task.c:1344 #16 (cherry picked from commit 84f43903da742a4d1040ad0dd7f1d1dca23ac31c) --- diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 0384268b589..e57f6229f44 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15336,7 +15336,10 @@ void dns_zone_name(dns_zone_t *zone, char *buf, size_t length) { REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(buf != NULL); + + LOCK_ZONE(zone); zone_namerd_tostr(zone, buf, length); + UNLOCK_ZONE(zone); } void