Project

General

Profile

Actions

Bug #9063

closed
VJ VJ

output-lua: streaming buffer registry entry references a dead stack object

Bug #9063: output-lua: streaming buffer registry entry references a dead stack object

Added by Victor Julien 2 months ago. Updated 8 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Affected Versions:
Effort:
Difficulty:
Label:

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:

LuaStreamingBuffer b = { data, data_len, flags };
...
LuaStateSetStreamingBuffer(luastate, &b);

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.


Subtasks 1 (0 open — 1 closed)

Bug #9313: output-lua: streaming buffer registry entry references a dead stack object (8.0.x backport)ClosedVictor JulienActions
Actions

Also available in: PDF Atom