summaryrefslogtreecommitdiffstats
path: root/src/core/cgroup.c
diff options
context:
space:
mode:
authorMichal Koutný <mkoutny@suse.com>2021-01-26 19:15:45 +0100
committerMichal Koutný <mkoutny@suse.com>2021-02-11 16:58:34 +0100
commit0fa7b50053695a3012af71c719dd86c12ab10fc6 (patch)
tree827b7be95414024a3e18f8d5fd523025a22f80de /src/core/cgroup.c
parentcgroup: Simplify cg_get_path_and_check (diff)
downloadsystemd-0fa7b50053695a3012af71c719dd86c12ab10fc6.tar.xz
systemd-0fa7b50053695a3012af71c719dd86c12ab10fc6.zip
core: Make (user) instance aware of delegated cgroup controllers
systemd user instance assumed same controllers are available to it as to PID 1. That is not true generally, in v1 (legacy, hybrid) we don't delegate any controllers to anyone and in v2 (unified) we may delegate only subset of controllers. The user instance would fail silently when the controller cgroup cannot be created or the controller cannot be enabled on the unified hierarchy. The changes in 7b63961415 ("cgroup: Swap cgroup v1 deletion and migration") caused some attempts of operating on non-delegated controllers to be logged. Make the user instance first check what controllers are availble to it and narrow operations only to these controllers. The original checks are kept in place. Note that daemon-reexec needs to be invoked in order to update the set of unabled controllers after a change. Fixes: #18047 Fixes: #17862
Diffstat (limited to 'src/core/cgroup.c')
-rw-r--r--src/core/cgroup.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index c9cf7fb16c..a0d188e1c4 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -3110,7 +3110,7 @@ int manager_setup_cgroup(Manager *m) {
(void) cg_set_attribute("memory", "/", "memory.use_hierarchy", "1");
/* 8. Figure out which controllers are supported */
- r = cg_mask_supported(&m->cgroup_supported);
+ r = cg_mask_supported_subtree(m->cgroup_root, &m->cgroup_supported);
if (r < 0)
return log_error_errno(r, "Failed to determine supported controllers: %m");