diff options
| -rw-r--r-- | arch/s390/kernel/compat_linux.c | 1 | ||||
| -rw-r--r-- | fs/nfsd/auth.c | 3 | ||||
| -rw-r--r-- | include/linux/cred.h | 1 | ||||
| -rw-r--r-- | kernel/groups.c | 5 | ||||
| -rw-r--r-- | kernel/uid16.c | 1 | ||||
| -rw-r--r-- | net/sunrpc/auth_gss/gss_rpc_xdr.c | 1 | ||||
| -rw-r--r-- | net/sunrpc/auth_gss/svcauth_gss.c | 1 | ||||
| -rw-r--r-- | net/sunrpc/svcauth_unix.c | 2 |
8 files changed, 13 insertions, 2 deletions
diff --git a/arch/s390/kernel/compat_linux.c b/arch/s390/kernel/compat_linux.c index f04db3779b34..59eea9c65d3e 100644 --- a/arch/s390/kernel/compat_linux.c +++ b/arch/s390/kernel/compat_linux.c | |||
| @@ -263,6 +263,7 @@ COMPAT_SYSCALL_DEFINE2(s390_setgroups16, int, gidsetsize, u16 __user *, grouplis | |||
| 263 | return retval; | 263 | return retval; |
| 264 | } | 264 | } |
| 265 | 265 | ||
| 266 | groups_sort(group_info); | ||
| 266 | retval = set_current_groups(group_info); | 267 | retval = set_current_groups(group_info); |
| 267 | put_group_info(group_info); | 268 | put_group_info(group_info); |
| 268 | 269 | ||
diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c index 697f8ae7792d..f650e475d8f0 100644 --- a/fs/nfsd/auth.c +++ b/fs/nfsd/auth.c | |||
| @@ -60,6 +60,9 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp) | |||
| 60 | gi->gid[i] = exp->ex_anon_gid; | 60 | gi->gid[i] = exp->ex_anon_gid; |
| 61 | else | 61 | else |
| 62 | gi->gid[i] = rqgi->gid[i]; | 62 | gi->gid[i] = rqgi->gid[i]; |
| 63 | |||
| 64 | /* Each thread allocates its own gi, no race */ | ||
| 65 | groups_sort(gi); | ||
| 63 | } | 66 | } |
| 64 | } else { | 67 | } else { |
| 65 | gi = get_group_info(rqgi); | 68 | gi = get_group_info(rqgi); |
diff --git a/include/linux/cred.h b/include/linux/cred.h index 099058e1178b..631286535d0f 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h | |||
| @@ -83,6 +83,7 @@ extern int set_current_groups(struct group_info *); | |||
| 83 | extern void set_groups(struct cred *, struct group_info *); | 83 | extern void set_groups(struct cred *, struct group_info *); |
| 84 | extern int groups_search(const struct group_info *, kgid_t); | 84 | extern int groups_search(const struct group_info *, kgid_t); |
| 85 | extern bool may_setgroups(void); | 85 | extern bool may_setgroups(void); |
| 86 | extern void groups_sort(struct group_info *); | ||
| 86 | 87 | ||
| 87 | /* | 88 | /* |
| 88 | * The security context of a task | 89 | * The security context of a task |
diff --git a/kernel/groups.c b/kernel/groups.c index e357bc800111..daae2f2dc6d4 100644 --- a/kernel/groups.c +++ b/kernel/groups.c | |||
| @@ -86,11 +86,12 @@ static int gid_cmp(const void *_a, const void *_b) | |||
| 86 | return gid_gt(a, b) - gid_lt(a, b); | 86 | return gid_gt(a, b) - gid_lt(a, b); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | static void groups_sort(struct group_info *group_info) | 89 | void groups_sort(struct group_info *group_info) |
| 90 | { | 90 | { |
| 91 | sort(group_info->gid, group_info->ngroups, sizeof(*group_info->gid), | 91 | sort(group_info->gid, group_info->ngroups, sizeof(*group_info->gid), |
| 92 | gid_cmp, NULL); | 92 | gid_cmp, NULL); |
| 93 | } | 93 | } |
| 94 | EXPORT_SYMBOL(groups_sort); | ||
| 94 | 95 | ||
| 95 | /* a simple bsearch */ | 96 | /* a simple bsearch */ |
| 96 | int groups_search(const struct group_info *group_info, kgid_t grp) | 97 | int groups_search(const struct group_info *group_info, kgid_t grp) |
| @@ -122,7 +123,6 @@ int groups_search(const struct group_info *group_info, kgid_t grp) | |||
| 122 | void set_groups(struct cred *new, struct group_info *group_info) | 123 | void set_groups(struct cred *new, struct group_info *group_info) |
| 123 | { | 124 | { |
| 124 | put_group_info(new->group_info); | 125 | put_group_info(new->group_info); |
| 125 | groups_sort(group_info); | ||
| 126 | get_group_info(group_info); | 126 | get_group_info(group_info); |
| 127 | new->group_info = group_info; | 127 | new->group_info = group_info; |
| 128 | } | 128 | } |
| @@ -206,6 +206,7 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist) | |||
| 206 | return retval; | 206 | return retval; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | groups_sort(group_info); | ||
| 209 | retval = set_current_groups(group_info); | 210 | retval = set_current_groups(group_info); |
| 210 | put_group_info(group_info); | 211 | put_group_info(group_info); |
| 211 | 212 | ||
diff --git a/kernel/uid16.c b/kernel/uid16.c index ce74a4901d2b..ef1da2a5f9bd 100644 --- a/kernel/uid16.c +++ b/kernel/uid16.c | |||
| @@ -192,6 +192,7 @@ SYSCALL_DEFINE2(setgroups16, int, gidsetsize, old_gid_t __user *, grouplist) | |||
| 192 | return retval; | 192 | return retval; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | groups_sort(group_info); | ||
| 195 | retval = set_current_groups(group_info); | 196 | retval = set_current_groups(group_info); |
| 196 | put_group_info(group_info); | 197 | put_group_info(group_info); |
| 197 | 198 | ||
diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c index c4778cae58ef..444380f968f1 100644 --- a/net/sunrpc/auth_gss/gss_rpc_xdr.c +++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c | |||
| @@ -231,6 +231,7 @@ static int gssx_dec_linux_creds(struct xdr_stream *xdr, | |||
| 231 | goto out_free_groups; | 231 | goto out_free_groups; |
| 232 | creds->cr_group_info->gid[i] = kgid; | 232 | creds->cr_group_info->gid[i] = kgid; |
| 233 | } | 233 | } |
| 234 | groups_sort(creds->cr_group_info); | ||
| 234 | 235 | ||
| 235 | return 0; | 236 | return 0; |
| 236 | out_free_groups: | 237 | out_free_groups: |
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 5dd4e6c9fef2..26531193fce4 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c | |||
| @@ -481,6 +481,7 @@ static int rsc_parse(struct cache_detail *cd, | |||
| 481 | goto out; | 481 | goto out; |
| 482 | rsci.cred.cr_group_info->gid[i] = kgid; | 482 | rsci.cred.cr_group_info->gid[i] = kgid; |
| 483 | } | 483 | } |
| 484 | groups_sort(rsci.cred.cr_group_info); | ||
| 484 | 485 | ||
| 485 | /* mech name */ | 486 | /* mech name */ |
| 486 | len = qword_get(&mesg, buf, mlen); | 487 | len = qword_get(&mesg, buf, mlen); |
diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 740b67d5a733..af7f28fb8102 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c | |||
| @@ -520,6 +520,7 @@ static int unix_gid_parse(struct cache_detail *cd, | |||
| 520 | ug.gi->gid[i] = kgid; | 520 | ug.gi->gid[i] = kgid; |
| 521 | } | 521 | } |
| 522 | 522 | ||
| 523 | groups_sort(ug.gi); | ||
| 523 | ugp = unix_gid_lookup(cd, uid); | 524 | ugp = unix_gid_lookup(cd, uid); |
| 524 | if (ugp) { | 525 | if (ugp) { |
| 525 | struct cache_head *ch; | 526 | struct cache_head *ch; |
| @@ -819,6 +820,7 @@ svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp) | |||
| 819 | kgid_t kgid = make_kgid(&init_user_ns, svc_getnl(argv)); | 820 | kgid_t kgid = make_kgid(&init_user_ns, svc_getnl(argv)); |
| 820 | cred->cr_group_info->gid[i] = kgid; | 821 | cred->cr_group_info->gid[i] = kgid; |
| 821 | } | 822 | } |
| 823 | groups_sort(cred->cr_group_info); | ||
| 822 | if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) { | 824 | if (svc_getu32(argv) != htonl(RPC_AUTH_NULL) || svc_getu32(argv) != 0) { |
| 823 | *authp = rpc_autherr_badverf; | 825 | *authp = rpc_autherr_badverf; |
| 824 | return SVC_DENIED; | 826 | return SVC_DENIED; |
