Skip to content

Commit 5330208

Browse files
trondmypdgregkh
authored andcommitted
NFS: Ensure we revalidate attributes before using execute_ok()
commit 5c5fc09a1157a11dbe84e6421c3e0b37d05238cb upstream. 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> Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cb1fb15 commit 5330208

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

fs/nfs/dir.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,6 +2421,20 @@ int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags)
24212421
}
24222422
EXPORT_SYMBOL_GPL(nfs_may_open);
24232423

2424+
static int nfs_execute_ok(struct inode *inode, int mask)
2425+
{
2426+
struct nfs_server *server = NFS_SERVER(inode);
2427+
int ret;
2428+
2429+
if (mask & MAY_NOT_BLOCK)
2430+
ret = nfs_revalidate_inode_rcu(server, inode);
2431+
else
2432+
ret = nfs_revalidate_inode(server, inode);
2433+
if (ret == 0 && !execute_ok(inode))
2434+
ret = -EACCES;
2435+
return ret;
2436+
}
2437+
24242438
int nfs_permission(struct inode *inode, int mask)
24252439
{
24262440
struct rpc_cred *cred;
@@ -2470,8 +2484,8 @@ int nfs_permission(struct inode *inode, int mask)
24702484
res = PTR_ERR(cred);
24712485
}
24722486
out:
2473-
if (!res && (mask & MAY_EXEC) && !execute_ok(inode))
2474-
res = -EACCES;
2487+
if (!res && (mask & MAY_EXEC))
2488+
res = nfs_execute_ok(inode, mask);
24752489

24762490
dfprintk(VFS, "NFS: permission(%s/%lu), mask=0x%x, res=%d\n",
24772491
inode->i_sb->s_id, inode->i_ino, mask, res);

0 commit comments

Comments
 (0)