Bug #9063
closedoutput-lua: streaming buffer registry entry references a dead stack object
Description
- Status: present in
main(9b7938aec); latent (no getter caller today) - Class: registry entry pointing at a dead stack object
- Component:
src/output-lua.c:124-137(LuaStreamingLogger),src/util-lua.c:254-268
Description¶
LuaStreamingLogger() creates the buffer descriptor on the stack:
LuaStateSetStreamingBuffer() stores &b in the Lua registry; it is never cleared, so after the callback returns the registry holds a dangling stack pointer. LuaStateGetStreamingBuffer() (registered API, dist/suricata.lua docs?) has no caller in the tree today, so the dangling pointer is currently unread; any future consumer would dereference a dead stack frame.
Related: for streaming chunks without OUTPUT_STREAMING_FLAG_TRANSACTION, LuaStateSetTX is skipped (output-lua.c:134) while the registry key keeps the previous transaction's tx pointer (same class as the tx staleness issue).
Fix direction¶
Remove the registry entry and the accessor, or store a value copy / clear the entry (LuaStateSetStreamingBuffer(luastate, NULL)) after the call. Set TX to NULL for non-transaction chunks.
Test¶
lua-output-streaming-stale (unit: assert the registry entry is NULL after a callback) or delete the dead accessor.
VJ Updated by Victor Julien about 2 months ago
- Status changed from New to In Progress
- Assignee changed from OISF Dev to Victor Julien
JI Updated by Jason Ish about 1 month ago
- Status changed from In Progress to In Review
MR1382