From: Donald Buczek <buczek@molgen.mpg.de>
To: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH] NFS: Ensure we revalidate attributes before using execute_ok()
Date: Tue, 29 Dec 2015 20:51:00 +0100 [thread overview]
Message-ID: <5682E424.8070606@molgen.mpg.de> (raw)
In-Reply-To: <1451349629-47744-1-git-send-email-trond.myklebust@primarydata.com>
On 29.12.2015 01:40, Trond Myklebust wrote:
> Donald Buczek reports that NFS clients can also report incorrect
> results for access() due to lack of revalidation of attributes
> before calling execute_ok().
> Looking closely, it seems chdir() is afflicted with the same problem.
>
> Fix is to ensure we call nfs_revalidate_inode_rcu() or
> nfs_revalidate_inode() as appropriate before deciding to trust
> execute_ok().
>
> Reported-by: Donald Buczek <buczek@molgen.mpg.de>
> Link: http://lkml.kernel.org/r/1451331530-3748-1-git-send-email-buczek@molgen.mpg.de
> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
> ---
> fs/nfs/dir.c | 18 ++++++++++++++++--
> 1 file changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 44e519c21e18..5bd2f5bfaf57 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2432,6 +2432,20 @@ int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags)
> }
> EXPORT_SYMBOL_GPL(nfs_may_open);
>
> +static int nfs_execute_ok(struct inode *inode, int mask)
> +{
> + struct nfs_server *server = NFS_SERVER(inode);
> + int ret;
> +
> + if (mask & MAY_NOT_BLOCK)
> + ret = nfs_revalidate_inode_rcu(server, inode);
> + else
> + ret = nfs_revalidate_inode(server, inode);
> + if (ret == 0 && !execute_ok(inode))
> + ret = -EACCES;
> + return ret;
> +}
> +
> int nfs_permission(struct inode *inode, int mask)
> {
> struct rpc_cred *cred;
> @@ -2484,8 +2498,8 @@ force_lookup:
> res = PTR_ERR(cred);
> }
> out:
> - if (!res && (mask & MAY_EXEC) && !execute_ok(inode))
> - res = -EACCES;
> + if (!res && (mask & MAY_EXEC))
> + res = nfs_execute_ok(inode, mask);
>
> dfprintk(VFS, "NFS: permission(%s/%lu), mask=0x%x, res=%d\n",
> inode->i_sb->s_id, inode->i_ino, mask, res);
This patch doesn't resolve the problem. The reason is, that there is a
nfs_do_access() before this nfs_execute_ok() in the execution path of
nfs_permission. While nfs4_proc_acccess doesn't update the mode, it
does update read_cache_jiffies. So the later nfs_revalidate_inode will
be a noop, the cache was just made to look fresh.
If nfs_revalidate_inode would be called before the nfs_do_access it
might work. I fact it would make some sense to move it before the switch
based on inode->i_mode, because the mode might change on the server, too.
Regards
Donald
PS: Sorry for my faulty patch! What a shame :(
next prev parent reply other threads:[~2015-12-29 19:51 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
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 [this message]
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=5682E424.8070606@molgen.mpg.de \
--to=buczek@molgen.mpg.de \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@primarydata.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).