From: "J. Bruce Fields" <bfields@fieldses.org>
To: Roger Willcocks <roger@filmlight.ltd.uk>
Cc: linux-kernel@vger.kernel.org, nfs@lists.sourceforge.net,
Neil Brown <neilb@suse.de>
Subject: Re: nfsd bug: create file with specific uid/gid
Date: Fri, 30 Nov 2007 17:01:27 -0500 [thread overview]
Message-ID: <20071130220127.GJ24887@fieldses.org> (raw)
In-Reply-To: <475042FB.8020106@filmlight.ltd.uk>
On Fri, Nov 30, 2007 at 05:06:03PM +0000, Roger Willcocks wrote:
> nfsd/vfs.c:nfsd_create (the v2 version of create) says:
>
> "Set file attributes. Mode has already been set and
> setting uid/gid works only for root"
>
> but it doesn't actually test for root-ness (which could happen if the
> access is no-root-squash). There's similar code without the comment in
> nfsd_create_v3. In both cases the test:
>
> if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID|ATTR_MODE)) != 0)
>
> should read:
>
> if (current->fsuid != 0)
> iap->ia_valid &= ~(ATTR_UID|ATTR_GID);
> if ((iap->ia_valid &= ~ATTR_MODE) != 0)
>
> although arguably they should return an EPERM error if the uid/gid bits are
> set, instead of silently ignoring them.
Assignments (especially with things like &=) inside of conditionals
always make my head hurt for some reason. So maybe something like the
below?
Although I'd be happier if we could get a comment from someone with a
better understanding of why this hack was added in the first place.
Thanks for the bug report! (And, by the way, how did you run across
this?)
--b.
commit 38574420b8992d69f469ca86041f75b6e2283174
Author: J. Bruce Fields <bfields@citi.umich.edu>
Date: Fri Nov 30 16:55:23 2007 -0500
nfsd: allow root to set uid and gid on create
The server silently ignores attempts to set the uid and gid on create.
Based on the comment, this appears to have been done to prevent some
overly-clever IRIX client from causing itself problems.
Perhaps we should remove that hack completely. For now, at least, it
makes sense to allow root (when no_root_squash is set) to set uid and
gid.
Thanks to Roger Willcocks <roger@filmlight.ltd.uk> for the bug report
and original patch on which this is based.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 755ba43..8a8bf06 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -1257,12 +1257,16 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp,
}
- /* Set file attributes. Mode has already been set and
- * setting uid/gid works only for root. Irix appears to
+ /* Mode has already been set: */
+ iap->ia_valid &= ~ATTR_MODE;
+ /*
+ * Setting uid/gid works only for root. Irix appears to
* send along the gid when it tries to implement setgid
- * directories via NFS.
+ * directories via NFS:
*/
- if ((iap->ia_valid &= ~(ATTR_UID|ATTR_GID|ATTR_MODE)) != 0) {
+ if (current->fsuid != 0)
+ iap->ia_valid &= ~(ATTR_UID|ATTR_GID);
+ if (iap->ia_valid) {
__be32 err2 = nfsd_setattr(rqstp, resfhp, iap, 0, (time_t)0);
if (err2)
err = err2;
next prev parent reply other threads:[~2007-11-30 22:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-30 17:06 nfsd bug: create file with specific uid/gid Roger Willcocks
2007-11-30 22:01 ` J. Bruce Fields [this message]
2007-12-01 11:36 ` Roger Willcocks
2007-12-03 16:17 ` J. Bruce Fields
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=20071130220127.GJ24887@fieldses.org \
--to=bfields@fieldses.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@suse.de \
--cc=nfs@lists.sourceforge.net \
--cc=roger@filmlight.ltd.uk \
/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