From 791a046cc7eca91350984f0844ebfc5ea161a521 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Fri, 15 Dec 2023 09:43:36 +0000 Subject: [PATCH 1/2] Use atomic store operations instead of atomic initialize The atomic_init() function makes sense to use with structure's members when creating a new instance of a strucutre. In other places, use atomic store operations instead, in order to avoid data races. --- lib/dns/xfrin.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 148449ce62..697e8507c9 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -1260,8 +1260,8 @@ xfrin_start(dns_xfrin_t *xfr) { * The "SOA before" mode is used, where the SOA request is * using the same transport as the XFR. */ - atomic_init(&xfr->soa_transport_type, - dns_xfrin_gettransporttype(xfr)); + atomic_store_relaxed(&xfr->soa_transport_type, + dns_xfrin_gettransporttype(xfr)); } /* Set the maximum timer */ @@ -1552,10 +1552,10 @@ xfrin_send_request(dns_xfrin_t *xfr) { CHECK(add_opt(msg, udpsize, reqnsid, reqexpire)); } - atomic_init(&xfr->nmsg, 0); - atomic_init(&xfr->nrecs, 0); - atomic_init(&xfr->nbytes, 0); - atomic_init(&xfr->start, isc_time_now()); + atomic_store_relaxed(&xfr->nmsg, 0); + atomic_store_relaxed(&xfr->nrecs, 0); + atomic_store_relaxed(&xfr->nbytes, 0); + atomic_store_relaxed(&xfr->start, isc_time_now()); msg->id = xfr->id; if (xfr->tsigctx != NULL) { From 2179224573fa9163131822329145d6d7953b08c8 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Fri, 15 Dec 2023 09:48:19 +0000 Subject: [PATCH 2/2] Add a CHANGES note for [GL #4493] --- CHANGES | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index 82989bbccc..c35817b3ab 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +6301. [bug] Fix data races with atomic members of the xfrin + structure in xfrin_start() and xfrin_send_request() + functions. [GL #4493] + 6300. [bug] Fix statistics export to use full 64 bit signed numbers instead of truncating values to unsigned 32 bits. [GL #4467]