devcgroup: fix permission check when adding entry to child cgroup
authorLi Zefan <lizf@cn.fujitsu.com>
Sun, 13 Jul 2008 19:14:04 +0000 (12:14 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sun, 13 Jul 2008 19:51:18 +0000 (12:51 -0700)
 # cat devices.list
 c 1:3 r
 # echo 'c 1:3 w' > sub/devices.allow
 # cat sub/devices.list
 c 1:3 w

As illustrated, the parent group has no write permission to /dev/null, so
it's child should not be allowed to add this write permission.

Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Cc: Serge Hallyn <serue@us.ibm.com>
Cc: Paul Menage <menage@google.com>
Cc: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
security/device_cgroup.c

index 1e2e28afba45883c43863e57fbd4baeeacee0523..ddd92cec78ed81c44bcfc4d9c530662a179381f2 100644 (file)
@@ -300,7 +300,7 @@ static int may_access_whitelist(struct dev_cgroup *c,
                        continue;
                if (whitem->minor != ~0 && whitem->minor != refwh->minor)
                        continue;
-               if (refwh->access & (~(whitem->access | ACC_MASK)))
+               if (refwh->access & (~whitem->access))
                        continue;
                return 1;
        }