From 7513aeead88bfe58f0c62c6025126a0d969f7376 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 2 Sep 2022 16:20:33 -0700 Subject: [PATCH] fix a possible use-after-detach bug in rndc we need to detach the rndc task when calling isc_app_shutdown(), otherwise it may be detached before the last reference to it. while this does not prevent rndc from working, it causes a spurious core dump on shutdown. --- bin/rndc/rndc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index b81ed3ed26..c292a66dbf 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -307,6 +307,7 @@ rndc_senddone(isc_nmhandle_t *handle, isc_result_t result, void *arg) { atomic_load_acquire(&recvs) == 0) { shuttingdown = true; + isc_task_detach(&rndc_task); isc_app_shutdown(); } } @@ -392,6 +393,7 @@ rndc_recvdone(isc_nmhandle_t *handle, isc_result_t result, void *arg) { atomic_load_acquire(&sends) == 0) { shuttingdown = true; + isc_task_detach(&rndc_task); isc_app_shutdown(); } } @@ -1081,7 +1083,6 @@ main(int argc, char **argv) { fatal("isc_app_run() failed: %s", isc_result_totext(result)); } - isc_task_detach(&rndc_task); isc_managers_destroy(&netmgr, &taskmgr, NULL); /*