]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix task timing race in setnsec3param()
authorOndřej Surý <ondrej@sury.org>
Mon, 19 Apr 2021 07:25:14 +0000 (09:25 +0200)
committerOndřej Surý <ondrej@isc.org>
Mon, 19 Apr 2021 09:48:39 +0000 (11:48 +0200)
When setnsec3param() is schedule from zone_postload() there's no
guarantee that `zone->db` is not `NULL` yet.  Thus when the
setnsec3param() is called, we need to check for `zone->db` existence and
reschedule the task, because calling `rss_post()` on a zone with empty
`.db` ends up with no-op (the function just returns).

(cherry picked from commit 0127ba6472a210f7ca41bf18e5a5c9b015f20c6c)

lib/dns/zone.c

index 8bc636d4a87ab7137b30e5a5c9f8d13e38cd32e5..fa6ed8ab5b61dc843af8ef6accbe208507d6a173 100644 (file)
@@ -20947,6 +20947,22 @@ setnsec3param(isc_task_t *task, isc_event_t *event) {
                 */
                ISC_LIST_APPEND(zone->rss_post, event, ev_link);
        } else {
+               bool rescheduled = false;
+               ZONEDB_LOCK(&zone->dblock, isc_rwlocktype_read);
+               /*
+                * The zone is not yet fully loaded. Reschedule the event to
+                * be picked up later. This turns this function into a busy
+                * wait, but it only happens at startup.
+                */
+               if (zone->db == NULL) {
+                       rescheduled = true;
+                       isc_task_send(task, &event);
+               }
+               ZONEDB_UNLOCK(&zone->dblock, isc_rwlocktype_read);
+               if (rescheduled) {
+                       return;
+               }
+
                rss_post(zone, event);
        }
        dns_zone_idetach(&zone);