Skip to content

Commit

Permalink
NFS: Use raw NFS access mask in nfs4_opendata_access()
Browse files Browse the repository at this point in the history
Commit bd8b244 ("NFS: Store the raw NFS access mask in the inode's
access cache") changed how the access results are stored after an
access() call.  An NFS v4 OPEN might have access bits returned with the
opendata, so we should use the NFS4_ACCESS values when determining the
return value in nfs4_opendata_access().

Fixes: bd8b244 ("NFS: Store the raw NFS access mask in the inode's
access cache")
Reported-by: Eryu Guan <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
Tested-by: Takashi Iwai <[email protected]>
  • Loading branch information
amschuma-ntap committed Jul 26, 2017
1 parent 1ebf980 commit 1e6f209
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2236,7 +2236,7 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
int openflags)
{
struct nfs_access_entry cache;
u32 mask;
u32 mask, flags;

/* access call failed or for some reason the server doesn't
* support any access modes -- defer access call until later */
Expand All @@ -2250,16 +2250,20 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
*/
if (openflags & __FMODE_EXEC) {
/* ONLY check for exec rights */
mask = MAY_EXEC;
if (S_ISDIR(state->inode->i_mode))
mask = NFS4_ACCESS_LOOKUP;
else
mask = NFS4_ACCESS_EXECUTE;
} else if ((fmode & FMODE_READ) && !opendata->file_created)
mask = MAY_READ;
mask = NFS4_ACCESS_READ;

cache.cred = cred;
cache.jiffies = jiffies;
nfs_access_set_mask(&cache, opendata->o_res.access_result);
nfs_access_add_cache(state->inode, &cache);

if ((mask & ~cache.mask & (MAY_READ | MAY_EXEC)) == 0)
flags = NFS4_ACCESS_READ | NFS4_ACCESS_EXECUTE | NFS4_ACCESS_LOOKUP;
if ((mask & ~cache.mask & flags) == 0)
return 0;

return -EACCES;
Expand Down

0 comments on commit 1e6f209

Please sign in to comment.