]> git.ipfire.org Git - thirdparty/bind9.git/commit
Fix the data race when shutting down dns_adb
authorOndřej Surý <ondrej@sury.org>
Mon, 15 Nov 2021 11:13:22 +0000 (12:13 +0100)
committerOndřej Surý <ondrej@sury.org>
Mon, 22 Nov 2021 10:09:21 +0000 (11:09 +0100)
commit7e002d89b451e7c939baf228a1e293ea8c11a0d4
tree6e638c5f25685a236fbc7c508aac17aad1823e31
parent9d94720735f118b234d15601d178950c943c64a3
Fix the data race when shutting down dns_adb

When dns_adb is shutting down, first the adb->shutting_down flag is set
and then task is created that runs shutdown_stage2() that sets the
shutdown flag on names and entries.  However, when dns_adb_createfind()
is called, only the individual shutdown flags are being checked, and the
global adb->shutting_down flag was not checked.  Because of that it was
possible for a different thread to slip in and create new find between
the dns_adb_shutdown() and dns_adb_detach(), but before the
shutdown_stage2() task is complete.  This was detected by
ThreadSanitizer as data race because the zonetable might have been
already detached by dns_view shutdown process and simultaneously
accessed by dns_adb_createfind().

This commit converts the adb->shutting_down to atomic_bool to prevent
the global adb lock when creating the find.
lib/dns/adb.c