Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Supplementary group IDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/cred.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/security.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/sort.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/user_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/vmalloc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) struct group_info *groups_alloc(int gidsetsize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	struct group_info *gi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	len = sizeof(struct group_info) + sizeof(kgid_t) * gidsetsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	gi = kmalloc(len, GFP_KERNEL_ACCOUNT|__GFP_NOWARN|__GFP_NORETRY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	if (!gi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 		gi = __vmalloc(len, GFP_KERNEL_ACCOUNT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	if (!gi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	atomic_set(&gi->usage, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	gi->ngroups = gidsetsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	return gi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) EXPORT_SYMBOL(groups_alloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) void groups_free(struct group_info *group_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	kvfree(group_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) EXPORT_SYMBOL(groups_free);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /* export the group_info to a user-space array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) static int groups_to_user(gid_t __user *grouplist,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			  const struct group_info *group_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct user_namespace *user_ns = current_user_ns();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	unsigned int count = group_info->ngroups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		gid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		gid = from_kgid_munged(user_ns, group_info->gid[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		if (put_user(gid, grouplist+i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) /* fill a group_info from a user-space array - it must be allocated already */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static int groups_from_user(struct group_info *group_info,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)     gid_t __user *grouplist)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct user_namespace *user_ns = current_user_ns();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	unsigned int count = group_info->ngroups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	for (i = 0; i < count; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		gid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		kgid_t kgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		if (get_user(gid, grouplist+i))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		kgid = make_kgid(user_ns, gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		if (!gid_valid(kgid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		group_info->gid[i] = kgid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) static int gid_cmp(const void *_a, const void *_b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	kgid_t a = *(kgid_t *)_a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	kgid_t b = *(kgid_t *)_b;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	return gid_gt(a, b) - gid_lt(a, b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) void groups_sort(struct group_info *group_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	sort(group_info->gid, group_info->ngroups, sizeof(*group_info->gid),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	     gid_cmp, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) EXPORT_SYMBOL(groups_sort);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) /* a simple bsearch */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) int groups_search(const struct group_info *group_info, kgid_t grp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	unsigned int left, right;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	if (!group_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	left = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	right = group_info->ngroups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	while (left < right) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		unsigned int mid = (left+right)/2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		if (gid_gt(grp, group_info->gid[mid]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			left = mid + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		else if (gid_lt(grp, group_info->gid[mid]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			right = mid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  * set_groups - Change a group subscription in a set of credentials
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  * @new: The newly prepared set of credentials to alter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * @group_info: The group list to install
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) void set_groups(struct cred *new, struct group_info *group_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	put_group_info(new->group_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	get_group_info(group_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	new->group_info = group_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) EXPORT_SYMBOL(set_groups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  * set_current_groups - Change current's group subscription
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  * @group_info: The group list to impose
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  * Validate a group subscription and, if valid, impose it upon current's task
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  * security record.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) int set_current_groups(struct group_info *group_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	struct cred *new;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	new = prepare_creds();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	if (!new)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	set_groups(new, group_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	return commit_creds(new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) EXPORT_SYMBOL(set_current_groups);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) SYSCALL_DEFINE2(getgroups, int, gidsetsize, gid_t __user *, grouplist)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	const struct cred *cred = current_cred();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	if (gidsetsize < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	/* no need to grab task_lock here; it cannot change */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	i = cred->group_info->ngroups;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	if (gidsetsize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 		if (i > gidsetsize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 			i = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		if (groups_to_user(grouplist, cred->group_info)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 			i = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	return i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) bool may_setgroups(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	struct user_namespace *user_ns = current_user_ns();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	return ns_capable_setid(user_ns, CAP_SETGID) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		userns_may_setgroups(user_ns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  *	SMP: Our groups are copy-on-write. We can set them safely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *	without another task interfering.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	struct group_info *group_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	int retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	if (!may_setgroups())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	if ((unsigned)gidsetsize > NGROUPS_MAX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	group_info = groups_alloc(gidsetsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	if (!group_info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	retval = groups_from_user(group_info, grouplist);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	if (retval) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		put_group_info(group_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	groups_sort(group_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	retval = set_current_groups(group_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	put_group_info(group_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)  * Check whether we're fsgid/egid or in the supplemental group..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) int in_group_p(kgid_t grp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	const struct cred *cred = current_cred();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	int retval = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	if (!gid_eq(grp, cred->fsgid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		retval = groups_search(cred->group_info, grp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) EXPORT_SYMBOL(in_group_p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) int in_egroup_p(kgid_t grp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	const struct cred *cred = current_cred();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	int retval = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	if (!gid_eq(grp, cred->egid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		retval = groups_search(cred->group_info, grp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	return retval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) EXPORT_SYMBOL(in_egroup_p);