* [PATCH] device_cgroup: fix unchecked cgroup parent usage
@ 2012-10-31 16:04 Aristeu Rozanski
2012-10-31 16:23 ` Tejun Heo
[not found] ` <20121031160430.GD14789-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 2 replies; 5+ messages in thread
From: Aristeu Rozanski @ 2012-10-31 16:04 UTC (permalink / raw)
To: linux-kernel
Cc: Andrew Morton, Tejun Heo, Li Zefan, James Morris, Pavel Emelyanov,
Serge Hallyn, Jiri Slaby, cgroups
In 4cef7299b4786879a3e113e84084a72b24590c5b the cgroup parent usage is
unchecked. root will not have a parent and trying to use
device.{allow,deny} will cause problems. For some reason my stressing
scripts didn't test the root directory so I didn't catch it on my
regular tests.
Andrew, Tejun, this patch needs to make Linus tree ASAP or a revert for
4cef7299b4786879a3e113e84084a72b24590c5b.
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Li Zefan <lizefan@huawei.com>
Cc: James Morris <jmorris@namei.org>
Cc: Pavel Emelyanov <xemul@openvz.org>
Cc: Serge Hallyn <serge.hallyn@canonical.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
--- github.orig/security/device_cgroup.c 2012-10-26 17:18:01.739366780 -0400
+++ github/security/device_cgroup.c 2012-10-29 10:03:33.221918003 -0400
@@ -352,6 +352,8 @@
*/
static inline int may_allow_all(struct dev_cgroup *parent)
{
+ if (!parent)
+ return 1;
return parent->behavior == DEVCG_DEFAULT_ALLOW;
}
@@ -376,11 +378,14 @@
int count, rc;
struct dev_exception_item ex;
struct cgroup *p = devcgroup->css.cgroup;
- struct dev_cgroup *parent = cgroup_to_devcgroup(p->parent);
+ struct dev_cgroup *parent = NULL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
+ if (p->parent)
+ parent = cgroup_to_devcgroup(p->parent);
+
memset(&ex, 0, sizeof(ex));
b = buffer;
@@ -391,11 +396,14 @@
if (!may_allow_all(parent))
return -EPERM;
dev_exception_clean(devcgroup);
+ devcgroup->behavior = DEVCG_DEFAULT_ALLOW;
+ if (!parent)
+ break;
+
rc = dev_exceptions_copy(&devcgroup->exceptions,
&parent->exceptions);
if (rc)
return rc;
- devcgroup->behavior = DEVCG_DEFAULT_ALLOW;
break;
case DEVCG_DENY:
dev_exception_clean(devcgroup);
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] device_cgroup: fix unchecked cgroup parent usage
2012-10-31 16:04 [PATCH] device_cgroup: fix unchecked cgroup parent usage Aristeu Rozanski
@ 2012-10-31 16:23 ` Tejun Heo
[not found] ` <20121031160430.GD14789-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
1 sibling, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2012-10-31 16:23 UTC (permalink / raw)
To: Aristeu Rozanski
Cc: linux-kernel, Andrew Morton, Li Zefan, James Morris,
Pavel Emelyanov, Serge Hallyn, Jiri Slaby, cgroups
On Wed, Oct 31, 2012 at 12:04:30PM -0400, Aristeu Rozanski wrote:
> In 4cef7299b4786879a3e113e84084a72b24590c5b the cgroup parent usage is
> unchecked. root will not have a parent and trying to use
> device.{allow,deny} will cause problems. For some reason my stressing
> scripts didn't test the root directory so I didn't catch it on my
> regular tests.
>
> Andrew, Tejun, this patch needs to make Linus tree ASAP or a revert for
> 4cef7299b4786879a3e113e84084a72b24590c5b.
Acked-by: Tejun Heo <tj@kernel.org>
Andrew, can you please pick this one up?
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 5+ messages in thread[parent not found: <20121031160430.GD14789-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] device_cgroup: fix unchecked cgroup parent usage
[not found] ` <20121031160430.GD14789-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2012-10-31 17:21 ` Serge Hallyn
2012-10-31 23:35 ` Andrew Morton
1 sibling, 0 replies; 5+ messages in thread
From: Serge Hallyn @ 2012-10-31 17:21 UTC (permalink / raw)
To: Aristeu Rozanski
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Andrew Morton, Tejun Heo,
Li Zefan, James Morris, Pavel Emelyanov, Jiri Slaby,
cgroups-u79uwXL29TY76Z2rM5mHXA
Quoting Aristeu Rozanski (aris-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org):
> In 4cef7299b4786879a3e113e84084a72b24590c5b the cgroup parent usage is
> unchecked. root will not have a parent and trying to use
> device.{allow,deny} will cause problems. For some reason my stressing
> scripts didn't test the root directory so I didn't catch it on my
> regular tests.
>
> Andrew, Tejun, this patch needs to make Linus tree ASAP or a revert for
> 4cef7299b4786879a3e113e84084a72b24590c5b.
>
> Cc: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
> Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
> Cc: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> Cc: James Morris <jmorris-gx6/JNMH7DfYtjvyW6yDsg@public.gmane.org>
> Cc: Pavel Emelyanov <xemul-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
> Cc: Serge Hallyn <serge.hallyn-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Acked-by: Serge E. Hallyn <serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
> Cc: Jiri Slaby <jslaby-AlSwsSmVLrQ@public.gmane.org>
> Signed-off-by: Aristeu Rozanski <aris-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
> --- github.orig/security/device_cgroup.c 2012-10-26 17:18:01.739366780 -0400
> +++ github/security/device_cgroup.c 2012-10-29 10:03:33.221918003 -0400
> @@ -352,6 +352,8 @@
> */
> static inline int may_allow_all(struct dev_cgroup *parent)
> {
> + if (!parent)
> + return 1;
> return parent->behavior == DEVCG_DEFAULT_ALLOW;
> }
>
> @@ -376,11 +378,14 @@
> int count, rc;
> struct dev_exception_item ex;
> struct cgroup *p = devcgroup->css.cgroup;
> - struct dev_cgroup *parent = cgroup_to_devcgroup(p->parent);
> + struct dev_cgroup *parent = NULL;
>
> if (!capable(CAP_SYS_ADMIN))
> return -EPERM;
>
> + if (p->parent)
> + parent = cgroup_to_devcgroup(p->parent);
> +
> memset(&ex, 0, sizeof(ex));
> b = buffer;
>
> @@ -391,11 +396,14 @@
> if (!may_allow_all(parent))
> return -EPERM;
> dev_exception_clean(devcgroup);
> + devcgroup->behavior = DEVCG_DEFAULT_ALLOW;
> + if (!parent)
> + break;
> +
> rc = dev_exceptions_copy(&devcgroup->exceptions,
> &parent->exceptions);
> if (rc)
> return rc;
> - devcgroup->behavior = DEVCG_DEFAULT_ALLOW;
> break;
> case DEVCG_DENY:
> dev_exception_clean(devcgroup);
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH] device_cgroup: fix unchecked cgroup parent usage
[not found] ` <20121031160430.GD14789-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-10-31 17:21 ` Serge Hallyn
@ 2012-10-31 23:35 ` Andrew Morton
[not found] ` <20121031163501.79a0950e.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
1 sibling, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2012-10-31 23:35 UTC (permalink / raw)
To: Aristeu Rozanski
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Tejun Heo, Li Zefan,
James Morris, Pavel Emelyanov, Serge Hallyn, Jiri Slaby,
cgroups-u79uwXL29TY76Z2rM5mHXA
On Wed, 31 Oct 2012 12:04:30 -0400
Aristeu Rozanski <aris-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
> In 4cef7299b4786879a3e113e84084a72b24590c5b the cgroup parent usage is
> unchecked. root will not have a parent and trying to use
> device.{allow,deny} will cause problems.
From my reading of the code "problems" means "kernel null pointer
dereference".
> For some reason my stressing
> scripts didn't test the root directory so I didn't catch it on my
> regular tests.
>
> --- github.orig/security/device_cgroup.c 2012-10-26 17:18:01.739366780 -0400
> +++ github/security/device_cgroup.c 2012-10-29 10:03:33.221918003 -0400
> @@ -352,6 +352,8 @@
> */
> static inline int may_allow_all(struct dev_cgroup *parent)
offtopic: this function could quite neatly have a bool return type.
> {
> + if (!parent)
> + return 1;
hm. Does it need a comment explaining what and why? I guess not... just.
> return parent->behavior == DEVCG_DEFAULT_ALLOW;
> }
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-01 13:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-31 16:04 [PATCH] device_cgroup: fix unchecked cgroup parent usage Aristeu Rozanski
2012-10-31 16:23 ` Tejun Heo
[not found] ` <20121031160430.GD14789-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-10-31 17:21 ` Serge Hallyn
2012-10-31 23:35 ` Andrew Morton
[not found] ` <20121031163501.79a0950e.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2012-11-01 13:28 ` Aristeu Rozanski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).