From: Amos Kong <akong-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org,
cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
Subject: [PATCH] cgroup: fix device deny of DEV_ALL
Date: Fri, 18 May 2012 16:19:12 +0800 [thread overview]
Message-ID: <20120518081912.16779.21065.stgit@t> (raw)
In-Reply-To: <CAFeW=pZ8Y7ycxjxro7zBMqdtaCOYs4RmoxtDrsN8+mqLhOL--g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
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);
next parent reply other threads:[~2012-05-18 8:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAFeW=pZ8Y7ycxjxro7zBMqdtaCOYs4RmoxtDrsN8+mqLhOL--g@mail.gmail.com>
[not found] ` <CAFeW=pZ8Y7ycxjxro7zBMqdtaCOYs4RmoxtDrsN8+mqLhOL--g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-18 8:19 ` Amos Kong [this message]
2012-05-21 14:03 ` [PATCH] cgroup: fix device deny of DEV_ALL Serge Hallyn
[not found] ` <20120521140324.GA5091@sergelap>
2012-05-22 0:34 ` Li Zefan
[not found] ` <4FBADF1A.6040303-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2012-05-22 1:54 ` Serge E. Hallyn
[not found] ` <20120522015426.GA10344-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-05-22 2:08 ` Serge E. Hallyn
2012-05-22 2:14 ` Amos Kong
[not found] ` <20120522020857.GA10499@mail.hallyn.com>
[not found] ` <20120522020857.GA10499-7LNsyQBKDXoIagZqoN9o3w@public.gmane.org>
2012-05-22 2:23 ` Amos Kong
[not found] ` <4FBAF680.90007@redhat.com>
[not found] ` <4FBAF680.90007-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-05-22 12:48 ` Serge Hallyn
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120518081912.16779.21065.stgit@t \
--to=akong-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=mtosatti-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
--cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox