aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Schumaker2017-07-25 15:10:47 -0500
committerAnna Schumaker2017-07-26 15:53:57 -0500
commit1e6f209515a08de29ec53b653eac73b50efd949c (patch)
tree5fbb6452e99d9c30de647e697eff178d9cd38663
parent1ebf980127924c639e2b85c08468311ba1c95b70 (diff)
downloadlinux-phy-1e6f209515a08de29ec53b653eac73b50efd949c.tar.gz
linux-phy-1e6f209515a08de29ec53b653eac73b50efd949c.tar.xz
linux-phy-1e6f209515a08de29ec53b653eac73b50efd949c.zip
NFS: Use raw NFS access mask in nfs4_opendata_access()
Commit bd8b2441742b ("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: bd8b2441742b ("NFS: Store the raw NFS access mask in the inode's access cache") Reported-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Tested-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--fs/nfs/nfs4proc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index e1a26c653e78..583c2b38c908 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2236,7 +2236,7 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
2236 int openflags) 2236 int openflags)
2237{ 2237{
2238 struct nfs_access_entry cache; 2238 struct nfs_access_entry cache;
2239 u32 mask; 2239 u32 mask, flags;
2240 2240
2241 /* access call failed or for some reason the server doesn't 2241 /* access call failed or for some reason the server doesn't
2242 * support any access modes -- defer access call until later */ 2242 * support any access modes -- defer access call until later */
@@ -2250,16 +2250,20 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
2250 */ 2250 */
2251 if (openflags & __FMODE_EXEC) { 2251 if (openflags & __FMODE_EXEC) {
2252 /* ONLY check for exec rights */ 2252 /* ONLY check for exec rights */
2253 mask = MAY_EXEC; 2253 if (S_ISDIR(state->inode->i_mode))
2254 mask = NFS4_ACCESS_LOOKUP;
2255 else
2256 mask = NFS4_ACCESS_EXECUTE;
2254 } else if ((fmode & FMODE_READ) && !opendata->file_created) 2257 } else if ((fmode & FMODE_READ) && !opendata->file_created)
2255 mask = MAY_READ; 2258 mask = NFS4_ACCESS_READ;
2256 2259
2257 cache.cred = cred; 2260 cache.cred = cred;
2258 cache.jiffies = jiffies; 2261 cache.jiffies = jiffies;
2259 nfs_access_set_mask(&cache, opendata->o_res.access_result); 2262 nfs_access_set_mask(&cache, opendata->o_res.access_result);
2260 nfs_access_add_cache(state->inode, &cache); 2263 nfs_access_add_cache(state->inode, &cache);
2261 2264
2262 if ((mask & ~cache.mask & (MAY_READ | MAY_EXEC)) == 0) 2265 flags = NFS4_ACCESS_READ | NFS4_ACCESS_EXECUTE | NFS4_ACCESS_LOOKUP;
2266 if ((mask & ~cache.mask & flags) == 0)
2263 return 0; 2267 return 0;
2264 2268
2265 return -EACCES; 2269 return -EACCES;