|
Michal Koutný |
e9ed91 |
From: =?utf-8?b?TWljaGFsIEtvdXRuw70gPG1rb3V0bnlAc3VzZS5jb20+?=
|
|
Michal Koutný |
e9ed91 |
Date: Fri, 26 Aug 2022 18:52:35 +0200
|
|
Michal Koutný |
e9ed91 |
Subject: cgroup: Honor caller's cgroup NS when resolving path
|
|
Michal Koutný |
e9ed91 |
MIME-Version: 1.0
|
|
Michal Koutný |
e9ed91 |
Content-Type: text/plain; charset=UTF-8
|
|
Michal Koutný |
e9ed91 |
Content-Transfer-Encoding: 8bit
|
|
Michal Koutný |
e9ed91 |
Git-commit: 74e4b956eb1cac0e4c10c240339b1bbfbc9a4c48
|
|
Michal Koutný |
e9ed91 |
Patch-mainline: v6.1-rc1
|
|
Michal Koutný |
e9ed91 |
References: bsc#1205650
|
|
Michal Koutný |
e9ed91 |
|
|
Michal Koutný |
e9ed91 |
cgroup_get_from_path() is not widely used function. Its callers presume
|
|
Michal Koutný |
e9ed91 |
the path is resolved under cgroup namespace. (There is one caller
|
|
Michal Koutný |
e9ed91 |
currently and resolving in init NS won't make harm (netfilter). However,
|
|
Michal Koutný |
e9ed91 |
future users may be subject to different effects when resolving
|
|
Michal Koutný |
e9ed91 |
globally.)
|
|
Michal Koutný |
e9ed91 |
Since, there's currently no use for the global resolution, modify the
|
|
Michal Koutný |
e9ed91 |
existing function to take cgroup NS into account.
|
|
Michal Koutný |
e9ed91 |
|
|
Michal Koutný |
e9ed91 |
Fixes: a79a908fd2b0 ("cgroup: introduce cgroup namespaces")
|
|
Michal Koutný |
e9ed91 |
Signed-off-by: Michal Koutný <mkoutny@suse.com>
|
|
Michal Koutný |
e9ed91 |
Signed-off-by: Tejun Heo <tj@kernel.org>
|
|
Michal Koutný |
e9ed91 |
---
|
|
Michal Koutný |
e9ed91 |
kernel/cgroup/cgroup.c | 6 +++++-
|
|
Michal Koutný |
e9ed91 |
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
Michal Koutný |
e9ed91 |
|
|
Michal Koutný |
e9ed91 |
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
|
|
Michal Koutný |
e9ed91 |
index 627ff0f07da7..1c7ab4109251 100644
|
|
Michal Koutný |
e9ed91 |
--- a/kernel/cgroup/cgroup.c
|
|
Michal Koutný |
e9ed91 |
+++ b/kernel/cgroup/cgroup.c
|
|
Michal Koutný |
e9ed91 |
@@ -6602,8 +6602,12 @@ struct cgroup *cgroup_get_from_path(const char *path)
|
|
Michal Koutný |
e9ed91 |
{
|
|
Michal Koutný |
e9ed91 |
struct kernfs_node *kn;
|
|
Michal Koutný |
e9ed91 |
struct cgroup *cgrp = ERR_PTR(-ENOENT);
|
|
Michal Koutný |
e9ed91 |
+ struct cgroup *root_cgrp;
|
|
Michal Koutný |
e9ed91 |
|
|
Michal Koutný |
e9ed91 |
- kn = kernfs_walk_and_get(cgrp_dfl_root.cgrp.kn, path);
|
|
Michal Koutný |
e9ed91 |
+ spin_lock_irq(&css_set_lock);
|
|
Michal Koutný |
e9ed91 |
+ root_cgrp = current_cgns_cgroup_from_root(&cgrp_dfl_root);
|
|
Michal Koutný |
e9ed91 |
+ kn = kernfs_walk_and_get(root_cgrp->kn, path);
|
|
Michal Koutný |
e9ed91 |
+ spin_unlock_irq(&css_set_lock);
|
|
Michal Koutný |
e9ed91 |
if (!kn)
|
|
Michal Koutný |
e9ed91 |
goto out;
|
|
Michal Koutný |
e9ed91 |
|
|
Michal Koutný |
e9ed91 |
|