From: Donald Buczek <buczek@molgen.mpg.de>
To: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Anna Schumaker <anna.schumaker@netapp.com>,
Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH] NFSv4: Don't perform cached access checks before we've OPENed the file
Date: Sun, 27 Dec 2015 13:18:50 +0100 [thread overview]
Message-ID: <567FD72A.7090903@molgen.mpg.de> (raw)
In-Reply-To: <1451185588-69667-1-git-send-email-trond.myklebust@primarydata.com>
On 27.12.2015 04:06, Trond Myklebust wrote:
> Donald Buczek reports that a nfs4 client incorrectly denies
> execute access based on outdated file mode (missing 'x' bit).
> After the mode on the server is 'fixed' (chmod +x) further execution
> attempts continue to fail, because the nfs ACCESS call updates
> the access parameter but not the mode parameter or the mode in
> the inode.
>
> The root cause is ultimately that the VFS is calling may_open()
> before the NFS client has a chance to OPEN the file and hence revalidate
> the access and attribute caches.
>
> Al Viro suggests:
>>>> Make nfs_permission() relax the checks when it sees MAY_OPEN, if you know
>>>> that things will be caught by server anyway?
>>> That can work as long as we're guaranteed that everything that calls
>>> inode_permission() with MAY_OPEN on a regular file will also follow up
>>> with a vfs_open() or dentry_open() on success. Is this always the
>>> case?
>> 1) in do_tmpfile(), followed by do_dentry_open() (not reachable by NFS since
>> it doesn't have ->tmpfile() instance anyway)
>>
>> 2) in atomic_open(), after the call of ->atomic_open() has succeeded.
>>
>> 3) in do_last(), followed on success by vfs_open()
>>
>> That's all. All calls of inode_permission() that get MAY_OPEN come from
>> may_open(), and there's no other callers of that puppy.
> Reported-by: Donald Buczek <buczek@molgen.mpg.de>
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=109771
> Link: http://lkml.kernel.org/r/1451046656-26319-1-git-send-email-buczek@molgen.mpg.de
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
> ---
> Hi Donald,
> Can you check if this fixes the issue for you?
>
> fs/nfs/dir.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index ce5a21861074..44e519c21e18 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2449,6 +2449,9 @@ int nfs_permission(struct inode *inode, int mask)
> case S_IFLNK:
> goto out;
> case S_IFREG:
> + if ((mask & MAY_OPEN) &&
> + nfs_server_capable(inode, NFS_CAP_ATOMIC_OPEN))
> + return 0;
> break;
> case S_IFDIR:
> /*
I can confirm that this fixes the original issue. However, even with
this patch, calls to the access syscall would continue to deliver
failure based on obsolete modes forever. This can be seen as a bug, too.
PS:
I don't yet understand the point of execute_ok. It doesn't even consider
the uid.
Apart from that two suggestions to consider:
* If we go over the server for ACCESS anyway, we could combine it
with a GETATTR compound operation. Then we would be ready for additional
client-side checks against the inode.
* If we look at the mode, we should validate it first (
nfs_revalidate_inode ? )
Regards
Donald
next prev parent reply other threads:[~2015-12-27 12:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-25 12:30 [PATCH] nfs: do not deny execute access based on outdated mode in inode Donald Buczek
2015-12-26 18:36 ` Trond Myklebust
2015-12-26 23:58 ` Donald Buczek
2015-12-27 0:11 ` Trond Myklebust
2015-12-27 0:38 ` Al Viro
2015-12-27 1:26 ` Trond Myklebust
2015-12-27 2:28 ` Al Viro
2015-12-27 2:54 ` Trond Myklebust
2015-12-27 3:06 ` [PATCH] NFSv4: Don't perform cached access checks before we've OPENed the file Trond Myklebust
2015-12-27 12:18 ` Donald Buczek [this message]
2015-12-27 16:23 ` Trond Myklebust
2015-12-27 17:57 ` Al Viro
2015-12-28 19:38 ` [PATCH] nfs: revalidate inode before access checks Donald Buczek
2015-12-28 21:10 ` Trond Myklebust
2015-12-29 0:40 ` [PATCH] NFS: Ensure we revalidate attributes before using execute_ok() Trond Myklebust
2015-12-29 19:51 ` Donald Buczek
2015-12-29 20:18 ` Trond Myklebust
2015-12-30 0:02 ` [PATCH] NFS: Fix attribute cache revalidation Trond Myklebust
2015-12-30 11:23 ` Donald Buczek
2015-12-30 14:04 ` Trond Myklebust
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=567FD72A.7090903@molgen.mpg.de \
--to=buczek@molgen.mpg.de \
--cc=anna.schumaker@netapp.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@primarydata.com \
--cc=viro@zeniv.linux.org.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;
as well as URLs for NNTP newsgroup(s).