Skip to content

Commit 06c5757

Browse files
authored
systemd: add patches for ipc issue (#16098)
Fixes issue relating to dbus-based ipc communication
1 parent 90d2ba6 commit 06c5757

6 files changed

+400
-2
lines changed

SPECS-SIGNED/systemd-boot-signed/systemd-boot-signed.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Version: 255
2020
# determine the build information from local checkout
2121
Version: %(tools/meson-vcs-tag.sh . error | sed -r 's/-([0-9])/.^\1/; s/-g/_g/')
2222
%endif
23-
Release: 25%{?dist}
23+
Release: 26%{?dist}
2424
License: LGPL-2.1-or-later AND MIT AND GPL-2.0-or-later
2525
Vendor: Microsoft Corporation
2626
Distribution: Azure Linux
@@ -98,6 +98,9 @@ popd
9898
/boot/efi/EFI/BOOT/%{grubefiname}
9999

100100
%changelog
101+
* Tue Mar 03 2026 Dan Streetman <ddstreet@ieee.org> - 255-26
102+
- Bump release to match systemd spec
103+
101104
* Wed Nov 26 2025 Rohit Rawat <rohitrawat@microsoft.com> - 255-25
102105
- Bump release to match systemd spec
103106

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
From 0247730a13284be4bb1ccd16181b34ba94b2da04 Mon Sep 17 00:00:00 2001
2+
From: Lennart Poettering <lennart@poettering.net>
3+
Date: Mon, 19 May 2025 12:58:52 +0200
4+
Subject: [PATCH 1/4] path-util: add flavour of path_startswith() that leaves a
5+
leading slash in place
6+
7+
(cherry picked from commit ee19edbb9f3455db3f750089082f3e5a925e3a0c)
8+
(cherry picked from commit 20021e7686426052e3a7505425d7e12085feb2a6)
9+
---
10+
src/basic/fs-util.c | 2 +-
11+
src/basic/mkdir.c | 2 +-
12+
src/basic/path-util.c | 39 ++++++++++++++++++++++++++++-----------
13+
src/basic/path-util.h | 10 ++++++++--
14+
src/test/test-path-util.c | 16 ++++++++++++++++
15+
5 files changed, 54 insertions(+), 15 deletions(-)
16+
17+
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
18+
index ee38e0266a..cc89f48fb7 100644
19+
--- a/src/basic/fs-util.c
20+
+++ b/src/basic/fs-util.c
21+
@@ -65,7 +65,7 @@ int rmdir_parents(const char *path, const char *stop) {
22+
assert(*slash == '/');
23+
*slash = '\0';
24+
25+
- if (path_startswith_full(stop, p, /* accept_dot_dot= */ false))
26+
+ if (path_startswith_full(stop, p, /* flags= */ 0))
27+
return 0;
28+
29+
if (rmdir(p) < 0 && errno != ENOENT)
30+
diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
31+
index c770e5ed32..7bc73361a5 100644
32+
--- a/src/basic/mkdir.c
33+
+++ b/src/basic/mkdir.c
34+
@@ -155,7 +155,7 @@ int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, ui
35+
assert(_mkdirat != mkdirat);
36+
37+
if (prefix) {
38+
- p = path_startswith_full(path, prefix, /* accept_dot_dot= */ false);
39+
+ p = path_startswith_full(path, prefix, /* flags= */ 0);
40+
if (!p)
41+
return -ENOTDIR;
42+
} else
43+
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
44+
index 6810bf66aa..e73f5d708e 100644
45+
--- a/src/basic/path-util.c
46+
+++ b/src/basic/path-util.c
47+
@@ -403,8 +403,8 @@ char* path_simplify_full(char *path, PathSimplifyFlags flags) {
48+
return path;
49+
}
50+
51+
-char* path_startswith_full(const char *path, const char *prefix, bool accept_dot_dot) {
52+
- assert(path);
53+
+char* path_startswith_full(const char *original_path, const char *prefix, PathStartWithFlags flags) {
54+
+ assert(original_path);
55+
assert(prefix);
56+
57+
/* Returns a pointer to the start of the first component after the parts matched by
58+
@@ -417,28 +417,45 @@ char* path_startswith_full(const char *path, const char *prefix, bool accept_dot
59+
* Returns NULL otherwise.
60+
*/
61+
62+
+ const char *path = original_path;
63+
+
64+
if ((path[0] == '/') != (prefix[0] == '/'))
65+
return NULL;
66+
67+
for (;;) {
68+
const char *p, *q;
69+
- int r, k;
70+
+ int m, n;
71+
72+
- r = path_find_first_component(&path, accept_dot_dot, &p);
73+
- if (r < 0)
74+
+ m = path_find_first_component(&path, FLAGS_SET(flags, PATH_STARTSWITH_ACCEPT_DOT_DOT), &p);
75+
+ if (m < 0)
76+
return NULL;
77+
78+
- k = path_find_first_component(&prefix, accept_dot_dot, &q);
79+
- if (k < 0)
80+
+ n = path_find_first_component(&prefix, FLAGS_SET(flags, PATH_STARTSWITH_ACCEPT_DOT_DOT), &q);
81+
+ if (n < 0)
82+
return NULL;
83+
84+
- if (k == 0)
85+
- return (char*) (p ?: path);
86+
+ if (n == 0) {
87+
+ if (!p)
88+
+ p = path;
89+
+
90+
+ if (FLAGS_SET(flags, PATH_STARTSWITH_RETURN_LEADING_SLASH)) {
91+
+
92+
+ if (p <= original_path)
93+
+ return NULL;
94+
+
95+
+ p--;
96+
+
97+
+ if (*p != '/')
98+
+ return NULL;
99+
+ }
100+
+
101+
+ return (char*) p;
102+
+ }
103+
104+
- if (r != k)
105+
+ if (m != n)
106+
return NULL;
107+
108+
- if (!strneq(p, q, r))
109+
+ if (!strneq(p, q, m))
110+
return NULL;
111+
}
112+
}
113+
diff --git a/src/basic/path-util.h b/src/basic/path-util.h
114+
index 6d943e967f..e0ec05f4db 100644
115+
--- a/src/basic/path-util.h
116+
+++ b/src/basic/path-util.h
117+
@@ -53,9 +53,15 @@ int safe_getcwd(char **ret);
118+
int path_make_absolute_cwd(const char *p, char **ret);
119+
int path_make_relative(const char *from, const char *to, char **ret);
120+
int path_make_relative_parent(const char *from_child, const char *to, char **ret);
121+
-char* path_startswith_full(const char *path, const char *prefix, bool accept_dot_dot) _pure_;
122+
+
123+
+typedef enum PathStartWithFlags {
124+
+ PATH_STARTSWITH_ACCEPT_DOT_DOT = 1U << 0,
125+
+ PATH_STARTSWITH_RETURN_LEADING_SLASH = 1U << 1,
126+
+} PathStartWithFlags;
127+
+
128+
+char* path_startswith_full(const char *path, const char *prefix, PathStartWithFlags flags) _pure_;
129+
static inline char* path_startswith(const char *path, const char *prefix) {
130+
- return path_startswith_full(path, prefix, true);
131+
+ return path_startswith_full(path, prefix, PATH_STARTSWITH_ACCEPT_DOT_DOT);
132+
}
133+
134+
int path_compare(const char *a, const char *b) _pure_;
135+
diff --git a/src/test/test-path-util.c b/src/test/test-path-util.c
136+
index f5a425689a..5b164facc0 100644
137+
--- a/src/test/test-path-util.c
138+
+++ b/src/test/test-path-util.c
139+
@@ -754,6 +754,22 @@ TEST(path_startswith) {
140+
test_path_startswith_one("/foo/bar/barfoo/", "/fo", NULL, NULL);
141+
}
142+
143+
+static void test_path_startswith_return_leading_slash_one(const char *path, const char *prefix, const char *expected) {
144+
+ const char *p;
145+
+
146+
+ log_debug("/* %s(%s, %s) */", __func__, path, prefix);
147+
+
148+
+ p = path_startswith_full(path, prefix, PATH_STARTSWITH_RETURN_LEADING_SLASH);
149+
+ assert_se(streq(p, expected));
150+
+}
151+
+
152+
+TEST(path_startswith_return_leading_slash) {
153+
+ test_path_startswith_return_leading_slash_one("/foo/bar", "/", "/foo/bar");
154+
+ test_path_startswith_return_leading_slash_one("/foo/bar", "/foo", "/bar");
155+
+ test_path_startswith_return_leading_slash_one("/foo/bar", "/foo/bar", NULL);
156+
+ test_path_startswith_return_leading_slash_one("/foo/bar/", "/foo/bar", "/");
157+
+}
158+
+
159+
static void test_prefix_root_one(const char *r, const char *p, const char *expected) {
160+
_cleanup_free_ char *s = NULL;
161+
const char *t;
162+
--
163+
2.51.0
164+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
From 647d009c240dbeadf586e69b3c9121b6b6cb12d7 Mon Sep 17 00:00:00 2001
2+
From: Lennart Poettering <lennart@poettering.net>
3+
Date: Fri, 23 May 2025 06:45:40 +0200
4+
Subject: [PATCH 2/4] path-util: invert PATH_STARTSWITH_ACCEPT_DOT_DOT flag
5+
6+
As requested: https://github.com/systemd/systemd/pull/37572#pullrequestreview-2861928094
7+
8+
(cherry picked from commit ceed11e465f1c8efff1931412a85924d9de7c08d)
9+
(cherry picked from commit 7ac3220213690e8a8d6d2a6e81e43bd1dce01d69)
10+
---
11+
src/basic/fs-util.c | 2 +-
12+
src/basic/mkdir.c | 2 +-
13+
src/basic/path-util.c | 4 ++--
14+
src/basic/path-util.h | 4 ++--
15+
4 files changed, 6 insertions(+), 6 deletions(-)
16+
17+
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c
18+
index cc89f48fb7..f7c91680d8 100644
19+
--- a/src/basic/fs-util.c
20+
+++ b/src/basic/fs-util.c
21+
@@ -65,7 +65,7 @@ int rmdir_parents(const char *path, const char *stop) {
22+
assert(*slash == '/');
23+
*slash = '\0';
24+
25+
- if (path_startswith_full(stop, p, /* flags= */ 0))
26+
+ if (path_startswith_full(stop, p, PATH_STARTSWITH_REFUSE_DOT_DOT))
27+
return 0;
28+
29+
if (rmdir(p) < 0 && errno != ENOENT)
30+
diff --git a/src/basic/mkdir.c b/src/basic/mkdir.c
31+
index 7bc73361a5..8f14c47214 100644
32+
--- a/src/basic/mkdir.c
33+
+++ b/src/basic/mkdir.c
34+
@@ -155,7 +155,7 @@ int mkdir_parents_internal(const char *prefix, const char *path, mode_t mode, ui
35+
assert(_mkdirat != mkdirat);
36+
37+
if (prefix) {
38+
- p = path_startswith_full(path, prefix, /* flags= */ 0);
39+
+ p = path_startswith_full(path, prefix, PATH_STARTSWITH_REFUSE_DOT_DOT);
40+
if (!p)
41+
return -ENOTDIR;
42+
} else
43+
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
44+
index e73f5d708e..a65a5c32f6 100644
45+
--- a/src/basic/path-util.c
46+
+++ b/src/basic/path-util.c
47+
@@ -426,11 +426,11 @@ char* path_startswith_full(const char *original_path, const char *prefix, PathSt
48+
const char *p, *q;
49+
int m, n;
50+
51+
- m = path_find_first_component(&path, FLAGS_SET(flags, PATH_STARTSWITH_ACCEPT_DOT_DOT), &p);
52+
+ m = path_find_first_component(&path, !FLAGS_SET(flags, PATH_STARTSWITH_REFUSE_DOT_DOT), &p);
53+
if (m < 0)
54+
return NULL;
55+
56+
- n = path_find_first_component(&prefix, FLAGS_SET(flags, PATH_STARTSWITH_ACCEPT_DOT_DOT), &q);
57+
+ n = path_find_first_component(&prefix, !FLAGS_SET(flags, PATH_STARTSWITH_REFUSE_DOT_DOT), &q);
58+
if (n < 0)
59+
return NULL;
60+
61+
diff --git a/src/basic/path-util.h b/src/basic/path-util.h
62+
index e0ec05f4db..11a1078df9 100644
63+
--- a/src/basic/path-util.h
64+
+++ b/src/basic/path-util.h
65+
@@ -55,13 +55,13 @@ int path_make_relative(const char *from, const char *to, char **ret);
66+
int path_make_relative_parent(const char *from_child, const char *to, char **ret);
67+
68+
typedef enum PathStartWithFlags {
69+
- PATH_STARTSWITH_ACCEPT_DOT_DOT = 1U << 0,
70+
+ PATH_STARTSWITH_REFUSE_DOT_DOT = 1U << 0,
71+
PATH_STARTSWITH_RETURN_LEADING_SLASH = 1U << 1,
72+
} PathStartWithFlags;
73+
74+
char* path_startswith_full(const char *path, const char *prefix, PathStartWithFlags flags) _pure_;
75+
static inline char* path_startswith(const char *path, const char *prefix) {
76+
- return path_startswith_full(path, prefix, PATH_STARTSWITH_ACCEPT_DOT_DOT);
77+
+ return path_startswith_full(path, prefix, 0);
78+
}
79+
80+
int path_compare(const char *a, const char *b) _pure_;
81+
--
82+
2.51.0
83+
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
From 2e169664aff3236331d1cb7063d5241dc68b7461 Mon Sep 17 00:00:00 2001
2+
From: Mike Yuan <me@yhndnzj.com>
3+
Date: Thu, 26 Feb 2026 11:06:00 +0100
4+
Subject: [PATCH 3/4] core/cgroup: avoid one unnecessary strjoina()
5+
6+
(cherry picked from commit 42aee39107fbdd7db1ccd402a2151822b2805e9f)
7+
(cherry picked from commit 80acea4ef80a4bb78560ed970c34952299b890d6)
8+
(cherry picked from commit b5fd14693057e5f2c9b4a49603be64ec3608ff6c)
9+
(cherry picked from commit 21167006574d6b83813c7596759b474f56562412)
10+
---
11+
src/core/cgroup.c | 29 ++++++++++++++---------------
12+
1 file changed, 14 insertions(+), 15 deletions(-)
13+
14+
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
15+
index 61ac4df1a6..1fedc6e72f 100644
16+
--- a/src/core/cgroup.c
17+
+++ b/src/core/cgroup.c
18+
@@ -2565,12 +2565,13 @@ static int unit_update_cgroup(
19+
return 0;
20+
}
21+
22+
-static int unit_attach_pid_to_cgroup_via_bus(Unit *u, pid_t pid, const char *suffix_path) {
23+
+static int unit_attach_pid_to_cgroup_via_bus(Unit *u, const char *cgroup_path, pid_t pid) {
24+
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
25+
- char *pp;
26+
int r;
27+
28+
assert(u);
29+
+ assert(cgroup_path);
30+
+ assert(pid_is_valid(pid));
31+
32+
if (MANAGER_IS_SYSTEM(u->manager))
33+
return -EINVAL;
34+
@@ -2578,17 +2579,13 @@ static int unit_attach_pid_to_cgroup_via_bus(Unit *u, pid_t pid, const char *suf
35+
if (!u->manager->system_bus)
36+
return -EIO;
37+
38+
- if (!u->cgroup_path)
39+
- return -EINVAL;
40+
-
41+
/* Determine this unit's cgroup path relative to our cgroup root */
42+
- pp = path_startswith(u->cgroup_path, u->manager->cgroup_root);
43+
+ const char *pp = path_startswith_full(cgroup_path,
44+
+ u->manager->cgroup_root,
45+
+ PATH_STARTSWITH_RETURN_LEADING_SLASH|PATH_STARTSWITH_REFUSE_DOT_DOT);
46+
if (!pp)
47+
return -EINVAL;
48+
49+
- pp = strjoina("/", pp, suffix_path);
50+
- path_simplify(pp);
51+
-
52+
r = bus_call_method(u->manager->system_bus,
53+
bus_systemd_mgr,
54+
"AttachProcessesToUnit",
55+
@@ -2627,8 +2624,10 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) {
56+
return r;
57+
58+
if (isempty(suffix_path))
59+
- p = u->cgroup_path;
60+
+ p = empty_to_root(u->cgroup_path);
61+
else {
62+
+ assert(path_is_absolute(suffix_path));
63+
+
64+
joined = path_join(u->cgroup_path, suffix_path);
65+
if (!joined)
66+
return -ENOMEM;
67+
@@ -2646,7 +2645,7 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) {
68+
* before we use it */
69+
r = pidref_verify(pid);
70+
if (r < 0) {
71+
- log_unit_info_errno(u, r, "PID " PID_FMT " vanished before we could move it to target cgroup '%s', skipping: %m", pid->pid, empty_to_root(p));
72+
+ log_unit_info_errno(u, r, "PID " PID_FMT " vanished before we could move it to target cgroup '%s', skipping: %m", pid->pid, p);
73+
continue;
74+
}
75+
76+
@@ -2657,7 +2656,7 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) {
77+
78+
log_unit_full_errno(u, again ? LOG_DEBUG : LOG_INFO, r,
79+
"Couldn't move process "PID_FMT" to%s requested cgroup '%s': %m",
80+
- pid->pid, again ? " directly" : "", empty_to_root(p));
81+
+ pid->pid, again ? " directly" : "", p);
82+
83+
if (again) {
84+
int z;
85+
@@ -2667,9 +2666,9 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) {
86+
* Since it's more privileged it might be able to move the process across the
87+
* leaves of a subtree whose top node is not owned by us. */
88+
89+
- z = unit_attach_pid_to_cgroup_via_bus(u, pid->pid, suffix_path);
90+
+ z = unit_attach_pid_to_cgroup_via_bus(u, p, pid->pid);
91+
if (z < 0)
92+
- log_unit_info_errno(u, z, "Couldn't move process "PID_FMT" to requested cgroup '%s' (directly or via the system bus): %m", pid->pid, empty_to_root(p));
93+
+ log_unit_info_errno(u, z, "Couldn't move process "PID_FMT" to requested cgroup '%s' (directly or via the system bus): %m", pid->pid, p);
94+
else {
95+
if (ret >= 0)
96+
ret++; /* Count successful additions */
97+
@@ -2707,7 +2706,7 @@ int unit_attach_pids_to_cgroup(Unit *u, Set *pids, const char *suffix_path) {
98+
continue; /* Success! */
99+
100+
log_unit_debug_errno(u, r, "Failed to attach PID " PID_FMT " to requested cgroup %s in controller %s, falling back to unit's cgroup: %m",
101+
- pid->pid, empty_to_root(p), cgroup_controller_to_string(c));
102+
+ pid->pid, p, cgroup_controller_to_string(c));
103+
}
104+
105+
/* So this controller is either not delegate or realized, or something else weird happened. In
106+
--
107+
2.51.0
108+

0 commit comments

Comments
 (0)