summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2022-07-17 07:50:27 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-07-18 11:47:37 +0100
commit832fb7c1c3edaf35650763af447f5aae192ef856 (patch)
treefccd75f074747538d79ac78e9ee4d96cc6893c0d /meta
parent7e6fed6af77aa66d51117a6b525da55168111e4d (diff)
downloadpoky-832fb7c1c3edaf35650763af447f5aae192ef856.tar.gz
lua: Backport fix for CVE-2022-33099
Fixes stack overflow while handling recurring errors in Lua-stack (From OE-Core rev: caad9d5f7184f0fa60fa7770e5d3da3f533647cb) Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/lua/lua/CVE-2022-33099.patch61
-rw-r--r--meta/recipes-devtools/lua/lua_5.4.4.bb1
2 files changed, 62 insertions, 0 deletions
diff --git a/meta/recipes-devtools/lua/lua/CVE-2022-33099.patch b/meta/recipes-devtools/lua/lua/CVE-2022-33099.patch
new file mode 100644
index 0000000000..fe7b6065c2
--- /dev/null
+++ b/meta/recipes-devtools/lua/lua/CVE-2022-33099.patch
@@ -0,0 +1,61 @@
1From 42d40581dd919fb134c07027ca1ce0844c670daf Mon Sep 17 00:00:00 2001
2From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
3Date: Fri, 20 May 2022 13:14:33 -0300
4Subject: [PATCH] Save stack space while handling errors
5
6Because error handling (luaG_errormsg) uses slots from EXTRA_STACK,
7and some errors can recur (e.g., string overflow while creating an
8error message in 'luaG_runerror', or a C-stack overflow before calling
9the message handler), the code should use stack slots with parsimony.
10
11This commit fixes the bug "Lua-stack overflow when C stack overflows
12while handling an error".
13
14CVE: CVE-2022-33099
15
16Upstream-Status: Backport [https://github.com/lua/lua/commit/42d40581dd919fb134c07027ca1ce0844c670daf]
17
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19---
20 ldebug.c | 5 ++++-
21 lvm.c | 6 ++++--
22 2 files changed, 8 insertions(+), 3 deletions(-)
23
24--- a/src/ldebug.c
25+++ b/src/ldebug.c
26@@ -824,8 +824,11 @@ l_noret luaG_runerror (lua_State *L, con
27 va_start(argp, fmt);
28 msg = luaO_pushvfstring(L, fmt, argp); /* format message */
29 va_end(argp);
30- if (isLua(ci)) /* if Lua function, add source:line information */
31+ if (isLua(ci)) { /* if Lua function, add source:line information */
32 luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));
33+ setobjs2s(L, L->top - 2, L->top - 1); /* remove 'msg' from the stack */
34+ L->top--;
35+ }
36 luaG_errormsg(L);
37 }
38
39--- a/src/lvm.c
40+++ b/src/lvm.c
41@@ -656,8 +656,10 @@ void luaV_concat (lua_State *L, int tota
42 /* collect total length and number of strings */
43 for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {
44 size_t l = vslen(s2v(top - n - 1));
45- if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl))
46+ if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl)) {
47+ L->top = top - total; /* pop strings to avoid wasting stack */
48 luaG_runerror(L, "string length overflow");
49+ }
50 tl += l;
51 }
52 if (tl <= LUAI_MAXSHORTLEN) { /* is result a short string? */
53@@ -672,7 +674,7 @@ void luaV_concat (lua_State *L, int tota
54 setsvalue2s(L, top - n, ts); /* create result */
55 }
56 total -= n-1; /* got 'n' strings to create 1 new */
57- L->top -= n-1; /* popped 'n' strings and pushed one */
58+ L->top = top - (n - 1); /* popped 'n' strings and pushed one */
59 } while (total > 1); /* repeat until only 1 result left */
60 }
61
diff --git a/meta/recipes-devtools/lua/lua_5.4.4.bb b/meta/recipes-devtools/lua/lua_5.4.4.bb
index 6f2cea5314..0b2e754b31 100644
--- a/meta/recipes-devtools/lua/lua_5.4.4.bb
+++ b/meta/recipes-devtools/lua/lua_5.4.4.bb
@@ -7,6 +7,7 @@ HOMEPAGE = "http://www.lua.org/"
7SRC_URI = "http://www.lua.org/ftp/lua-${PV}.tar.gz;name=tarballsrc \ 7SRC_URI = "http://www.lua.org/ftp/lua-${PV}.tar.gz;name=tarballsrc \
8 file://lua.pc.in \ 8 file://lua.pc.in \
9 file://CVE-2022-28805.patch \ 9 file://CVE-2022-28805.patch \
10 file://CVE-2022-33099.patch \
10 ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'http://www.lua.org/tests/lua-${PV_testsuites}-tests.tar.gz;name=tarballtest file://run-ptest ', '', d)} \ 11 ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'http://www.lua.org/tests/lua-${PV_testsuites}-tests.tar.gz;name=tarballtest file://run-ptest ', '', d)} \
11 " 12 "
12 13