From: W.C.A. Wijngaards Date: Tue, 16 Jun 2026 08:42:39 +0000 (+0200) Subject: - Fix locking in libunbound ub_ctx_set_event call. X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f72e11ef5ba7641d672a618c3a45c13f4d0684e5;p=thirdparty%2Funbound.git - Fix locking in libunbound ub_ctx_set_event call. Thanks to Qifan Zhang, Palo Alto Networks, for the report. --- diff --git a/doc/Changelog b/doc/Changelog index 65c5983f2..0bcd8a182 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -36,6 +36,8 @@ inconsistency between secret and public keys. Also duplicate files are skipped. Thanks to Qifan Zhang, Palo Alto Networks, for the report. + - Fix locking in libunbound ub_ctx_set_event call. + Thanks to Qifan Zhang, Palo Alto Networks, for the report. 15 June 2026: Wouter - Fix to add `max-transfer-size` and `max-transfer-time` that diff --git a/libunbound/libunbound.c b/libunbound/libunbound.c index 9c6a3e309..8431b6bb1 100644 --- a/libunbound/libunbound.c +++ b/libunbound/libunbound.c @@ -1467,8 +1467,15 @@ ub_ctx_set_event(struct ub_ctx* ctx, struct event_base* base) { lock_basic_lock(&ctx->cfglock); /* destroy the current worker - safe to pass in NULL */ + + /* Unlock the cfglock during libworker_delete_event, since it + * calls context_release_alloc, that wants to lock cfglock again. + * Since the event base is used from one thread, the one that + * called this function, it is safe to do so. */ + lock_basic_unlock(&ctx->cfglock); libworker_delete_event(ctx->event_worker); ctx->event_worker = NULL; + lock_basic_lock(&ctx->cfglock); new_base = ub_libevent_event_base(base); if (new_base) ctx->event_base = new_base;