package/lua/5.1.5: add patch for CVE-2014-5461

This CVE is specific for the version 5.1.5 still present in Buildroot.
It has been fixed in 5.2.3 and thereby doesn't affects the other
versions available in Buildroot.

- CVE-2014-5461

Buffer overflow in the vararg functions in ldo.c in Lua 5.1 through
5.2.x before 5.2.3 allows context-dependent attackers to cause a denial
of service (crash) via a small number of arguments to a function with a
large number of fixed arguments.

For more information see:
  - https://security-tracker.debian.org/tracker/CVE-2014-5461
  - https://udd.debian.org/patches.cgi?src=lua5.1&version=5.1.5-11

A patch present in Debian is used to address this vulnerability.

Signed-off-by: Thomas Perale <thomas.perale@mind.be>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit a2c906ee3b)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
This commit is contained in:
Thomas Perale
2025-09-17 20:53:44 +02:00
parent ede4af8c58
commit 6726e03471
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
From: Enrico Tassi <gareuselesinge@debian.org>
Date: Tue, 26 Aug 2014 16:20:55 +0200
Subject: Fix stack overflow in vararg functions
CVE: CVE-2014-5461
Upstream: https://sources.debian.org/data/main/l/lua5.1/5.1.5-11/debian/patches/0004-Fix-stack-overflow-in-vararg-functions.patch
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
---
src/ldo.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ldo.c b/src/ldo.c
index d1bf786..30333bf 100644
--- a/src/ldo.c
+++ b/src/ldo.c
@@ -274,7 +274,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
CallInfo *ci;
StkId st, base;
Proto *p = cl->p;
- luaD_checkstack(L, p->maxstacksize);
+ luaD_checkstack(L, p->maxstacksize + p->numparams);
func = restorestack(L, funcr);
if (!p->is_vararg) { /* no varargs? */
base = func + 1;

View File

@@ -21,6 +21,12 @@ LUA_LICENSE_FILES = COPYRIGHT
endif
LUA_CPE_ID_VENDOR = lua
ifeq ($(BR2_PACKAGE_LUA_5_1),y)
# Only affect lua version 5.1.5
# 5.1.5/0003-Fix-stack-overflow-in-vararg-functions.patch
LUA_IGNORE_CVES += CVE-2014-5461
endif
LUA_PROVIDES = luainterpreter
LUA_CFLAGS = -Wall -fPIC -DLUA_USE_POSIX