Skip to content

Commit

Permalink
nfs: verify open flags before allowing open
Browse files Browse the repository at this point in the history
Commit 9597c13 forbade opens with O_APPEND|O_DIRECT for NFSv4:

    nfs: verify open flags before allowing an atomic open

    Currently, you can open a NFSv4 file with O_APPEND|O_DIRECT, but cannot
    fcntl(F_SETFL,...) with those flags. This flag combination is explicitly
    forbidden on NFSv3 opens, and it seems like it should also be on NFSv4.

However, you can still open a file with O_DIRECT|O_APPEND if there exists a
cached dentry for the file because nfs4_file_open() is used instead of
nfs_atomic_open() and the check is bypassed.  Add the check in
nfs4_file_open() as well.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
Benjamin Coddington authored and Trond Myklebust committed Jun 25, 2015
1 parent 0c8315d commit 18a6008
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/nfs/nfs4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ nfs4_file_open(struct inode *inode, struct file *filp)

dprintk("NFS: open file(%pd2)\n", dentry);

err = nfs_check_flags(openflags);
if (err)
return err;

if ((openflags & O_ACCMODE) == 3)
openflags--;

Expand Down

0 comments on commit 18a6008

Please sign in to comment.