All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 1/2] devices cgroup: allow can_attach() if ns_capable
@ 2013-07-23 18:16 ` Serge Hallyn
  0 siblings, 0 replies; 28+ messages in thread
From: Serge Hallyn @ 2013-07-23 18:16 UTC (permalink / raw)
  To: ebiederm-aS9lmoZGLiVWk0Htik3J/w
  Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

We allow a task to change its own devices cgroup, or to change other tasks'
cgroups if it has CAP_SYS_ADMIN.

Also allow task A to change task B's cgroup if task A has CAP_SYS_ADMIN
with respect to task B - meaning A is root in the same userns, or A
created B's userns.

Signed-off-by: Serge Hallyn <serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
---
 security/device_cgroup.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index 9760ecb6..8f5386ea 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -74,11 +74,14 @@ struct cgroup_subsys devices_subsys;
 static int devcgroup_can_attach(struct cgroup *new_cgrp,
 				struct cgroup_taskset *set)
 {
-	struct task_struct *task = cgroup_taskset_first(set);
+	struct task_struct *t = cgroup_taskset_first(set);
+	int ret = 0;
 
-	if (current != task && !capable(CAP_SYS_ADMIN))
-		return -EPERM;
-	return 0;
+	rcu_read_lock();
+	if (current != t && !ns_capable(__task_cred(t)->user_ns, CAP_SYS_ADMIN))
+		ret = -EPERM;
+	rcu_read_unlock();
+	return ret;
 }
 
 /*
-- 
1.7.9.5

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

end of thread, other threads:[~2013-11-04 22:07 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-23 18:16 [RFC PATCH 1/2] devices cgroup: allow can_attach() if ns_capable Serge Hallyn
2013-07-23 18:16 ` Serge Hallyn
2013-07-23 18:18 ` [RFC PATCH 2/2] capabilities: allow nice if we are privileged Serge Hallyn
2013-07-23 18:18   ` Serge Hallyn
2013-07-24  8:07   ` Eric W. Biederman
2013-07-24  8:07     ` Eric W. Biederman
2013-07-23 18:30 ` [RFC PATCH 1/2] devices cgroup: allow can_attach() if ns_capable Tejun Heo
2013-07-23 18:30   ` Tejun Heo
     [not found]   ` <20130723183018.GF21100-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-23 18:38     ` Serge Hallyn
2013-07-23 18:38       ` Serge Hallyn
2013-07-23 18:50       ` Tejun Heo
2013-07-23 18:50         ` Tejun Heo
     [not found]         ` <CAOS58YPynQ-QBx5nZEnYrP5kGTVvv9VAj0cV0aYeikTitvTQbA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-07-23 19:04           ` Serge Hallyn
2013-07-23 19:04             ` Serge Hallyn
2013-07-23 19:12             ` Tejun Heo
2013-07-23 19:12               ` Tejun Heo
     [not found]               ` <20130723191245.GI21100-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-23 19:28                 ` Serge Hallyn
2013-07-23 19:28                   ` Serge Hallyn
2013-07-23 19:39                   ` Tejun Heo
2013-07-23 19:39                     ` Tejun Heo
     [not found]                     ` <CAOS58YPEKtEiZWsn-8u6OPr-UsyQp=XR+ecGmXyOdT0JnYAmsA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-04 21:51                       ` Serge E. Hallyn
2013-11-04 21:51                         ` Serge E. Hallyn
     [not found]                         ` <20131104215135.GA26190-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2013-11-04 22:06                           ` Tejun Heo
2013-11-04 22:06                             ` Tejun Heo
2013-10-23  0:41           ` Serge E. Hallyn
2013-10-23  0:41             ` Serge E. Hallyn
     [not found]             ` <20131023004130.GA12788-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2013-10-24 10:57               ` Tejun Heo
2013-10-24 10:57                 ` Tejun Heo

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.