All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] cgroup-v1: Grant CAP_SYS_NICE holders permission to move tasks between cgroups
@ 2021-06-17  9:09 ` Lee Jones
  0 siblings, 0 replies; 15+ messages in thread
From: Lee Jones @ 2021-06-17  9:09 UTC (permalink / raw)
  To: lee.jones; +Cc: linux-kernel, Tejun Heo, Zefan Li, Johannes Weiner, cgroups

It should be possible for processes with CAP_SYS_NICE capabilities
(privileges) to move lower priority tasks within the same namespace to
different cgroups.

One extremely common example of this is Android's 'system_server',
which moves processes around to different cgroups/cpusets, but should
not require any other root privileges.

Cc: Tejun Heo <tj@kernel.org>
Cc: Zefan Li <lizefan.x@bytedance.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: cgroups@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 kernel/cgroup/cgroup-v1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index 1f274d7fc934e..56d0d91951f02 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -510,7 +510,8 @@ static ssize_t __cgroup1_procs_write(struct kernfs_open_file *of,
 	tcred = get_task_cred(task);
 	if (!uid_eq(cred->euid, GLOBAL_ROOT_UID) &&
 	    !uid_eq(cred->euid, tcred->uid) &&
-	    !uid_eq(cred->euid, tcred->suid))
+	    !uid_eq(cred->euid, tcred->suid) &&
+	    !ns_capable(tcred->user_ns, CAP_SYS_NICE))
 		ret = -EACCES;
 	put_cred(tcred);
 	if (ret)
-- 
2.32.0


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

end of thread, other threads:[~2021-10-04 17:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17  9:09 [PATCH 1/1] cgroup-v1: Grant CAP_SYS_NICE holders permission to move tasks between cgroups Lee Jones
2021-06-17  9:09 ` Lee Jones
2021-06-17 11:41 ` Tejun Heo
2021-06-17 11:41   ` Tejun Heo
2021-06-17 12:01   ` Lee Jones
2021-06-17 12:01     ` Lee Jones
2021-09-30 21:20     ` Suren Baghdasaryan
2021-09-30 21:20       ` Suren Baghdasaryan
2021-10-04 16:41       ` Tejun Heo
2021-10-04 16:41         ` Tejun Heo
2021-10-04 16:57         ` Suren Baghdasaryan
2021-10-04 16:57           ` Suren Baghdasaryan
2021-10-04 17:23           ` John Stultz
2021-10-04 17:23             ` John Stultz
2021-10-04 17:33             ` John Stultz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.