summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2023-08-21 14:32:19 +0100
committerSteve Sakoman <steve@sakoman.com>2023-09-04 04:13:24 -1000
commit78aa33756044f15dbe5bd863b90f801f5cdafda9 (patch)
treec61c631ed1ac102d7ee6e6e41aab85e83a081116
parent7b65658ede3253a6d22297a6c5550f1400274632 (diff)
downloadpoky-78aa33756044f15dbe5bd863b90f801f5cdafda9.tar.gz
procps: backport fix for CVE-2023-4016
(From OE-Core rev: 255515e1b52fea6d72d37fae61667db08eb5b086) (From OE-Core rev: 7841349843f0adbb1312729d81ab05b5c459db79) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit eae2a94f5de78b95590ec45e11e930655dbd5caf) Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-extended/procps/procps/CVE-2023-4016.patch73
-rw-r--r--meta/recipes-extended/procps/procps_4.0.3.bb1
2 files changed, 74 insertions, 0 deletions
diff --git a/meta/recipes-extended/procps/procps/CVE-2023-4016.patch b/meta/recipes-extended/procps/procps/CVE-2023-4016.patch
new file mode 100644
index 0000000000..202fea91f1
--- /dev/null
+++ b/meta/recipes-extended/procps/procps/CVE-2023-4016.patch
@@ -0,0 +1,73 @@
1From 2c933ecba3bb1d3041a5a7a53a7b4078a6003413 Mon Sep 17 00:00:00 2001
2From: Craig Small <csmall@dropbear.xyz>
3Date: Thu, 10 Aug 2023 21:18:38 +1000
4Subject: [PATCH] ps: Fix possible buffer overflow in -C option
5
6ps allocates memory using malloc(length of arg * len of struct).
7In certain strange circumstances, the arg length could be very large
8and the multiplecation will overflow, allocating a small amount of
9memory.
10
11Subsequent strncpy() will then write into unallocated memory.
12The fix is to use calloc. It's slower but this is a one-time
13allocation. Other malloc(x * y) calls have also been replaced
14by calloc(x, y)
15
16References:
17 https://www.freelists.org/post/procps/ps-buffer-overflow-CVE-20234016
18 https://nvd.nist.gov/vuln/detail/CVE-2023-4016
19 https://gitlab.com/procps-ng/procps/-/issues/297
20 https://bugs.debian.org/1042887
21
22Signed-off-by: Craig Small <csmall@dropbear.xyz>
23
24CVE: CVE-2023-4016
25Upstream-Status: Backport [https://gitlab.com/procps-ng/procps/-/commit/2c933ecba3bb1d3041a5a7a53a7b4078a6003413]
26Signed-off-by: Ross Burton <ross.burton@arm.com>
27---
28 NEWS | 1 +
29 src/ps/parser.c | 8 ++++----
30 2 files changed, 5 insertions(+), 4 deletions(-)
31
32diff --git a/src/ps/parser.c b/src/ps/parser.c
33index 248aa741..15873dfa 100644
34--- a/src/ps/parser.c
35+++ b/src/ps/parser.c
36@@ -189,7 +189,6 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
37 const char *err; /* error code that could or did happen */
38 /*** prepare to operate ***/
39 node = xmalloc(sizeof(selection_node));
40- node->u = xmalloc(strlen(arg)*sizeof(sel_union)); /* waste is insignificant */
41 node->n = 0;
42 buf = strdup(arg);
43 /*** sanity check and count items ***/
44@@ -210,6 +209,7 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
45 } while (*++walk);
46 if(need_item) goto parse_error;
47 node->n = items;
48+ node->u = xcalloc(items, sizeof(sel_union));
49 /*** actually parse the list ***/
50 walk = buf;
51 while(items--){
52@@ -1050,15 +1050,15 @@ static const char *parse_trailing_pids(void){
53 thisarg = ps_argc - 1; /* we must be at the end now */
54
55 pidnode = xmalloc(sizeof(selection_node));
56- pidnode->u = xmalloc(i*sizeof(sel_union)); /* waste is insignificant */
57+ pidnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
58 pidnode->n = 0;
59
60 grpnode = xmalloc(sizeof(selection_node));
61- grpnode->u = xmalloc(i*sizeof(sel_union)); /* waste is insignificant */
62+ grpnode->u = xcalloc(i,sizeof(sel_union)); /* waste is insignificant */
63 grpnode->n = 0;
64
65 sidnode = xmalloc(sizeof(selection_node));
66- sidnode->u = xmalloc(i*sizeof(sel_union)); /* waste is insignificant */
67+ sidnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
68 sidnode->n = 0;
69
70 while(i--){
71--
72GitLab
73
diff --git a/meta/recipes-extended/procps/procps_4.0.3.bb b/meta/recipes-extended/procps/procps_4.0.3.bb
index cc3420df4e..140e7bfd22 100644
--- a/meta/recipes-extended/procps/procps_4.0.3.bb
+++ b/meta/recipes-extended/procps/procps_4.0.3.bb
@@ -15,6 +15,7 @@ inherit autotools gettext pkgconfig update-alternatives
15SRC_URI = "git://gitlab.com/procps-ng/procps.git;protocol=https;branch=master \ 15SRC_URI = "git://gitlab.com/procps-ng/procps.git;protocol=https;branch=master \
16 file://sysctl.conf \ 16 file://sysctl.conf \
17 file://0001-src-w.c-use-utmp.h-only.patch \ 17 file://0001-src-w.c-use-utmp.h-only.patch \
18 file://CVE-2023-4016.patch \
18 " 19 "
19SRCREV = "806eb270f217ff7e1e745c7bda2b002b5be74be4" 20SRCREV = "806eb270f217ff7e1e745c7bda2b002b5be74be4"
20 21