X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=kernel%2Fgroups.c;h=664411f171b59a9cfb7a8b9c8c843ab1ea3a908b;hb=ffe167b0f2debbb3e21d2094508f8caca5a5bd8e;hp=451698f86cfadae2eef8805df0795310b3f1d797;hpb=a292241cccb7e20e8b997a9a44177e7c98141859;p=karo-tx-linux.git diff --git a/kernel/groups.c b/kernel/groups.c index 451698f86cfa..664411f171b5 100644 --- a/kernel/groups.c +++ b/kernel/groups.c @@ -6,6 +6,7 @@ #include #include #include +#include #include /* init to 2 - one for init_task, one to ensure it is never freed */ @@ -213,6 +214,14 @@ out: return i; } +bool may_setgroups(void) +{ + struct user_namespace *user_ns = current_user_ns(); + + return ns_capable(user_ns, CAP_SETGID) && + userns_may_setgroups(user_ns); +} + /* * SMP: Our groups are copy-on-write. We can set them safely * without another task interfering. @@ -223,7 +232,7 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist) struct group_info *group_info; int retval; - if (!ns_capable(current_user_ns(), CAP_SETGID)) + if (!may_setgroups()) return -EPERM; if ((unsigned)gidsetsize > NGROUPS_MAX) return -EINVAL;