summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2021-09-28 20:29:17 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-07 15:10:40 +0100
commitc663e97a2d986f3b3193d7b4a012127740be6177 (patch)
treed013e8ed78265c4b81d4475ec4cbcd0cc101779f /meta/recipes-core/systemd
parenta1fa9d11540b5de1abf4bedcde746f9727377950 (diff)
downloadpoky-c663e97a2d986f3b3193d7b4a012127740be6177.tar.gz
systemd: fix CVE-2021-33910
Backport patch to fix CVE-2021-33910. (From OE-Core rev: 866a880c4fb58dea1e8460acea8152658376cd12) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core/systemd')
-rw-r--r--meta/recipes-core/systemd/systemd/0001-basic-unit-name-do-not-use-strdupa-on-a-path.patch72
-rw-r--r--meta/recipes-core/systemd/systemd_247.6.bb1
2 files changed, 73 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0001-basic-unit-name-do-not-use-strdupa-on-a-path.patch b/meta/recipes-core/systemd/systemd/0001-basic-unit-name-do-not-use-strdupa-on-a-path.patch
new file mode 100644
index 0000000000..0ab8174441
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0001-basic-unit-name-do-not-use-strdupa-on-a-path.patch
@@ -0,0 +1,72 @@
1From b00674347337b7531c92fdb65590ab253bb57538 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
3Date: Wed, 23 Jun 2021 11:46:41 +0200
4Subject: [PATCH] basic/unit-name: do not use strdupa() on a path
5
6The path may have unbounded length, for example through a fuse mount.
7
8CVE-2021-33910: attacked controlled alloca() leads to crash in systemd and
9ultimately a kernel panic. Systemd parses the content of /proc/self/mountinfo
10and each mountpoint is passed to mount_setup_unit(), which calls
11unit_name_path_escape() underneath. A local attacker who is able to mount a
12filesystem with a very long path can crash systemd and the whole system.
13
14https://bugzilla.redhat.com/show_bug.cgi?id=1970887
15
16The resulting string length is bounded by UNIT_NAME_MAX, which is 256. But we
17can't easily check the length after simplification before doing the
18simplification, which in turns uses a copy of the string we can write to.
19So we can't reject paths that are too long before doing the duplication.
20Hence the most obvious solution is to switch back to strdup(), as before
217410616cd9dbbec97cf98d75324da5cda2b2f7a2.
22
23(cherry picked from commit 441e0115646d54f080e5c3bb0ba477c892861ab9)
24(cherry picked from commit 764b74113e36ac5219a4b82a05f311b5a92136ce)
25(cherry picked from commit 4a1c5f34bd3e1daed4490e9d97918e504d19733b)
26
27CVE: CVE-2021-33910
28Upstream-Status: Backport [b00674347337b7531c92fdb65590ab253bb57538]
29Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
30---
31 src/basic/unit-name.c | 13 +++++--------
32 1 file changed, 5 insertions(+), 8 deletions(-)
33
34diff --git a/src/basic/unit-name.c b/src/basic/unit-name.c
35index 5f595af944..9b6cacde87 100644
36--- a/src/basic/unit-name.c
37+++ b/src/basic/unit-name.c
38@@ -378,12 +378,13 @@ int unit_name_unescape(const char *f, char **ret) {
39 }
40
41 int unit_name_path_escape(const char *f, char **ret) {
42- char *p, *s;
43+ _cleanup_free_ char *p = NULL;
44+ char *s;
45
46 assert(f);
47 assert(ret);
48
49- p = strdupa(f);
50+ p = strdup(f);
51 if (!p)
52 return -ENOMEM;
53
54@@ -395,13 +396,9 @@ int unit_name_path_escape(const char *f, char **ret) {
55 if (!path_is_normalized(p))
56 return -EINVAL;
57
58- /* Truncate trailing slashes */
59+ /* Truncate trailing slashes and skip leading slashes */
60 delete_trailing_chars(p, "/");
61-
62- /* Truncate leading slashes */
63- p = skip_leading_chars(p, "/");
64-
65- s = unit_name_escape(p);
66+ s = unit_name_escape(skip_leading_chars(p, "/"));
67 }
68 if (!s)
69 return -ENOMEM;
70--
712.33.0
72
diff --git a/meta/recipes-core/systemd/systemd_247.6.bb b/meta/recipes-core/systemd/systemd_247.6.bb
index f1db1e922b..e79c79a7fd 100644
--- a/meta/recipes-core/systemd/systemd_247.6.bb
+++ b/meta/recipes-core/systemd/systemd_247.6.bb
@@ -31,6 +31,7 @@ SRC_URI += "file://touchscreen.rules \
31 file://0002-sd-dhcp-client-shorten-code-a-bit.patch \ 31 file://0002-sd-dhcp-client-shorten-code-a-bit.patch \
32 file://0003-sd-dhcp-client-logs-when-dhcp-client-unexpectedly-ga.patch \ 32 file://0003-sd-dhcp-client-logs-when-dhcp-client-unexpectedly-ga.patch \
33 file://0004-sd-dhcp-client-tentatively-ignore-FORCERENEW-command.patch \ 33 file://0004-sd-dhcp-client-tentatively-ignore-FORCERENEW-command.patch \
34 file://0001-basic-unit-name-do-not-use-strdupa-on-a-path.patch \
34 " 35 "
35 36
36# patches needed by musl 37# patches needed by musl