engine/mt: Ensure master lock held for reload

Issue: 7819

DetectEngineReload must hold the `master->lock`; recent changes changed
the locking usages to avoid deadlock when registering/handling tenants.
These changes added the presumption that the master lock is held at a
higher level. Coverity highlighted that the lock is not held
consistently.
pull/14077/head
Jeff Lucovsky 2 months ago committed by Victor Julien
parent 9d2d1c4f8f
commit 46a53aee73

@ -2303,6 +2303,7 @@ static void InjectPackets(
*
* If called in unix socket mode, it's possible that we don't have
* detect threads yet.
* NOTE: master MUST be locked before calling this
*
* \retval -1 error
* \retval 0 no detection threads
@ -4859,8 +4860,13 @@ int DetectEngineReload(const SCInstance *suri)
DetectEngineDeReference(&old_de_ctx);
SCLogDebug("going to reload the threads to use new_de_ctx %p", new_de_ctx);
DetectEngineMasterCtx *master = &g_master_de_ctx;
SCMutexLock(&master->lock);
/* update the threads */
DetectEngineReloadThreads(new_de_ctx);
SCMutexUnlock(&master->lock);
SCLogDebug("threads now run new_de_ctx %p", new_de_ctx);
/* walk free list, freeing the old_de_ctx */

Loading…
Cancel
Save