public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 -next] cgroup: update some statememt about delegation
@ 2024-08-15 13:14 Chen Ridong
  2024-08-19 22:16 ` Tejun Heo
  2024-08-21 16:35 ` Michal Koutný
  0 siblings, 2 replies; 3+ messages in thread
From: Chen Ridong @ 2024-08-15 13:14 UTC (permalink / raw)
  To: tj, lizefan.x, hannes, longman, mkoutny; +Cc: cgroups, linux-kernel

The comment in cgroup_file_write is missing some interfaces, such as
'cgroup.threads'. All delegatable files are listed in
'/sys/kernel/cgroup/delegate', so update the comment in cgroup_file_write.
Besides, add a statement that files outside the namespace shouldn't be
visible from inside the delegated namespace.

Signed-off-by: Chen Ridong <chenridong@huawei.com>
---
 Documentation/admin-guide/cgroup-v2.rst | 10 ++++++----
 kernel/cgroup/cgroup.c                  |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index f2d1ec7d6aba..3618168de371 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -533,10 +533,12 @@ cgroup namespace on namespace creation.
 Because the resource control interface files in a given directory
 control the distribution of the parent's resources, the delegatee
 shouldn't be allowed to write to them.  For the first method, this is
-achieved by not granting access to these files.  For the second, the
-kernel rejects writes to all files other than "cgroup.procs" and
-"cgroup.subtree_control" on a namespace root from inside the
-namespace.
+achieved by not granting access to these files.  For the second, files
+outside the namespace should be hidden from the delegatee by the means
+of at least mount namespacing, and the kernel rejects writes to all files
+on a namespace root from inside the cgroup namespace, except for those
+files listed in "/sys/kernel/cgroup/delegate" (including "cgroup.procs",
+"cgroup.threads", "cgroup.subtree_control", etc.).
 
 The end results are equivalent for both delegation types.  Once
 delegated, the user can build sub-hierarchy under the directory,
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index a3fa645f8433..16b9749e131e 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -4131,7 +4131,7 @@ static ssize_t cgroup_file_write(struct kernfs_open_file *of, char *buf,
 	 * If namespaces are delegation boundaries, disallow writes to
 	 * files in an non-init namespace root from inside the namespace
 	 * except for the files explicitly marked delegatable -
-	 * cgroup.procs and cgroup.subtree_control.
+	 * eg. cgroup.procs, cgroup.threads and cgroup.subtree_control.
 	 */
 	if ((cgrp->root->flags & CGRP_ROOT_NS_DELEGATE) &&
 	    !(cft->flags & CFTYPE_NS_DELEGATABLE) &&
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 -next] cgroup: update some statememt about delegation
  2024-08-15 13:14 [PATCH v2 -next] cgroup: update some statememt about delegation Chen Ridong
@ 2024-08-19 22:16 ` Tejun Heo
  2024-08-21 16:35 ` Michal Koutný
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2024-08-19 22:16 UTC (permalink / raw)
  To: Chen Ridong; +Cc: lizefan.x, hannes, longman, mkoutny, cgroups, linux-kernel

On Thu, Aug 15, 2024 at 01:14:08PM +0000, Chen Ridong wrote:
> The comment in cgroup_file_write is missing some interfaces, such as
> 'cgroup.threads'. All delegatable files are listed in
> '/sys/kernel/cgroup/delegate', so update the comment in cgroup_file_write.
> Besides, add a statement that files outside the namespace shouldn't be
> visible from inside the delegated namespace.
> 
> Signed-off-by: Chen Ridong <chenridong@huawei.com>

Applied to cgroup/for-6.12 w/ text reflowed for consistency.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 -next] cgroup: update some statememt about delegation
  2024-08-15 13:14 [PATCH v2 -next] cgroup: update some statememt about delegation Chen Ridong
  2024-08-19 22:16 ` Tejun Heo
@ 2024-08-21 16:35 ` Michal Koutný
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Koutný @ 2024-08-21 16:35 UTC (permalink / raw)
  To: Chen Ridong; +Cc: tj, lizefan.x, hannes, longman, cgroups, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

On Thu, Aug 15, 2024 at 01:14:08PM GMT, Chen Ridong <chenridong@huawei.com> wrote:
> The comment in cgroup_file_write is missing some interfaces, such as
> 'cgroup.threads'. All delegatable files are listed in
> '/sys/kernel/cgroup/delegate', so update the comment in cgroup_file_write.
> Besides, add a statement that files outside the namespace shouldn't be
> visible from inside the delegated namespace.
> 
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
>  Documentation/admin-guide/cgroup-v2.rst | 10 ++++++----
>  kernel/cgroup/cgroup.c                  |  2 +-
>  2 files changed, 7 insertions(+), 5 deletions(-)

Acked-by: Michal Koutný <mkoutny@suse.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-21 16:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-15 13:14 [PATCH v2 -next] cgroup: update some statememt about delegation Chen Ridong
2024-08-19 22:16 ` Tejun Heo
2024-08-21 16:35 ` Michal Koutný

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox