diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-02-26 06:45:16 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-02-26 06:45:16 -0800 |
| commit | 5d573c6b86da12f39ea410dff6f80c8b9b0b5b82 (patch) | |
| tree | b981f856b6543eee6d33d26b5808ab69cbd0fec1 | |
| parent | 408b87a03f610d85dd3853535f74e395020900be (diff) | |
[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.
| -rw-r--r-- | fs/nfsd/auth.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c index bf38d343a285..cfe9ce881613 100644 --- a/fs/nfsd/auth.c +++ b/fs/nfsd/auth.c @@ -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; |
