5 #include <linux/export.h>
6 #include <linux/slab.h>
9 #include <asm/uaccess.h>
22 nblocks = nblocks ? : 1;
26 group_info->
ngroups = gidsetsize;
37 goto out_undo_partial_alloc;
43 out_undo_partial_alloc:
57 for (i = 0; i < group_info->
nblocks; i++)
66 static int groups_to_user(
gid_t __user *grouplist,
73 for (i = 0; i <
count; i++) {
83 static int groups_from_user(
struct group_info *group_info,
84 gid_t __user *grouplist)
88 unsigned int count = group_info->
ngroups;
90 for (i = 0; i <
count; i++) {
106 static void groups_sort(
struct group_info *group_info)
109 int gidsetsize = group_info->
ngroups;
111 for (stride = 1; stride < gidsetsize; stride = 3 * stride + 1)
116 max = gidsetsize - stride;
117 for (base = 0; base <
max; base++) {
119 int right = left + stride;
122 while (left >= 0 && gid_gt(
GROUP_AT(group_info, left), tmp)) {
144 while (left < right) {
146 if (gid_gt(grp,
GROUP_AT(group_info, mid)))
148 else if (gid_lt(grp,
GROUP_AT(group_info, mid)))
167 groups_sort(group_info);
168 get_group_info(group_info);
169 new->group_info = group_info;
213 if (i > gidsetsize) {
217 if (groups_to_user(grouplist, cred->
group_info)) {
233 struct group_info *group_info;
244 retval = groups_from_user(group_info, grouplist);
264 if (!gid_eq(grp, cred->
fsgid))
276 if (!gid_eq(grp, cred->
egid))