From ab07803465f46f71f8f910c080a5644a4068006f Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Mon, 7 Oct 2024 12:26:59 +0000 Subject: [PATCH] Fix a data race in dns_zone_getxfrintime() The dns_zone_getxfrintime() function fails to lock the zone before accessing its 'xfrintime' structure member, which can cause a data race between soa_query() and the statistics channel. Add the missing locking/unlocking pair, like it's done in numerous other similar functions. --- lib/dns/include/dns/zone.h | 2 +- lib/dns/zone.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index 86f2f36329..e30ac2f73f 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -1555,7 +1555,7 @@ dns_zone_getprimaryaddr(dns_zone_t *zone); */ isc_time_t -dns_zone_getxfrintime(const dns_zone_t *zone); +dns_zone_getxfrintime(dns_zone_t *zone); /*%< * Get the start time of the zone's latest major step before an incoming zone * transfer is initiated. The time is set to the current time before the diff --git a/lib/dns/zone.c b/lib/dns/zone.c index f1567be0ba..51eb23890a 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -18169,10 +18169,16 @@ dns_zone_getprimaryaddr(dns_zone_t *zone) { } isc_time_t -dns_zone_getxfrintime(const dns_zone_t *zone) { +dns_zone_getxfrintime(dns_zone_t *zone) { + isc_time_t xfrintime; + REQUIRE(DNS_ZONE_VALID(zone)); - return (zone->xfrintime); + LOCK_ZONE(zone); + xfrintime = zone->xfrintime; + UNLOCK_ZONE(zone); + + return (xfrintime); } static void