Commit 5d573c6b authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] nfsd: don't modify group_info structures

From: Neil Brown <neilb@cse.unsw.edu.au>

Make sure nfsd doesn't modify group_info structures as they might be
shared.
parent 408b87a0
......@@ -21,15 +21,24 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
if (exp->ex_flags & NFSEXP_ALLSQUASH) {
cred->cr_uid = exp->ex_anon_uid;
cred->cr_gid = exp->ex_anon_gid;
cred->cr_group_info->ngroups = 0;
put_group_info(cred->cr_group_info);
cred->cr_group_info = groups_alloc(0);
} else if (exp->ex_flags & NFSEXP_ROOTSQUASH) {
struct group_info *gi;
if (!cred->cr_uid)
cred->cr_uid = exp->ex_anon_uid;
if (!cred->cr_gid)
cred->cr_gid = exp->ex_anon_gid;
for (i = 0; i < cred->cr_group_info->ngroups; i++)
if (!GROUP_AT(cred->cr_group_info, i))
GROUP_AT(cred->cr_group_info, i) = exp->ex_anon_gid;
gi = groups_alloc(cred->cr_group_info->ngroups);
if (gi)
for (i = 0; i < cred->cr_group_info->ngroups; i++) {
if (!GROUP_AT(cred->cr_group_info, i))
GROUP_AT(gi, i) = exp->ex_anon_gid;
else
GROUP_AT(gi, i) = GROUP_AT(cred->cr_group_info, i);
}
put_group_info(cred->cr_group_info);
cred->cr_group_info = gi;
}
if (cred->cr_uid != (uid_t) -1)
......@@ -41,6 +50,8 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
else
current->fsgid = exp->ex_anon_gid;
if (!cred->cr_group_info)
return -ENOMEM;
ret = set_current_groups(cred->cr_group_info);
if ((cred->cr_uid)) {
cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment