Skip to content

Commit

Permalink
NFSv4: Handle the special Linux file open access mode
Browse files Browse the repository at this point in the history
According to the open() manpage, Linux reserves the access mode 3
to mean "check for read and write permission on the file and return
a file descriptor that can't be used for reading or writing."

Currently, the NFSv4 code will ask the server to open the file,
and will use an incorrect share access mode of 0. Since it has
an incorrect share access mode, the client later forgets to send
a corresponding close, meaning it can leak stateids on the server.

Fixes: ce4ef7c ("NFS: Split out NFS v4 file operations")
Cc: stable@vger.kernel.org # 3.6+
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Trond Myklebust committed Jul 6, 2019
1 parent 1bf85d8 commit 44942b4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ int nfs_open(struct inode *inode, struct file *filp)
nfs_fscache_open_file(inode, filp);
return 0;
}
EXPORT_SYMBOL_GPL(nfs_open);

/*
* This function is called whenever some part of NFS notices that
Expand Down
2 changes: 1 addition & 1 deletion fs/nfs/nfs4file.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)
return err;

if ((openflags & O_ACCMODE) == 3)
openflags--;
return nfs_open(inode, filp);

/* We can't create new files here */
openflags &= ~(O_CREAT|O_EXCL);
Expand Down

0 comments on commit 44942b4

Please sign in to comment.