0005-BUG-MEDIUM-lua-bad-memory-access.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. From ea3b479be6cacb399a6541a00b1bdce17b0179d0 Mon Sep 17 00:00:00 2001
  2. From: Thierry FOURNIER <thierry.fournier@ozon.io>
  3. Date: Mon, 17 Jul 2017 00:44:40 +0200
  4. Subject: [PATCH 05/18] BUG/MEDIUM: lua: bad memory access
  5. We cannot perform garbage collection on unreferenced thread.
  6. This memory is now free and another Lua process can use it for
  7. other things.
  8. HAProxy is monothread, so this bug doesn't cause crash.
  9. This patch must be backported in 1.6 and 1.7
  10. (cherry picked from commit 7bd10d58d3aecf7cf1e5ee7df01193e07128a52d)
  11. Signed-off-by: Willy Tarreau <w@1wt.eu>
  12. ---
  13. src/hlua.c | 12 +++---------
  14. 1 file changed, 3 insertions(+), 9 deletions(-)
  15. diff --git a/src/hlua.c b/src/hlua.c
  16. index eb003558..a998860e 100644
  17. --- a/src/hlua.c
  18. +++ b/src/hlua.c
  19. @@ -895,16 +895,10 @@ void hlua_ctx_destroy(struct hlua *lua)
  20. * the garbage collection.
  21. */
  22. if (lua->flags & HLUA_MUST_GC) {
  23. - if (!SET_SAFE_LJMP(lua->T))
  24. + if (!SET_SAFE_LJMP(gL.T))
  25. return;
  26. - lua_gc(lua->T, LUA_GCCOLLECT, 0);
  27. - RESET_SAFE_LJMP(lua->T);
  28. - if (lua_status(lua->T) != LUA_OK) {
  29. - if (!SET_SAFE_LJMP(gL.T))
  30. - return;
  31. - lua_gc(gL.T, LUA_GCCOLLECT, 0);
  32. - RESET_SAFE_LJMP(gL.T);
  33. - }
  34. + lua_gc(gL.T, LUA_GCCOLLECT, 0);
  35. + RESET_SAFE_LJMP(gL.T);
  36. }
  37. lua->T = NULL;
  38. --
  39. 2.13.0