]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
lua/output: access luastate within lock
authorJason Ish <jason.ish@oisf.net>
Wed, 4 Jun 2025 17:26:52 +0000 (11:26 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 4 Jun 2025 21:14:41 +0000 (23:14 +0200)
Fixes Coverity issue:

CID 1648445: (#1 of 1): Data race condition (MISSING_LOCK)
4. missing_lock: Accessing td->lua_ctx->luastate without holding lock
LogLuaCtx_.m. Elsewhere, LogLuaCtx_.luastate is written to with
LogLuaCtx_.m held 41 out of 41 times.

src/output-lua.c

index 3e1edaef3291f97a905783f0eb7b8ce04ae81c7c..6f63fb1a706f8a32fdc683433d301d35b58e8829 100644 (file)
@@ -126,9 +126,8 @@ static int LuaStreamingLogger(ThreadVars *tv, void *thread_data, const Flow *f,
     }
 
     LogLuaThreadCtx *td = (LogLuaThreadCtx *)thread_data;
-    lua_State *luastate = td->lua_ctx->luastate;
-
     SCMutexLock(&td->lua_ctx->m);
+    lua_State *luastate = td->lua_ctx->luastate;
 
     LuaStateSetThreadVars(luastate, tv);
     if (flags & OUTPUT_STREAMING_FLAG_TRANSACTION)