From 6dca323ae0eafaf51fee26507c2d9565e14c41fa Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Sun, 12 Jul 2026 18:22:58 +0200 Subject: [PATCH] shunt-manager: Fix potential race between install and uninstall If the installation fails while a shunt is concurrently uninstalled, the entry could already be destroyed when trying to remove and destroy it after acquiring the lock again in `install()`. This change handles the conflict the same way trap-manager does since 69cbe2ca3fe4 ("trap-manager: Wait for install to finish before uninstalling"). Fixes: 616ff9a2369f ("shunt-manager: Remove stored entries if installation fails") --- src/libcharon/sa/shunt_manager.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcharon/sa/shunt_manager.c b/src/libcharon/sa/shunt_manager.c index b0c674c64..2b5cae816 100644 --- a/src/libcharon/sa/shunt_manager.c +++ b/src/libcharon/sa/shunt_manager.c @@ -377,6 +377,10 @@ METHOD(shunt_manager_t, uninstall, bool, entry_t *entry, *found = NULL; this->lock->write_lock(this->lock); + while (this->installing) + { + this->condvar->wait(this->condvar, this->lock); + } enumerator = this->shunts->create_enumerator(this->shunts); while (enumerator->enumerate(enumerator, &entry)) {