summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJinfeng Wang <jinfeng.wang.cn@windriver.com>2024-09-30 10:19:50 +0800
committerSteve Sakoman <steve@sakoman.com>2024-10-07 05:43:22 -0700
commit8c4a3b7c651b0d9dccfc3efc8b8f0dbea9dd552a (patch)
tree7d9c0d556d4d14707a6862d398016fcdb345f3dd
parent18329f8b1cf0dbabb8837e48ef91257389813e21 (diff)
downloadpoky-8c4a3b7c651b0d9dccfc3efc8b8f0dbea9dd552a.tar.gz
procps: patch CVE-2023-4016
Previous patch[1] for CVE-2023-4016 is insufficent. Backport more from upstream master. There is one change needed to apply this patch: * change file location from local/xalloc.h to include/xalloc.h [1] https://git.openembedded.org/openembedded-core/commit/meta/recipes-extended/procps/procps/CVE-2023-4016.patch?h=kirkstone&id=71d0683d625c09d4db5e0473a0b15a266aa787f4 (From OE-Core rev: 94521a1e49e8fd9193211f486995d2e504f99d3f) Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-extended/procps/procps/CVE-2023-4016-2.patch60
-rw-r--r--meta/recipes-extended/procps/procps_3.3.17.bb3
2 files changed, 62 insertions, 1 deletions
diff --git a/meta/recipes-extended/procps/procps/CVE-2023-4016-2.patch b/meta/recipes-extended/procps/procps/CVE-2023-4016-2.patch
new file mode 100644
index 0000000000..7269068045
--- /dev/null
+++ b/meta/recipes-extended/procps/procps/CVE-2023-4016-2.patch
@@ -0,0 +1,60 @@
1From 93bb86a37a0cf7b9c71e374f3c9aac7dbfe2953a Mon Sep 17 00:00:00 2001
2From: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
3Date: Fri, 27 Sep 2024 14:22:32 +0800
4Subject: [PATCH] procps: patch CVE-2023-4016
5
6ps/parser: parse_list(): int overflow for large arg, free() of uninit. ptr
7
8* ps/parser.c:parse_list(): Regression (2c933ecb): node->u is uninitialized at
9 free(node->u) when reached before node->u=xcalloc().
10* ps/parser.c:parse_list(): When "arg" is very long, CVE-2023-4016 is triggered.
11 2c933ecb handles the multiplication issue, but there is still the possibility
12 of int overflow when incrementing "items".
13
14CVE: CVE-2023-4016
15
16Upstream-Status: Backport [https://gitlab.com/procps-ng/procps/-/commit/f5f843e257daeceaac2504b8957e84f4bf87a8f2]
17
18Signed-off-by: Jinfeng Wang <jinfeng.wang.cn@windriver.com>
19---
20 include/xalloc.h | 2 +-
21 ps/parser.c | 3 ++-
22 2 files changed, 3 insertions(+), 2 deletions(-)
23
24diff --git a/include/xalloc.h b/include/xalloc.h
25index 8b4d368f..a8046892 100644
26--- a/include/xalloc.h
27+++ b/include/xalloc.h
28@@ -42,7 +42,7 @@ void *xcalloc(const size_t nelems, const size_t size)
29 {
30 void *ret = calloc(nelems, size);
31 if (!ret && size && nelems)
32- xerrx(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", size);
33+ xerrx(XALLOC_EXIT_CODE, "cannot allocate %zu bytes", nelems*size);
34 return ret;
35 }
36
37diff --git a/ps/parser.c b/ps/parser.c
38index 5c92fce4..a94b49ff 100644
39--- a/ps/parser.c
40+++ b/ps/parser.c
41@@ -185,6 +185,7 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
42 /*** prepare to operate ***/
43 node = malloc(sizeof(selection_node));
44 node->n = 0;
45+ node->u = NULL;
46 buf = strdup(arg);
47 /*** sanity check and count items ***/
48 need_item = 1; /* true */
49@@ -198,7 +199,7 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
50 need_item=1;
51 break;
52 default:
53- if(need_item) items++;
54+ if(need_item && items<INT_MAX) items++;
55 need_item=0;
56 }
57 } while (*++walk);
58--
592.34.1
60
diff --git a/meta/recipes-extended/procps/procps_3.3.17.bb b/meta/recipes-extended/procps/procps_3.3.17.bb
index 897f28f187..bbec5a543c 100644
--- a/meta/recipes-extended/procps/procps_3.3.17.bb
+++ b/meta/recipes-extended/procps/procps_3.3.17.bb
@@ -17,6 +17,7 @@ SRC_URI = "git://gitlab.com/procps-ng/procps.git;protocol=https;branch=master \
17 file://0001-w.c-correct-musl-builds.patch \ 17 file://0001-w.c-correct-musl-builds.patch \
18 file://0002-proc-escape.c-add-missing-include.patch \ 18 file://0002-proc-escape.c-add-missing-include.patch \
19 file://CVE-2023-4016.patch \ 19 file://CVE-2023-4016.patch \
20 file://CVE-2023-4016-2.patch \
20 " 21 "
21SRCREV = "19a508ea121c0c4ac6d0224575a036de745eaaf8" 22SRCREV = "19a508ea121c0c4ac6d0224575a036de745eaaf8"
22 23
@@ -101,4 +102,4 @@ ALTERNATIVE_LINK_NAME[ps] = "${base_bindir}/ps"
101 102
102ALTERNATIVE:${PN}-sysctl = "sysctl" 103ALTERNATIVE:${PN}-sysctl = "sysctl"
103ALTERNATIVE_TARGET[sysctl] = "${base_sbindir}/sysctl" 104ALTERNATIVE_TARGET[sysctl] = "${base_sbindir}/sysctl"
104ALTERNATIVE_LINK_NAME[sysctl] = "${base_sbindir}/sysctl" \ No newline at end of file 105ALTERNATIVE_LINK_NAME[sysctl] = "${base_sbindir}/sysctl"