Commit d564d2c4 authored by ChenXiaoSong's avatar ChenXiaoSong Committed by Trond Myklebust

NFSv4: check FMODE_EXEC from open context mode in nfs4_opendata_access()

After converting file f_flags to open context mode by flags_to_mode(), open
context mode will have FMODE_EXEC when file open for exec, so we check
FMODE_EXEC from open context mode.

No functional change, just simplify the code.
Signed-off-by: default avatarChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 6f1c1d95
...@@ -2630,8 +2630,7 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data) ...@@ -2630,8 +2630,7 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data)
*/ */
static int nfs4_opendata_access(const struct cred *cred, static int nfs4_opendata_access(const struct cred *cred,
struct nfs4_opendata *opendata, struct nfs4_opendata *opendata,
struct nfs4_state *state, fmode_t fmode, struct nfs4_state *state, fmode_t fmode)
int openflags)
{ {
struct nfs_access_entry cache; struct nfs_access_entry cache;
u32 mask, flags; u32 mask, flags;
...@@ -2642,11 +2641,7 @@ static int nfs4_opendata_access(const struct cred *cred, ...@@ -2642,11 +2641,7 @@ static int nfs4_opendata_access(const struct cred *cred,
return 0; return 0;
mask = 0; mask = 0;
/* if (fmode & FMODE_EXEC) {
* Use openflags to check for exec, because fmode won't
* always have FMODE_EXEC set when file open for exec.
*/
if (openflags & __FMODE_EXEC) {
/* ONLY check for exec rights */ /* ONLY check for exec rights */
if (S_ISDIR(state->inode->i_mode)) if (S_ISDIR(state->inode->i_mode))
mask = NFS4_ACCESS_LOOKUP; mask = NFS4_ACCESS_LOOKUP;
...@@ -3034,7 +3029,7 @@ static unsigned nfs4_exclusive_attrset(struct nfs4_opendata *opendata, ...@@ -3034,7 +3029,7 @@ static unsigned nfs4_exclusive_attrset(struct nfs4_opendata *opendata,
} }
static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
int flags, struct nfs_open_context *ctx) struct nfs_open_context *ctx)
{ {
struct nfs4_state_owner *sp = opendata->owner; struct nfs4_state_owner *sp = opendata->owner;
struct nfs_server *server = sp->so_server; struct nfs_server *server = sp->so_server;
...@@ -3095,8 +3090,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, ...@@ -3095,8 +3090,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
/* Parse layoutget results before we check for access */ /* Parse layoutget results before we check for access */
pnfs_parse_lgopen(state->inode, opendata->lgp, ctx); pnfs_parse_lgopen(state->inode, opendata->lgp, ctx);
ret = nfs4_opendata_access(sp->so_cred, opendata, state, ret = nfs4_opendata_access(sp->so_cred, opendata, state, acc_mode);
acc_mode, flags);
if (ret != 0) if (ret != 0)
goto out; goto out;
...@@ -3170,7 +3164,7 @@ static int _nfs4_do_open(struct inode *dir, ...@@ -3170,7 +3164,7 @@ static int _nfs4_do_open(struct inode *dir,
if (d_really_is_positive(dentry)) if (d_really_is_positive(dentry))
opendata->state = nfs4_get_open_state(d_inode(dentry), sp); opendata->state = nfs4_get_open_state(d_inode(dentry), sp);
status = _nfs4_open_and_get_state(opendata, flags, ctx); status = _nfs4_open_and_get_state(opendata, ctx);
if (status != 0) if (status != 0)
goto err_opendata_put; goto err_opendata_put;
state = ctx->state; state = ctx->state;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment