diff mbox series

[scarthgap,3/3] busybox: fix CVE-2026-38753

Message ID 20261201155656.839273-4-joaomarcos.costa@bootlin.com
State New
Headers show
Series busybox: fix multiple High scored CVEs | expand

Commit Message

João Marcos Costa (Schneider Electric) Dec. 1, 2026, 3:56 p.m. UTC
A patch [1] to fix this vulnerability, marked as High [2], was submitted to
Busybox's mailing list, but not yet merged.

Backport the fix to busybox 1.36.1, and mark it as 'Pending'.

[1] https://lists.busybox.net/pipermail/busybox/2026-June/092354.html
[2] https://nvd.nist.gov/vuln/detail/cve-2026-38755

Signed-off-by: João Marcos Costa (Schneider Electric) <joaomarcos.costa@bootlin.com>
---
 .../busybox/busybox/CVE-2026-38755.patch      | 72 +++++++++++++++++++
 meta/recipes-core/busybox/busybox_1.36.1.bb   |  1 +
 2 files changed, 73 insertions(+)
 create mode 100644 meta/recipes-core/busybox/busybox/CVE-2026-38755.patch
diff mbox series

Patch

diff --git a/meta/recipes-core/busybox/busybox/CVE-2026-38755.patch b/meta/recipes-core/busybox/busybox/CVE-2026-38755.patch
new file mode 100644
index 0000000000..95a6303591
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/CVE-2026-38755.patch
@@ -0,0 +1,72 @@ 
+From cb2e18a92ca873780bf9a31f2070c4a4c8aa0f0a Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jo=C3=A3o=20Marcos=20Costa?= <joaomarcos.costa@bootlin.com>
+Date: Tue, 1 Dec 2026 16:20:37 +0100
+Subject: [PATCH] ash: fix stack overflow in evalfun()
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Recursive shell functions can repeatedly enter evalfun() until the
+process stack is exhausted. Track active shell function calls and raise a
+normal shell error when the recursion limit is reached.
+
+The counter is decremented through the existing funcdone cleanup path so
+errors raised from inside the function body unwind it correctly.
+
+Signed-off-by: Sanghyun Park <sanghyun.park.cnu@gmail.com>
+
+CVE: CVE-2026-38755
+Upstream-Status: Pending [https://lists.busybox.net/pipermail/busybox/2026-June/092354.html]
+
+Signed-off-by: João Marcos Costa (Schneider Electric) <joaomarcos.costa@bootlin.com>
+---
+ shell/ash.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/shell/ash.c b/shell/ash.c
+index e77c8d19a..917798f0f 100644
+--- a/shell/ash.c
++++ b/shell/ash.c
+@@ -402,6 +402,7 @@ struct globals_misc {
+ 	int shlvl;
+ #define rootshell (!shlvl)
+ 	int errlinno;
++	unsigned func_depth;
+ 
+ 	char *minusc;  /* argument to -c option */
+ 
+@@ -489,6 +490,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
+ #define rootpid     (G_misc.rootpid    )
+ #define shlvl       (G_misc.shlvl      )
+ #define errlinno    (G_misc.errlinno   )
++#define func_depth  (G_misc.func_depth )
+ #define minusc      (G_misc.minusc     )
+ #define curdir      (G_misc.curdir     )
+ #define physdir     (G_misc.physdir    )
+@@ -9918,6 +9920,10 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
+ 	int savefuncline;
+ 	char *savefuncname;
+ 	char *savetrap = NULL;
++	enum { MAX_ASH_FUNC_DEPTH = 1000 };
++
++	if (func_depth >= MAX_ASH_FUNC_DEPTH)
++		ash_msg_and_raise_error("function recursion limit exceeded");
+ 
+ 	if (!Eflag) {
+ 		savetrap = trap[NTRAP_ERR];
+@@ -9936,6 +9942,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
+ 	exception_handler = &jmploc;
+ 	shellparam.malloced = 0;
+ 	func->count++;
++	func_depth++;
+ 	funcname = func->n.ndefun.text;
+ 	funcline = func->n.ndefun.linno;
+ 	INT_ON;
+@@ -9957,6 +9964,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
+ 	}
+ 	funcline = savefuncline;
+ 	lineno = savelineno;
++	func_depth--;
+ 	freefunc(func);
+ 	freeparam(&shellparam);
+ 	shellparam = saveparam;
diff --git a/meta/recipes-core/busybox/busybox_1.36.1.bb b/meta/recipes-core/busybox/busybox_1.36.1.bb
index 68dea62557..606fe23375 100644
--- a/meta/recipes-core/busybox/busybox_1.36.1.bb
+++ b/meta/recipes-core/busybox/busybox_1.36.1.bb
@@ -70,6 +70,7 @@  SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
            file://CVE-2024-58251.patch \
            file://CVE-2026-38752.patch \
            file://CVE-2026-38753.patch \
+           file://CVE-2026-38755.patch \
            "
 SRC_URI:append:libc-musl = " file://musl.cfg "
 # TODO http://lists.busybox.net/pipermail/busybox/2023-January/090078.html