]> git.ipfire.org Git - thirdparty/bind9.git/commit
Fix a lock-order-inversion bug in resolver.c
authorAram Sargsyan <aram@isc.org>
Mon, 5 Jun 2023 14:35:42 +0000 (14:35 +0000)
committerAram Sargsyan <aram@isc.org>
Tue, 6 Jun 2023 11:02:24 +0000 (11:02 +0000)
commitdb45cab546042376685e20273c9a398f8be1aae1
tree92b8f1ac6076d49b2768519aac719f4f796893fd
parentff3d25a47f9f969669b2e4f5cde10c50f9cdd171
Fix a lock-order-inversion bug in resolver.c

There is a lock-order-inversion (potential deadlock) in resolver.c,
because in dns_resolver_shutdown() a resolver bucket lock is locked
while the resolver lock itself is already locked, while in
fctx_sendevents() the resolver lock is locked while a bucket lock
is locked before calling that function in fctx__done_detach().

The resolver lock/unlock in dns_resolver_shutdown() was added back in
the 317e36d47e1c5bc60783716a678255b60379590e commit to make sure that
the function is finished before the resolver object is destroyed.

Since res->exiting is atomic, it should be possible to remove the
resolver locking in dns_resolver_shutdown() and add it to the
send_shutdown_events() function which requires it.

Also, since 'res->exiting' is now set while unlocked, the 'INSIST'
in spillattimer_countdown() is wrong, and is removed.
lib/dns/resolver.c