[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120518081912.16779.21065.stgit@t>
Date: Fri, 18 May 2012 16:19:12 +0800
From: Amos Kong <akong@...hat.com>
To: containers@...ts.linux-foundation.org, mtosatti@...hat.com,
linux-kernel@...r.kernel.org, lizefan@...wei.com,
cgroups@...r.kernel.org, tj@...nel.org, serue@...ibm.com
Subject: [PATCH] cgroup: fix device deny of DEV_ALL
@ mount -t cgroup -o devices none /cgroup
@ mkdir /cgroups/devices
@ ls -l /dev/dm-3
brw-rw----. 1 root disk 253, 3 Oct 14 19:03 /dev/dm-3
@ echo 'b 253:3 rw' > devices.deny
but I can still write it by 'dd if=/dev/zero of=/dev/dm-3'
In devcgroup_create(), we create a new whitelist, and add first
entry which type is 'DEV_ALL'. Execute "# echo 'b 253:3 rw' >
devices.deny", dev_whitelist_rm() will update access of first
entry to 1(m), but type of first entry is still 'DEV_ALL'.
Execute dd cmd to write device, __devcgroup_inode_permission()
will be called, permission checking will pass if entry type
is 'DEV_ALL'. So write operation of 'dd' is not denied.
Currently 'access' is updated by not be used, this patch updated
the type,major,minor of first entry, then permission checking
would work.
Signed-off-by: Amos Kong <akong@...hat.com>
---
security/device_cgroup.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/security/device_cgroup.c b/security/device_cgroup.c
index c43a332..d16b4bc 100644
--- a/security/device_cgroup.c
+++ b/security/device_cgroup.c
@@ -146,6 +146,11 @@ static void dev_whitelist_rm(struct dev_cgroup *dev_cgroup,
remove:
walk->access &= ~wh->access;
+ if (walk->type == DEV_ALL) {
+ walk->type = wh->type;
+ walk->major = wh->major;
+ walk->minor = wh->minor;
+ }
if (!walk->access) {
list_del_rcu(&walk->list);
kfree_rcu(walk, rcu);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists