From: Sheena Mira-ato Date: Wed, 20 Mar 2019 23:30:56 +0000 (+1300) Subject: trap-manager: Wait for install to finish before uninstalling X-Git-Tag: 5.8.0dr2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69cbe2ca3fe4d6e6607eac0d2b00a5eb682fe4a0;p=thirdparty%2Fstrongswan.git trap-manager: Wait for install to finish before uninstalling There was a race condition between install() and uninstall() where one thread was in the process of installing a trap entry, and had destroyed the child_sa, while the other thread was uninstalling the same trap entry and ended up trying to destroy the already destroyed child_sa, resulting in a segmentation fault in the destroy_entry() function. The uninstall() function needs to wait until all the threads are done with the installing before proceeding to uninstall a trap entry. Closes strongswan/strongswan#131. --- diff --git a/src/libcharon/sa/trap_manager.c b/src/libcharon/sa/trap_manager.c index 148df39238..c35b8c0de8 100644 --- a/src/libcharon/sa/trap_manager.c +++ b/src/libcharon/sa/trap_manager.c @@ -352,6 +352,10 @@ METHOD(trap_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->traps->create_enumerator(this->traps); while (enumerator->enumerate(enumerator, &entry)) {