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

Revert "NFSv4: Handle the special Linux file open access mode"

This reverts commit 44942b4e.

After secondly opening a file with O_ACCMODE|O_DIRECT flags,
nfs4_valid_open_stateid() will dereference NULL nfs4_state when lseek().

Reproducer:
  1. mount -t nfs -o vers=4.2 $server_ip:/ /mnt/
  2. fd = open("/mnt/file", O_ACCMODE|O_DIRECT|O_CREAT)
  3. close(fd)
  4. fd = open("/mnt/file", O_ACCMODE|O_DIRECT)
  5. lseek(fd)
Reported-by: default avatarLyu Tao <tao.lyu@epfl.ch>
Signed-off-by: default avatarChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 7c9d845f
...@@ -1180,7 +1180,6 @@ int nfs_open(struct inode *inode, struct file *filp) ...@@ -1180,7 +1180,6 @@ int nfs_open(struct inode *inode, struct file *filp)
nfs_fscache_open_file(inode, filp); nfs_fscache_open_file(inode, filp);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(nfs_open);
/* /*
* This function is called whenever some part of NFS notices that * This function is called whenever some part of NFS notices that
......
...@@ -51,7 +51,7 @@ nfs4_file_open(struct inode *inode, struct file *filp) ...@@ -51,7 +51,7 @@ nfs4_file_open(struct inode *inode, struct file *filp)
return err; return err;
if ((openflags & O_ACCMODE) == 3) if ((openflags & O_ACCMODE) == 3)
return nfs_open(inode, filp); openflags--;
/* We can't create new files here */ /* We can't create new files here */
openflags &= ~(O_CREAT|O_EXCL); openflags &= ~(O_CREAT|O_EXCL);
......
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