systemd: backport patches to fix CVE-2025-4598
PATCH v2 1/1 systemd: backport patches to fix CVE-2025-4598
From: Chen Qi <[email protected]>
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.
Signed-off-by Chen Qi <[email protected]>
--- .../systemd/systemd/CVE-2025-4598-0001.patch | 92 +++++++++++ .../systemd/systemd/CVE-2025-4598-0002.patch | 106 +++++++++++++ .../systemd/systemd/CVE-2025-4598-0003.patch | 144 ++++++++++++++++++ .../systemd/systemd/CVE-2025-4598-0004.patch | 36 +++++ meta/recipes-core/systemd/systemd_250.14.bb | 4 + 5 files changed, 382 insertions(+) create mode 100644 meta/recipes-core/systemd/systemd/CVE-2025-4598-0001.patch create mode 100644 meta/recipes-core/systemd/systemd/CVE-2025-4598-0002.patch create mode 100644 meta/recipes-core/systemd/systemd/CVE-2025-4598-0003.patch create mode 100644 meta/recipes-core/systemd/systemd/CVE-2025-4598-0004.patch
meta/recipes-core/systemd/systemd/CVE-2025-4598-0001.patch new file +92 -0
@@ -0,0 +1,92 @@ +From 2108812a76bd078a2bbd7583308ff18bf01f2383 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <[email protected]> +Date: Tue, 29 Apr 2025 14:47:59 +0200 +Subject: [PATCH 1/3] coredump: restore compatibility with older patterns + +This was broken in f45b8015513d38ee5f7cc361db9c5b88c9aae704. Unfortunately +the review does not talk about backward compatibility at all. There are +two places where it matters: +- During upgrades, the replacement of kernel.core_pattern is asynchronous. + For example, during rpm upgrades, it would be updated a post-transaction + file trigger. In other scenarios, the update might only happen after + reboot. We have a potentially long window where the old pattern is in + place. We need to capture coredumps during upgrades too. +- With --backtrace. The interface of --backtrace, in hindsight, is not + great. But there are users of --backtrace which were written to use + a specific set of arguments, and we can't just break compatiblity. + One example is systemd-coredump-python, but there are also reports of + users using --backtrace to generate coredump logs. + +Thus, we require the original set of args, and will use the additional args if +found. + +A test is added to verify that --backtrace works with and without the optional +args. + +(cherry picked from commit ded0aac389e647d35bce7ec4a48e718d77c0435b) +(cherry picked from commit f9b8b75c11bba9b63096904be98cc529c304eb97) +(cherry picked from commit 385a33b043406ad79a7207f3906c3b15192a3333) +(cherry picked from commit c6f79626b6d175c6a5b62b8c5d957a83eb882301) +(cherry picked from commit 9f02346d50e33c24acf879ce4dd5937d56473325) +(cherry picked from commit ac0aa5d1fdc21db1ef035fce562cb6fc8602b544) + +Upstream-Status: Backport [https://github.com/systemd/systemd-stable/commit/cadd1b1a1f39fd13b1115a10f563017201d7b56a] + +Signed-off-by: Chen Qi <[email protected]> +--- + src/coredump/coredump.c | 21 ++++++++++++++------- + 1 file changed, 14 insertions(+), 7 deletions(-) + +diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c +index 79280ab986..d598f6f59a 100644 +--- a/src/coredump/coredump.c ++++ b/src/coredump/coredump.c +@@ -84,8 +84,12 @@ enum { + META_ARGV_SIGNAL, /* %s: number of signal causing dump */ + META_ARGV_TIMESTAMP, /* %t: time of dump, expressed as seconds since the Epoch (we expand this to µs granularity) */ + META_ARGV_RLIMIT, /* %c: core file size soft resource limit */ +- META_ARGV_HOSTNAME, /* %h: hostname */ ++ _META_ARGV_REQUIRED, ++ /* The fields below were added to kernel/core_pattern at later points, so they might be missing. */ ++ META_ARGV_HOSTNAME = _META_ARGV_REQUIRED, /* %h: hostname */ + _META_ARGV_MAX, ++ /* If new fields are added, they should be added here, to maintain compatibility ++ * with callers which don't know about the new fields. */ + + /* The following indexes are cached for a couple of special fields we use (and + * thereby need to be retrieved quickly) for naming coredump files, and attaching +@@ -96,7 +100,7 @@ enum { + _META_MANDATORY_MAX, + + /* The rest are similar to the previous ones except that we won't fail if one of +- * them is missing. */ ++ * them is missing in a message sent over the socket. */ + + META_EXE = _META_MANDATORY_MAX, + META_UNIT, +@@ -1278,14 +1282,17 @@ static int gather_pid_metadata_from_argv( + char *t; + + /* We gather all metadata that were passed via argv[] into an array of iovecs that +- * we'll forward to the socket unit */ ++ * we'll forward to the socket unit. ++ * ++ * We require at least _META_ARGV_REQUIRED args, but will accept more. ++ * We know how to parse _META_ARGV_MAX args. The rest will be ignored. */ + +- if (argc < _META_ARGV_MAX) ++ if (argc < _META_ARGV_REQUIRED) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), +- "Not enough arguments passed by the kernel (%i, expected %i).", +- argc, _META_ARGV_MAX); ++ "Not enough arguments passed by the kernel (%i, expected between %i and %i).", ++ argc, _META_ARGV_REQUIRED, _META_ARGV_MAX); + +- for (int i = 0; i < _META_ARGV_MAX; i++) { ++ for (int i = 0; i < MIN(argc, _META_ARGV_MAX); i++) { + + t = argv[i]; + +-- +2.34.1 +
meta/recipes-core/systemd/systemd/CVE-2025-4598-0002.patch new file +106 -0
106 lines not on this page · raw message
meta/recipes-core/systemd/systemd/CVE-2025-4598-0003.patch new file +144 -0
144 lines not on this page · raw message
meta/recipes-core/systemd/systemd/CVE-2025-4598-0004.patch new file +36 -0
@@ -0,0 +1,36 @@ +From a0c698c720441782fcf2cb7dfd01e69baf8f1f39 Mon Sep 17 00:00:00 2001 +From: Dan Streetman <[email protected]> +Date: Thu, 2 Feb 2023 15:58:10 -0500 +Subject: [PATCH] basic/macro: add macro to iterate variadic args + +(cherry picked from commit e179f2d89c9f0c951636d74de00136b4075cd1ac) +(cherry picked from commit cd4f43bf378ff33ce5cfeacd96f7f3726603bddc) + +Upstream-Status: Backport [https://github.com/systemd/systemd-stable/commit/c288a3aafdf11cd93eb7a21e4d587c6fc218a29c] + +Signed-off-by: Chen Qi <[email protected]> +--- + src/basic/macro.h | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/src/basic/macro.h b/src/basic/macro.h +index 9e62f9c71c..16242902ec 100644 +--- a/src/basic/macro.h ++++ b/src/basic/macro.h +@@ -454,4 +454,13 @@ typedef struct { + + assert_cc(sizeof(dummy_t) == 0); + ++/* Iterate through each variadic arg. All must be the same type as 'entry' or must be implicitly ++ * convertable. The iteration variable 'entry' must already be defined. */ ++#define VA_ARGS_FOREACH(entry, ...) \ ++ _VA_ARGS_FOREACH(entry, UNIQ_T(_entries_, UNIQ), UNIQ_T(_current_, UNIQ), ##__VA_ARGS__) ++#define _VA_ARGS_FOREACH(entry, _entries_, _current_, ...) \ ++ for (typeof(entry) _entries_[] = { __VA_ARGS__ }, *_current_ = _entries_; \ ++ ((long)(_current_ - _entries_) < (long)ELEMENTSOF(_entries_)) && ({ entry = *_current_; true; }); \ ++ _current_++) ++ + #include "log.h" +-- +2.34.1 +
meta/recipes-core/systemd/systemd_250.14.bb +4 -0
@@ -31,6 +31,10 @@ SRC_URI += "file://touchscreen.rules \ file://0001-core-fix-build-when-seccomp-is-off.patch \ file://0001-journal-Make-sd_journal_previous-next-return-0-at-HE.patch \ file://0001-basic-do-not-warn-in-mkdir_p-when-parent-directory-e.patch \ + file://CVE-2025-4598-0001.patch \ + file://CVE-2025-4598-0002.patch \ + file://CVE-2025-4598-0003.patch \ + file://CVE-2025-4598-0004.patch \ " # patches needed by musl
Signature · 1 line
2.34.1