From d6001423af831572f1af555d8a4cebade010cca4 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Thu, 2 Mar 2023 10:18:11 +0000 Subject: [PATCH] catz: protect db_registered and db callback (un)registration with a lock Doing this to avoid a race between the 'dns__catz_update_cb()' and 'dns_catz_dbupdate_callback()' functions. (cherry picked from commit a87859f1fa05ce92e99acb2c12aae0245bc8e79e) --- lib/dns/catz.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dns/catz.c b/lib/dns/catz.c index 909b8a102c..30722db307 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -2500,6 +2500,7 @@ final: * update callback in zone_startload or axfr_makedb, but we will * call onupdate() artificially so we can register the callback here. */ + LOCK(&catzs->lock); if (!oldcatz->db_registered) { result = dns_db_updatenotify_register( updb, dns_catz_dbupdate_callback, oldcatz->catzs); @@ -2507,6 +2508,7 @@ final: oldcatz->db_registered = true; } } + UNLOCK(&catzs->lock); exit: catz->updateresult = result;