summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-core/busybox/busybox/CVE-2022-48174.patch80
-rw-r--r--meta/recipes-core/busybox/busybox_1.35.0.bb1
2 files changed, 81 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/CVE-2022-48174.patch b/meta/recipes-core/busybox/busybox/CVE-2022-48174.patch
new file mode 100644
index 0000000000..dd0ea19f02
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/CVE-2022-48174.patch
@@ -0,0 +1,80 @@
1From cf5d0889262e1b04ec2aa4caff2f5da2d602c665 Mon Sep 17 00:00:00 2001
2From: Denys Vlasenko <vda.linux@googlemail.com>
3Date: Mon, 12 Jun 2023 17:48:47 +0200
4Subject: [PATCH] busybox: shell: avoid segfault on ${0::0/0~09J}. Closes 15216
5function old new delta evaluate_string 1011 1053 +42
6
7Upstream-Status: Backport [https://git.busybox.net/busybox/commit/?id=d417193cf37ca1005830d7e16f5fa7e1d8a44209]
8CVE: CVE-2022-48174
9
10Signed-off-by: Meenali Gupta <meenali.gupta@windriver.com>
11---
12 shell/math.c | 39 +++++++++++++++++++++++++++++++++++----
13 1 file changed, 35 insertions(+), 4 deletions(-)
14
15diff --git a/shell/math.c b/shell/math.c
16index 76d22c9..727c294 100644
17--- a/shell/math.c
18+++ b/shell/math.c
19@@ -577,6 +577,28 @@ static arith_t strto_arith_t(const char *nptr, char **endptr)
20 # endif
21 #endif
22
23+//TODO: much better estimation than expr_len/2? Such as:
24+//static unsigned estimate_nums_and_names(const char *expr)
25+//{
26+// unsigned count = 0;
27+// while (*(expr = skip_whitespace(expr)) != '\0') {
28+// const char *p;
29+// if (isdigit(*expr)) {
30+// while (isdigit(*++expr))
31+// continue;
32+// count++;
33+// continue;
34+// }
35+// p = endofname(expr);
36+// if (p != expr) {
37+// expr = p;
38+// count++;
39+// continue;
40+// }
41+// }
42+// return count;
43+//}
44+
45 static arith_t
46 evaluate_string(arith_state_t *math_state, const char *expr)
47 {
48@@ -584,10 +606,12 @@ evaluate_string(arith_state_t *math_state, const char *expr)
49 const char *errmsg;
50 const char *start_expr = expr = skip_whitespace(expr);
51 unsigned expr_len = strlen(expr) + 2;
52- /* Stack of integers */
53- /* The proof that there can be no more than strlen(startbuf)/2+1
54- * integers in any given correct or incorrect expression
55- * is left as an exercise to the reader. */
56+ /* Stack of integers/names */
57+ /* There can be no more than strlen(startbuf)/2+1
58+ * integers/names in any given correct or incorrect expression.
59+ * (modulo "09v09v09v09v09v" case,
60+ * but we have code to detect that early)
61+ */
62 var_or_num_t *const numstack = alloca((expr_len / 2) * sizeof(numstack[0]));
63 var_or_num_t *numstackptr = numstack;
64 /* Stack of operator tokens */
65@@ -652,6 +676,13 @@ evaluate_string(arith_state_t *math_state, const char *expr)
66 numstackptr->var = NULL;
67 errno = 0;
68 numstackptr->val = strto_arith_t(expr, (char**) &expr);
69+ /* A number can't be followed by another number, or a variable name.
70+ * We'd catch this later anyway, but this would require numstack[]
71+ * to be twice as deep to handle strings where _every_ char is
72+ * a new number or name. Example: 09v09v09v09v09v09v09v09v09v
73+ */
74+ if (isalnum(*expr) || *expr == '_')
75+ goto err;
76 //bb_error_msg("val:%lld", numstackptr->val);
77 if (errno)
78 numstackptr->val = 0; /* bash compat */
79--
802.40.0
diff --git a/meta/recipes-core/busybox/busybox_1.35.0.bb b/meta/recipes-core/busybox/busybox_1.35.0.bb
index e9ca6fdb1a..07a5137d2a 100644
--- a/meta/recipes-core/busybox/busybox_1.35.0.bb
+++ b/meta/recipes-core/busybox/busybox_1.35.0.bb
@@ -51,6 +51,7 @@ SRC_URI = "https://busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
51 file://0002-nslookup-sanitize-all-printed-strings-with-printable.patch \ 51 file://0002-nslookup-sanitize-all-printed-strings-with-printable.patch \
52 file://CVE-2022-30065.patch \ 52 file://CVE-2022-30065.patch \
53 file://0001-devmem-add-128-bit-width.patch \ 53 file://0001-devmem-add-128-bit-width.patch \
54 file://CVE-2022-48174.patch \
54 " 55 "
55SRC_URI:append:libc-musl = " file://musl.cfg " 56SRC_URI:append:libc-musl = " file://musl.cfg "
56 57