From 151d6ceb606eb465dd3ad09f33c944b68c575459 Mon Sep 17 00:00:00 2001 From: Madelyn Olson Date: Mon, 6 Jan 2025 14:02:22 -0800 Subject: [PATCH] Fix LUA garbage collector (CVE-2024-46981) (#1513) Reset GC state before closing the lua VM to prevent user data to be wrongly freed while still might be used on destructor callbacks. Created and publish by Redis in their OSS branch. Signed-off-by: Madelyn Olson Co-authored-by: YaacovHazan --- src/eval.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/eval.c b/src/eval.c index e3ffd3f5e4..6e9131a6ef 100644 --- a/src/eval.c +++ b/src/eval.c @@ -279,6 +279,7 @@ void scriptingRelease(int async) { else dictRelease(lctx.lua_scripts); lctx.lua_scripts_mem = 0; + lua_gc(lctx.lua, LUA_GCCOLLECT, 0); lua_close(lctx.lua); }