diff options
author | Michal Koutný <mkoutny@suse.com> | 2022-08-26 18:52:35 +0200 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2022-08-26 22:56:26 +0200 |
commit | 74e4b956eb1cac0e4c10c240339b1bbfbc9a4c48 (patch) | |
tree | 5080c9578e6b6d0fc873dff2fa38f8f5fff3f445 /kernel/cgroup/cgroup.c | |
parent | cgroup: Replace cgroup->ancestor_ids[] with ->ancestors[] (diff) | |
download | linux-74e4b956eb1cac0e4c10c240339b1bbfbc9a4c48.tar.xz linux-74e4b956eb1cac0e4c10c240339b1bbfbc9a4c48.zip |
cgroup: Honor caller's cgroup NS when resolving path
cgroup_get_from_path() is not widely used function. Its callers presume
the path is resolved under cgroup namespace. (There is one caller
currently and resolving in init NS won't make harm (netfilter). However,
future users may be subject to different effects when resolving
globally.)
Since, there's currently no use for the global resolution, modify the
existing function to take cgroup NS into account.
Fixes: a79a908fd2b0 ("cgroup: introduce cgroup namespaces")
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup/cgroup.c')
-rw-r--r-- | kernel/cgroup/cgroup.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 627ff0f07da7..1c7ab4109251 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -6602,8 +6602,12 @@ struct cgroup *cgroup_get_from_path(const char *path) { struct kernfs_node *kn; struct cgroup *cgrp = ERR_PTR(-ENOENT); + struct cgroup *root_cgrp; - kn = kernfs_walk_and_get(cgrp_dfl_root.cgrp.kn, path); + spin_lock_irq(&css_set_lock); + root_cgrp = current_cgns_cgroup_from_root(&cgrp_dfl_root); + kn = kernfs_walk_and_get(root_cgrp->kn, path); + spin_unlock_irq(&css_set_lock); if (!kn) goto out; |