X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=kernel%2Fgroups.c;h=67b4ba30475fbc2b902e5a6226aeac2d2aaa5803;hb=677616e3ecaa43e77a81e36aa162d32bdba01476;hp=6b2588dd04ff20fb89995394f9c530a2613fbb83;hpb=2d117403b30cd7301af60d7d54b279a9f566d10d;p=firefly-linux-kernel-4.4.55.git diff --git a/kernel/groups.c b/kernel/groups.c index 6b2588dd04ff..67b4ba30475f 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 */ @@ -223,6 +224,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. @@ -233,7 +242,7 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist) struct group_info *group_info; int retval; - if (!nsown_capable(CAP_SETGID)) + if (!may_setgroups()) return -EPERM; if ((unsigned)gidsetsize > NGROUPS_MAX) return -EINVAL;