From: Andrew Morton <akpm@osdl.org>
To: thockin@sun.com
Cc: arjanv@redhat.com, thomas.schlichter@web.de, thoffman@arnor.net,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: 2.6.2-rc2-mm2
Date: Fri, 30 Jan 2004 15:31:49 -0800 [thread overview]
Message-ID: <20040130153149.00bcb210.akpm@osdl.org> (raw)
In-Reply-To: <20040130232103.GF9155@sun.com>
Tim Hockin <thockin@sun.com> wrote:
>
> > + struct group_info *group_info = NULL;
>
> Why init to NULL?
leftovers.
> > + ngroups = 0;
> > + if (!(exp->ex_flags & NFSEXP_ALLSQUASH)) {
> > + for (i = 0; i < SVC_CRED_NGROUPS; i++) {
> > + if (cred->cr_groups[i])
> > + ngroups++;
> > + }
> > + }
>
> I though of doing this, but passed in favor of simplicity of patch :)
>
> The original made a specific point of doing
> gid_t group = cred->cr_groups[i];
> if (group == (gid_t) NOGROUP)
> break;
>
> So the count loop should probably be
> ngroups = 0;
> if (!(exp->ex_flags & NFSEXP_ALLSQUASH)) {
> for (i = 0; i < SVC_CRED_NGROUPS; i++) {
> gid_t group = cred->cr_groups[i];
> if (group == (gid_t) NOGROUP)
> break;
> ngroups++;
> }
> }
> So that we don't assume anything about NOGROUP.
yes, thanks.
> > + return ret;
>
> The caller in fs/nfsd/nfsfh.c still needs to check the return value and do
> something with it, or all this is just dumb.
We can add that to Neil's todo list ;)
diff -puN fs/nfsd/auth.c~increase-NGROUPS-nfsd-cleanup-checks fs/nfsd/auth.c
--- 25/fs/nfsd/auth.c~increase-NGROUPS-nfsd-cleanup-checks Fri Jan 30 15:03:55 2004
+++ 25-akpm/fs/nfsd/auth.c Fri Jan 30 15:28:36 2004
@@ -11,13 +11,26 @@
#include <linux/nfsd/nfsd.h>
#define CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
-void
-nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
+
+int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
{
struct svc_cred *cred = &rqstp->rq_cred;
- int i, j;
- gid_t groups[SVC_CRED_NGROUPS];
struct group_info *group_info;
+ int ngroups;
+ int i;
+ int ret;
+
+ ngroups = 0;
+ if (!(exp->ex_flags & NFSEXP_ALLSQUASH)) {
+ for (i = 0; i < SVC_CRED_NGROUPS; i++) {
+ if (cred->cr_groups[i] == (gid_t)NOGROUP)
+ break;
+ ngroups++;
+ }
+ }
+ group_info = groups_alloc(ngroups);
+ if (group_info == NULL)
+ return -ENOMEM;
if (exp->ex_flags & NFSEXP_ALLSQUASH) {
cred->cr_uid = exp->ex_anon_uid;
@@ -41,25 +54,24 @@ nfsd_setuser(struct svc_rqst *rqstp, str
current->fsgid = cred->cr_gid;
else
current->fsgid = exp->ex_anon_gid;
+
for (i = 0; i < SVC_CRED_NGROUPS; i++) {
gid_t group = cred->cr_groups[i];
if (group == (gid_t) NOGROUP)
break;
- groups[i] = group;
+ GROUP_AT(group_info, i) = group;
}
- group_info = groups_alloc(i);
- /* should be error checking, but we can't return ENOMEM! */
- for (j = 0; j < i; j++)
- GROUP_AT(group_info, j) = groups[j];
- if (set_current_groups(group_info))
- put_group_info(group_info);
- /* should be error handling but we return void */
- if ((cred->cr_uid)) {
- cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
+ ret = set_current_groups(group_info);
+ if (ret == 0) {
+ if ((cred->cr_uid)) {
+ cap_t(current->cap_effective) &= ~CAP_NFSD_MASK;
+ } else {
+ cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
+ current->cap_permitted);
+ }
} else {
- cap_t(current->cap_effective) |= (CAP_NFSD_MASK &
- current->cap_permitted);
+ put_group_info(group_info);
}
-
+ return ret;
}
diff -puN include/linux/nfsd/auth.h~increase-NGROUPS-nfsd-cleanup-checks include/linux/nfsd/auth.h
--- 25/include/linux/nfsd/auth.h~increase-NGROUPS-nfsd-cleanup-checks Fri Jan 30 15:03:55 2004
+++ 25-akpm/include/linux/nfsd/auth.h Fri Jan 30 15:03:55 2004
@@ -21,7 +21,7 @@
* Set the current process's fsuid/fsgid etc to those of the NFS
* client user
*/
-void nfsd_setuser(struct svc_rqst *, struct svc_export *);
+int nfsd_setuser(struct svc_rqst *, struct svc_export *);
#endif /* __KERNEL__ */
#endif /* LINUX_NFSD_AUTH_H */
_
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>
next prev parent reply other threads:[~2004-01-30 23:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-30 9:41 2.6.2-rc2-mm2 Andrew Morton
2004-01-30 10:52 ` 2.6.2-rc2-mm2 Helge Hafting
2004-01-30 11:14 ` 2.6.2-rc2-mm2 Zephaniah E. Hull
2004-01-30 16:25 ` 2.6.2-rc2-mm2 Gene Heskett
2004-01-30 17:25 ` 2.6.2-rc2-mm2 Gene Heskett
2004-01-30 18:58 ` 2.6.2-rc2-mm2 Torrey Hoffman
2004-01-30 19:07 ` 2.6.2-rc2-mm2 Thomas Schlichter
2004-01-30 19:23 ` 2.6.2-rc2-mm2 Arjan van de Ven
2004-01-30 19:47 ` 2.6.2-rc2-mm2 Andrew Morton
2004-01-30 19:55 ` 2.6.2-rc2-mm2 Arjan van de Ven
2004-01-30 20:17 ` 2.6.2-rc2-mm2 Tim Hockin
2004-01-30 20:33 ` 2.6.2-rc2-mm2 Andrew Morton
2004-01-30 21:12 ` 2.6.2-rc2-mm2 Tim Hockin
2004-01-30 22:00 ` 2.6.2-rc2-mm2 Andrew Morton
2004-01-30 22:31 ` 2.6.2-rc2-mm2 Tim Hockin
2004-01-30 23:08 ` 2.6.2-rc2-mm2 Andrew Morton
2004-01-30 23:21 ` 2.6.2-rc2-mm2 Tim Hockin
2004-01-30 23:31 ` Andrew Morton [this message]
2004-01-30 23:43 ` 2.6.2-rc2-mm2 Tim Hockin
2004-01-30 21:16 ` 2.6.2-rc2-mm2 John Stoffel
2004-01-30 21:52 ` 2.6.2-rc2-mm2 Tim Hockin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040130153149.00bcb210.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=arjanv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=thockin@sun.com \
--cc=thoffman@arnor.net \
--cc=thomas.schlichter@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox