summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2025-07-01 12:09:15 +0800
committerSteve Sakoman <steve@sakoman.com>2025-07-09 08:23:23 -0700
commita17ec857dfeca61b7efbaafd6c89cbba69142ddf (patch)
tree4a2f45b5f2b8b68b14288e8a33180e0217efd907
parent8a1287dec6aa32195de6e451e0d30c61d4ea713f (diff)
downloadpoky-a17ec857dfeca61b7efbaafd6c89cbba69142ddf.tar.gz
systemd: backport patches to fix CVE-2025-4598
Patch 0003 is the actual patch to fix CVE. Patch 0002 is a preparation patch which systemd upstream uses for all actively maintained branches in preparation for patch 0003. Patch 0001 is a bug fix patch and is needed to avoid conflict introduced by patch 0002. Note that patch 0002 claims itself to be of no functional change, so this patch 0001 is really needed for patch 0002. Patch 0004 is a compilation fix patch which adds a macro needed by previous 0002 patch. (From OE-Core rev: a2e75ca4fa01d5005906fb88d28d52ea951def00) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
-rw-r--r--meta/recipes-core/systemd/systemd/CVE-2025-4598-0001.patch92
-rw-r--r--meta/recipes-core/systemd/systemd/CVE-2025-4598-0002.patch106
-rw-r--r--meta/recipes-core/systemd/systemd/CVE-2025-4598-0003.patch144
-rw-r--r--meta/recipes-core/systemd/systemd/CVE-2025-4598-0004.patch36
-rw-r--r--meta/recipes-core/systemd/systemd_250.14.bb4
5 files changed, 382 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/CVE-2025-4598-0001.patch b/meta/recipes-core/systemd/systemd/CVE-2025-4598-0001.patch
new file mode 100644
index 0000000000..cf27acafe9
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/CVE-2025-4598-0001.patch
@@ -0,0 +1,92 @@
1From 2108812a76bd078a2bbd7583308ff18bf01f2383 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
3Date: Tue, 29 Apr 2025 14:47:59 +0200
4Subject: [PATCH 1/3] coredump: restore compatibility with older patterns
5
6This was broken in f45b8015513d38ee5f7cc361db9c5b88c9aae704. Unfortunately
7the review does not talk about backward compatibility at all. There are
8two places where it matters:
9- During upgrades, the replacement of kernel.core_pattern is asynchronous.
10 For example, during rpm upgrades, it would be updated a post-transaction
11 file trigger. In other scenarios, the update might only happen after
12 reboot. We have a potentially long window where the old pattern is in
13 place. We need to capture coredumps during upgrades too.
14- With --backtrace. The interface of --backtrace, in hindsight, is not
15 great. But there are users of --backtrace which were written to use
16 a specific set of arguments, and we can't just break compatiblity.
17 One example is systemd-coredump-python, but there are also reports of
18 users using --backtrace to generate coredump logs.
19
20Thus, we require the original set of args, and will use the additional args if
21found.
22
23A test is added to verify that --backtrace works with and without the optional
24args.
25
26(cherry picked from commit ded0aac389e647d35bce7ec4a48e718d77c0435b)
27(cherry picked from commit f9b8b75c11bba9b63096904be98cc529c304eb97)
28(cherry picked from commit 385a33b043406ad79a7207f3906c3b15192a3333)
29(cherry picked from commit c6f79626b6d175c6a5b62b8c5d957a83eb882301)
30(cherry picked from commit 9f02346d50e33c24acf879ce4dd5937d56473325)
31(cherry picked from commit ac0aa5d1fdc21db1ef035fce562cb6fc8602b544)
32
33Upstream-Status: Backport [https://github.com/systemd/systemd-stable/commit/cadd1b1a1f39fd13b1115a10f563017201d7b56a]
34
35Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
36---
37 src/coredump/coredump.c | 21 ++++++++++++++-------
38 1 file changed, 14 insertions(+), 7 deletions(-)
39
40diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
41index 79280ab986..d598f6f59a 100644
42--- a/src/coredump/coredump.c
43+++ b/src/coredump/coredump.c
44@@ -84,8 +84,12 @@ enum {
45 META_ARGV_SIGNAL, /* %s: number of signal causing dump */
46 META_ARGV_TIMESTAMP, /* %t: time of dump, expressed as seconds since the Epoch (we expand this to µs granularity) */
47 META_ARGV_RLIMIT, /* %c: core file size soft resource limit */
48- META_ARGV_HOSTNAME, /* %h: hostname */
49+ _META_ARGV_REQUIRED,
50+ /* The fields below were added to kernel/core_pattern at later points, so they might be missing. */
51+ META_ARGV_HOSTNAME = _META_ARGV_REQUIRED, /* %h: hostname */
52 _META_ARGV_MAX,
53+ /* If new fields are added, they should be added here, to maintain compatibility
54+ * with callers which don't know about the new fields. */
55
56 /* The following indexes are cached for a couple of special fields we use (and
57 * thereby need to be retrieved quickly) for naming coredump files, and attaching
58@@ -96,7 +100,7 @@ enum {
59 _META_MANDATORY_MAX,
60
61 /* The rest are similar to the previous ones except that we won't fail if one of
62- * them is missing. */
63+ * them is missing in a message sent over the socket. */
64
65 META_EXE = _META_MANDATORY_MAX,
66 META_UNIT,
67@@ -1278,14 +1282,17 @@ static int gather_pid_metadata_from_argv(
68 char *t;
69
70 /* We gather all metadata that were passed via argv[] into an array of iovecs that
71- * we'll forward to the socket unit */
72+ * we'll forward to the socket unit.
73+ *
74+ * We require at least _META_ARGV_REQUIRED args, but will accept more.
75+ * We know how to parse _META_ARGV_MAX args. The rest will be ignored. */
76
77- if (argc < _META_ARGV_MAX)
78+ if (argc < _META_ARGV_REQUIRED)
79 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
80- "Not enough arguments passed by the kernel (%i, expected %i).",
81- argc, _META_ARGV_MAX);
82+ "Not enough arguments passed by the kernel (%i, expected between %i and %i).",
83+ argc, _META_ARGV_REQUIRED, _META_ARGV_MAX);
84
85- for (int i = 0; i < _META_ARGV_MAX; i++) {
86+ for (int i = 0; i < MIN(argc, _META_ARGV_MAX); i++) {
87
88 t = argv[i];
89
90--
912.34.1
92
diff --git a/meta/recipes-core/systemd/systemd/CVE-2025-4598-0002.patch b/meta/recipes-core/systemd/systemd/CVE-2025-4598-0002.patch
new file mode 100644
index 0000000000..0520bac87c
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/CVE-2025-4598-0002.patch
@@ -0,0 +1,106 @@
1From fb22bb743556d4d14463b0f0373c24d07d2e7b28 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
3Date: Mon, 26 May 2025 12:04:44 +0200
4Subject: [PATCH 2/3] coredump: get rid of _META_MANDATORY_MAX
5
6No functional change. This change is done in preparation for future changes.
7Currently, the list of fields which are received on the command line is a
8strict subset of the fields which are always expected to be received on a
9socket. But when we add new kernel args in the future, we'll have two
10non-overlapping sets and this approach will not work. Get rid of the variable
11and enumerate the required fields. This set will never change, so this is
12actually more maintainable.
13
14The message with the hint where to add new fields is switched with
15_META_ARGV_MAX. The new order is more correct.
16
17(cherry-picked from 49f1f2d4a7612bbed5211a73d11d6a94fbe3bb69)
18(cherry-picked from aea6a631bca93e8b04a11aaced694f25f4da155e)
19(cherry picked from cf16b6b6b2e0a656531bfd73ad66be3817b155cd)
20
21(cherry picked from commit b46a4f023cd80b24c8f1aa7a95700bc0cb828cdc)
22(cherry picked from commit 5855552310ed279180c21cb803408aa2ce36053d)
23(cherry picked from commit cc31f2d4146831b9f2fe7bf584468908ff9c4de5)
24
25Upstream-Status: Backport [https://github.com/systemd/systemd-stable/commit/2c81e60fe0b8c506a4fe902e45bed6f58f482b39]
26
27Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
28---
29 src/coredump/coredump.c | 29 ++++++++++++++++++++---------
30 1 file changed, 20 insertions(+), 9 deletions(-)
31
32diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
33index d598f6f59a..0b27086288 100644
34--- a/src/coredump/coredump.c
35+++ b/src/coredump/coredump.c
36@@ -71,7 +71,7 @@
37 * size. See DATA_SIZE_MAX in journal-importer.h. */
38 assert_cc(JOURNAL_SIZE_MAX <= DATA_SIZE_MAX);
39
40-enum {
41+typedef enum {
42 /* We use these as array indexes for our process metadata cache.
43 *
44 * The first indices of the cache stores the same metadata as the ones passed by
45@@ -87,9 +87,9 @@ enum {
46 _META_ARGV_REQUIRED,
47 /* The fields below were added to kernel/core_pattern at later points, so they might be missing. */
48 META_ARGV_HOSTNAME = _META_ARGV_REQUIRED, /* %h: hostname */
49- _META_ARGV_MAX,
50 /* If new fields are added, they should be added here, to maintain compatibility
51 * with callers which don't know about the new fields. */
52+ _META_ARGV_MAX,
53
54 /* The following indexes are cached for a couple of special fields we use (and
55 * thereby need to be retrieved quickly) for naming coredump files, and attaching
56@@ -97,16 +97,15 @@ enum {
57 * environment. */
58
59 META_COMM = _META_ARGV_MAX,
60- _META_MANDATORY_MAX,
61
62 /* The rest are similar to the previous ones except that we won't fail if one of
63 * them is missing in a message sent over the socket. */
64
65- META_EXE = _META_MANDATORY_MAX,
66+ META_EXE,
67 META_UNIT,
68 META_PROC_AUXV,
69 _META_MAX
70-};
71+} meta_argv_t;
72
73 static const char * const meta_field_names[_META_MAX] = {
74 [META_ARGV_PID] = "COREDUMP_PID=",
75@@ -1192,12 +1191,24 @@ static int process_socket(int fd) {
76 if (r < 0)
77 goto finish;
78
79- /* Make sure we received at least all fields we need. */
80- for (int i = 0; i < _META_MANDATORY_MAX; i++)
81+ /* Make sure we received all the expected fields. We support being called by an *older*
82+ * systemd-coredump from the outside, so we require only the basic set of fields that
83+ * was being sent when the support for sending to containers over a socket was added
84+ * in a108c43e36d3ceb6e34efe37c014fc2cda856000. */
85+ meta_argv_t i;
86+ VA_ARGS_FOREACH(i,
87+ META_ARGV_PID,
88+ META_ARGV_UID,
89+ META_ARGV_GID,
90+ META_ARGV_SIGNAL,
91+ META_ARGV_TIMESTAMP,
92+ META_ARGV_RLIMIT,
93+ META_ARGV_HOSTNAME,
94+ META_COMM)
95 if (!context.meta[i]) {
96 r = log_error_errno(SYNTHETIC_ERRNO(EINVAL),
97- "A mandatory argument (%i) has not been sent, aborting.",
98- i);
99+ "Mandatory argument %s not received on socket, aborting.",
100+ meta_field_names[i]);
101 goto finish;
102 }
103
104--
1052.34.1
106
diff --git a/meta/recipes-core/systemd/systemd/CVE-2025-4598-0003.patch b/meta/recipes-core/systemd/systemd/CVE-2025-4598-0003.patch
new file mode 100644
index 0000000000..737121af12
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/CVE-2025-4598-0003.patch
@@ -0,0 +1,144 @@
1From 89730dea979b2d22fd548b622cd88bac99ff1d6b Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
3Date: Tue, 29 Apr 2025 14:47:59 +0200
4Subject: [PATCH 3/3] coredump: use %d in kernel core pattern
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9The kernel provides %d which is documented as
10"dump mode—same as value returned by prctl(2) PR_GET_DUMPABLE".
11
12We already query /proc/pid/auxv for this information, but unfortunately this
13check is subject to a race, because the crashed process may be replaced by an
14attacker before we read this data, for example replacing a SUID process that
15was killed by a signal with another process that is not SUID, tricking us into
16making the coredump of the original process readable by the attacker.
17
18With this patch, we effectively add one more check to the list of conditions
19that need be satisfied if we are to make the coredump accessible to the user.
20
21Reportedy-by: Qualys Security Advisory <qsa@qualys.com>
22
23(cherry-picked from commit 0c49e0049b7665bb7769a13ef346fef92e1ad4d6)
24(cherry-picked from commit c58a8a6ec9817275bb4babaa2c08e0e35090d4e3)
25(cherry picked from commit 19d439189ab85dd7222bdd59fd442bbcc8ea99a7)
26(cherry picked from commit 254ab8d2a7866679cee006d844d078774cbac3c9)
27(cherry picked from commit 7fc7aa5a4d28d7768dfd1eb85be385c3ea949168)
28(cherry picked from commit 19b228662e0fcc6596c0395a0af8486a4b3f1627)
29
30CVE: CVE-2025-4598
31
32Upstream-Status: Backport [https://github.com/systemd/systemd-stable/commit/2eb46dce078334805c547cbcf5e6462cf9d2f9f0]
33
34Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
35---
36 man/systemd-coredump.xml | 12 ++++++++++++
37 src/coredump/coredump.c | 21 ++++++++++++++++++---
38 sysctl.d/50-coredump.conf.in | 2 +-
39 3 files changed, 31 insertions(+), 4 deletions(-)
40
41diff --git a/man/systemd-coredump.xml b/man/systemd-coredump.xml
42index cb9f47745b..ba7cad12bc 100644
43--- a/man/systemd-coredump.xml
44+++ b/man/systemd-coredump.xml
45@@ -259,6 +259,18 @@ COREDUMP_FILENAME=/var/lib/systemd/coredump/core.Web….552351.….zst
46 </listitem>
47 </varlistentry>
48
49+ <varlistentry>
50+ <term><varname>COREDUMP_DUMPABLE=</varname></term>
51+
52+ <listitem><para>The <constant>PR_GET_DUMPABLE</constant> field as reported by the kernel, see
53+ <citerefentry
54+ project='man-pages'><refentrytitle>prctl</refentrytitle><manvolnum>2</manvolnum></citerefentry>.
55+ </para>
56+
57+ <xi:include href="version-info.xml" xpointer="v258"/>
58+ </listitem>
59+ </varlistentry>
60+
61 <varlistentry>
62 <term><varname>COREDUMP_OPEN_FDS=</varname></term>
63
64diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
65index 0b27086288..aca6a2eb6b 100644
66--- a/src/coredump/coredump.c
67+++ b/src/coredump/coredump.c
68@@ -87,6 +87,7 @@ typedef enum {
69 _META_ARGV_REQUIRED,
70 /* The fields below were added to kernel/core_pattern at later points, so they might be missing. */
71 META_ARGV_HOSTNAME = _META_ARGV_REQUIRED, /* %h: hostname */
72+ META_ARGV_DUMPABLE, /* %d: as set by the kernel */
73 /* If new fields are added, they should be added here, to maintain compatibility
74 * with callers which don't know about the new fields. */
75 _META_ARGV_MAX,
76@@ -115,6 +116,7 @@ static const char * const meta_field_names[_META_MAX] = {
77 [META_ARGV_TIMESTAMP] = "COREDUMP_TIMESTAMP=",
78 [META_ARGV_RLIMIT] = "COREDUMP_RLIMIT=",
79 [META_ARGV_HOSTNAME] = "COREDUMP_HOSTNAME=",
80+ [META_ARGV_DUMPABLE] = "COREDUMP_DUMPABLE=",
81 [META_COMM] = "COREDUMP_COMM=",
82 [META_EXE] = "COREDUMP_EXE=",
83 [META_UNIT] = "COREDUMP_UNIT=",
84@@ -125,6 +127,7 @@ typedef struct Context {
85 const char *meta[_META_MAX];
86 size_t meta_size[_META_MAX];
87 pid_t pid;
88+ unsigned dumpable;
89 bool is_pid1;
90 bool is_journald;
91 } Context;
92@@ -470,14 +473,16 @@ static int grant_user_access(int core_fd, const Context *context) {
93 if (r < 0)
94 return r;
95
96- /* We allow access if we got all the data and at_secure is not set and
97- * the uid/gid matches euid/egid. */
98+ /* We allow access if dumpable on the command line was exactly 1, we got all the data,
99+ * at_secure is not set, and the uid/gid match euid/egid. */
100 bool ret =
101+ context->dumpable == 1 &&
102 at_secure == 0 &&
103 uid != UID_INVALID && euid != UID_INVALID && uid == euid &&
104 gid != GID_INVALID && egid != GID_INVALID && gid == egid;
105- log_debug("Will %s access (uid="UID_FMT " euid="UID_FMT " gid="GID_FMT " egid="GID_FMT " at_secure=%s)",
106+ log_debug("Will %s access (dumpable=%u uid="UID_FMT " euid="UID_FMT " gid="GID_FMT " egid="GID_FMT " at_secure=%s)",
107 ret ? "permit" : "restrict",
108+ context->dumpable,
109 uid, euid, gid, egid, yes_no(at_secure));
110 return ret;
111 }
112@@ -1102,6 +1107,16 @@ static int save_context(Context *context, const struct iovec_wrapper *iovw) {
113 if (r < 0)
114 return log_error_errno(r, "Failed to parse PID \"%s\": %m", context->meta[META_ARGV_PID]);
115
116+ /* The value is set to contents of /proc/sys/fs/suid_dumpable, which we set to 2,
117+ * if the process is marked as not dumpable, see PR_SET_DUMPABLE(2const). */
118+ if (context->meta[META_ARGV_DUMPABLE]) {
119+ r = safe_atou(context->meta[META_ARGV_DUMPABLE], &context->dumpable);
120+ if (r < 0)
121+ return log_error_errno(r, "Failed to parse dumpable field \"%s\": %m", context->meta[META_ARGV_DUMPABLE]);
122+ if (context->dumpable > 2)
123+ log_notice("Got unexpected %%d/dumpable value %u.", context->dumpable);
124+ }
125+
126 unit = context->meta[META_UNIT];
127 context->is_pid1 = streq(context->meta[META_ARGV_PID], "1") || streq_ptr(unit, SPECIAL_INIT_SCOPE);
128 context->is_journald = streq_ptr(unit, SPECIAL_JOURNALD_SERVICE);
129diff --git a/sysctl.d/50-coredump.conf.in b/sysctl.d/50-coredump.conf.in
130index 5fb551a8cf..9c10a89828 100644
131--- a/sysctl.d/50-coredump.conf.in
132+++ b/sysctl.d/50-coredump.conf.in
133@@ -13,7 +13,7 @@
134 # the core dump.
135 #
136 # See systemd-coredump(8) and core(5).
137-kernel.core_pattern=|{{ROOTLIBEXECDIR}}/systemd-coredump %P %u %g %s %t %c %h
138+kernel.core_pattern=|{{ROOTLIBEXECDIR}}/systemd-coredump %P %u %g %s %t %c %h %d
139
140 # Allow 16 coredumps to be dispatched in parallel by the kernel.
141 # We collect metadata from /proc/%P/, and thus need to make sure the crashed
142--
1432.34.1
144
diff --git a/meta/recipes-core/systemd/systemd/CVE-2025-4598-0004.patch b/meta/recipes-core/systemd/systemd/CVE-2025-4598-0004.patch
new file mode 100644
index 0000000000..a3aed25e27
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/CVE-2025-4598-0004.patch
@@ -0,0 +1,36 @@
1From a0c698c720441782fcf2cb7dfd01e69baf8f1f39 Mon Sep 17 00:00:00 2001
2From: Dan Streetman <ddstreet@ieee.org>
3Date: Thu, 2 Feb 2023 15:58:10 -0500
4Subject: [PATCH] basic/macro: add macro to iterate variadic args
5
6(cherry picked from commit e179f2d89c9f0c951636d74de00136b4075cd1ac)
7(cherry picked from commit cd4f43bf378ff33ce5cfeacd96f7f3726603bddc)
8
9Upstream-Status: Backport [https://github.com/systemd/systemd-stable/commit/c288a3aafdf11cd93eb7a21e4d587c6fc218a29c]
10
11Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
12---
13 src/basic/macro.h | 9 +++++++++
14 1 file changed, 9 insertions(+)
15
16diff --git a/src/basic/macro.h b/src/basic/macro.h
17index 9e62f9c71c..16242902ec 100644
18--- a/src/basic/macro.h
19+++ b/src/basic/macro.h
20@@ -454,4 +454,13 @@ typedef struct {
21
22 assert_cc(sizeof(dummy_t) == 0);
23
24+/* Iterate through each variadic arg. All must be the same type as 'entry' or must be implicitly
25+ * convertable. The iteration variable 'entry' must already be defined. */
26+#define VA_ARGS_FOREACH(entry, ...) \
27+ _VA_ARGS_FOREACH(entry, UNIQ_T(_entries_, UNIQ), UNIQ_T(_current_, UNIQ), ##__VA_ARGS__)
28+#define _VA_ARGS_FOREACH(entry, _entries_, _current_, ...) \
29+ for (typeof(entry) _entries_[] = { __VA_ARGS__ }, *_current_ = _entries_; \
30+ ((long)(_current_ - _entries_) < (long)ELEMENTSOF(_entries_)) && ({ entry = *_current_; true; }); \
31+ _current_++)
32+
33 #include "log.h"
34--
352.34.1
36
diff --git a/meta/recipes-core/systemd/systemd_250.14.bb b/meta/recipes-core/systemd/systemd_250.14.bb
index b3e31e1f23..66d20a46fd 100644
--- a/meta/recipes-core/systemd/systemd_250.14.bb
+++ b/meta/recipes-core/systemd/systemd_250.14.bb
@@ -31,6 +31,10 @@ SRC_URI += "file://touchscreen.rules \
31 file://0001-core-fix-build-when-seccomp-is-off.patch \ 31 file://0001-core-fix-build-when-seccomp-is-off.patch \
32 file://0001-journal-Make-sd_journal_previous-next-return-0-at-HE.patch \ 32 file://0001-journal-Make-sd_journal_previous-next-return-0-at-HE.patch \
33 file://0001-basic-do-not-warn-in-mkdir_p-when-parent-directory-e.patch \ 33 file://0001-basic-do-not-warn-in-mkdir_p-when-parent-directory-e.patch \
34 file://CVE-2025-4598-0001.patch \
35 file://CVE-2025-4598-0002.patch \
36 file://CVE-2025-4598-0003.patch \
37 file://CVE-2025-4598-0004.patch \
34 " 38 "
35 39
36# patches needed by musl 40# patches needed by musl