linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: Bruce Fields <bfields@fieldses.org>
Cc: Nelson Elhage <nelhage@nelhage.com>,
	Christoph Hellwig <hch@lst.de>,
	linux-nfs@vger.kernel.org, James Brown <jbrown@easypost.com>
Subject: Re: NFSv3 may inappropriately return EPERM for fsetxattr
Date: Sun, 12 Aug 2018 08:28:00 +1000	[thread overview]
Message-ID: <87d0uor11r.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <20180810170312.GG7906@fieldses.org>

[-- Attachment #1: Type: text/plain, Size: 3471 bytes --]

On Fri, Aug 10 2018, Bruce Fields wrote:

> On Fri, Aug 10, 2018 at 01:00:27PM -0400, Bruce Fields wrote:
>> On Fri, Aug 10, 2018 at 11:29:33AM +1000, NeilBrown wrote:
>> > On Mon, Mar 21 2016, Nelson Elhage wrote:
>> > 
>> > > That's correct. The other detail that seems to be important is that
>> > > the user making the call must be different from the user owning the
>> > > file. We've also been using user remapping on the server, so that
>> > > non-xattr calls succeed in that configuration.
>> > >
>> > > The reproducer James added in the bugzilla is:
>> > >
>> > > (on machine with IP address 10.1.1.1)
>> > > sudo mkdir /nfs_test
>> > > sudo useradd -u 10000 test_user
>> > > sudo chown test_user /nfs_test
>> > > echo "/nfs_test 10.1.1.2(rw,all_squash,anonuid=10000)" | sudo tee -a
>> > > /etc/exports
>> > > sudo exportfs -a
>> > >
>> > > (on machine with IP address 10.1.1.2)
>> > > sudo mkdir /nfs_test
>> > > sudo mount -t nfs -o vers=3,noacl 10.1.1.1:/nfs_test /nfs_test
>> > > touch /nfs_test/foo
>> > > install -m 755 /nfs_test/foo /nfs_test/bar
>> > 
>> > Did anything ever happen about this?
>> > I have a customer with a similar problem (in 4.4) but I cannot see any
>> > evidence of fixes landing in mainline.
>> > 
>> > Problem happens with you have uid mapping on the server
>> > (e.g. anonuid=10000 as above) and a user with a different uid on the
>> > client attempts setacl on a file with that user.
>> > As anon is mapped to the owner of the file, setacl should be allowed.
>> > However set_posix_acl() calls inode_owner_or_capable() which checks if
>> > the client-side uid matches the visible inode->i_uid - they don't.
>> > 
>> > Testing i_uid on the client is always incorrect for permission checking
>> > with NFS - the client should always ask the server, either with ACCESS
>> > or, in this case, by simply attempting the operation.
>> > 
>> > Any suggestions how best to fix this?
>> > - We could move the responsibility for permission checking into
>> >   i_op->set_acl, but that would be a large change and might make it too
>> >   easy for other filesystems to get it wrong.
>> > - we could have some sort of flag asking set_posix_acl(), but that's
>> >   rather clumsy.... maybe if i_op->set_acl_check_perm use that without
>> >   testing ownership first??
>> > - we could copy
>> >     posic_acl_xattr_{get,set,list} into nfs together with functions
>> >     they call, modify set_posix_acl() to not test ownership,
>> >     and provide a local 'struct xattr_handler' structure for NFS.
>> > 
>> > I don't really like any of those suggestions.  Can someone else do any
>> > better?
>> 
>> Do we have important callers of inode_owner_or_capable() in the vfs (as
>> opposed to in individual filesystems), and do any of them pose a similar
>> problem for network filesystems?
>
> do_linkat()->may_linkat() looks kinda suspicious to me.  Or what about
> the O_NOATIME check in map_open()?  Just engaging in dumb grepping
> here....
>
> --b.

NOATIME, both in open and fcntl, is rejected on NFS.  This seems valid
as there is no way in the protocol to ask the server to no update the
atime.

Others I found we just short-cuts to avoid calling i_op->permission() if
the caller was an owner.  I don't *think* that would affect NFS much
... though if an owner didn't have write permission, some things might
be incorrectly forbidden.  Maybe.

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2018-08-12  1:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18  3:46 NFSv3 may inappropriately return EPERM for fsetxattr Nelson Elhage
2016-03-21 14:43 ` Christoph Hellwig
2016-03-21 15:56   ` Nelson Elhage
2018-08-10  1:29     ` NeilBrown
2018-08-10 17:00       ` Bruce Fields
2018-08-10 17:03         ` Bruce Fields
2018-08-11 22:28           ` NeilBrown [this message]
2018-08-12 13:21             ` Bruce Fields
2018-08-12 23:55               ` NeilBrown
2018-08-14  9:03                 ` NeilBrown
2018-08-14 19:43                   ` Bruce Fields
2018-08-14 23:49                     ` NeilBrown
2018-08-16  0:39                     ` NeilBrown
2018-08-16 17:54                       ` Bruce Fields
2018-08-16 22:50                         ` NeilBrown

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=87d0uor11r.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=bfields@fieldses.org \
    --cc=hch@lst.de \
    --cc=jbrown@easypost.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=nelhage@nelhage.com \
    /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;
as well as URLs for NNTP newsgroup(s).