]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - kernel/groups.c
Merge tag 'gpio-fixes-for-v5.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel...
[mirror_ubuntu-jammy-kernel.git] / kernel / groups.c
index 6ee6691f6839f64554aceeb1bbeca0785feda08d..787b381c7c0026c31793ab1ebd0c2383ced820f0 100644 (file)
 struct group_info *groups_alloc(int gidsetsize)
 {
        struct group_info *gi;
-       unsigned int len;
-
-       len = sizeof(struct group_info) + sizeof(kgid_t) * gidsetsize;
-       gi = kmalloc(len, GFP_KERNEL_ACCOUNT|__GFP_NOWARN|__GFP_NORETRY);
-       if (!gi)
-               gi = __vmalloc(len, GFP_KERNEL_ACCOUNT);
+       gi = kvmalloc(struct_size(gi, gid, gidsetsize), GFP_KERNEL_ACCOUNT);
        if (!gi)
                return NULL;
 
@@ -178,7 +173,7 @@ bool may_setgroups(void)
 {
        struct user_namespace *user_ns = current_user_ns();
 
-       return ns_capable(user_ns, CAP_SETGID) &&
+       return ns_capable_setid(user_ns, CAP_SETGID) &&
                userns_may_setgroups(user_ns);
 }