Skip to content

Commit 6f1c1d9

Browse files
ChenXiaoSongTrond Myklebust
authored andcommitted
NFS: make sure open context mode have FMODE_EXEC when file open for exec
Because file f_mode never have FMODE_EXEC, open context mode won't get FMODE_EXEC from file f_mode. Open context mode only care about FMODE_READ/ FMODE_WRITE/FMODE_EXEC, and all info about open context mode can be convert from file f_flags, so convert file f_flags to open context mode by flags_to_mode(). Signed-off-by: ChenXiaoSong <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent d01c6ed commit 6f1c1d9

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

fs/nfs/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,8 @@ int nfs_open(struct inode *inode, struct file *filp)
11681168
{
11691169
struct nfs_open_context *ctx;
11701170

1171-
ctx = alloc_nfs_open_context(file_dentry(filp), filp->f_mode, filp);
1171+
ctx = alloc_nfs_open_context(file_dentry(filp),
1172+
flags_to_mode(filp->f_flags), filp);
11721173
if (IS_ERR(ctx))
11731174
return PTR_ERR(ctx);
11741175
nfs_file_set_open_context(filp, ctx);

fs/nfs/nfs4file.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ nfs4_file_open(struct inode *inode, struct file *filp)
3232
struct dentry *parent = NULL;
3333
struct inode *dir;
3434
unsigned openflags = filp->f_flags;
35-
fmode_t f_mode;
3635
struct iattr attr;
3736
int err;
3837

@@ -51,17 +50,14 @@ nfs4_file_open(struct inode *inode, struct file *filp)
5150
if (err)
5251
return err;
5352

54-
f_mode = filp->f_mode;
55-
if ((openflags & O_ACCMODE) == 3)
56-
f_mode |= flags_to_mode(openflags);
57-
5853
/* We can't create new files here */
5954
openflags &= ~(O_CREAT|O_EXCL);
6055

6156
parent = dget_parent(dentry);
6257
dir = d_inode(parent);
6358

64-
ctx = alloc_nfs_open_context(file_dentry(filp), f_mode, filp);
59+
ctx = alloc_nfs_open_context(file_dentry(filp),
60+
flags_to_mode(openflags), filp);
6561
err = PTR_ERR(ctx);
6662
if (IS_ERR(ctx))
6763
goto out;
@@ -366,8 +362,8 @@ static struct file *__nfs42_ssc_open(struct vfsmount *ss_mnt,
366362
goto out_free_name;
367363
}
368364

369-
ctx = alloc_nfs_open_context(filep->f_path.dentry, filep->f_mode,
370-
filep);
365+
ctx = alloc_nfs_open_context(filep->f_path.dentry,
366+
flags_to_mode(filep->f_flags), filep);
371367
if (IS_ERR(ctx)) {
372368
res = ERR_CAST(ctx);
373369
goto out_filep;

0 commit comments

Comments
 (0)