linux-stable/fs/nfs
ChenXiaoSong 45b9932b4d NFSv4: fix open failure with O_ACCMODE flag
[ Upstream commit b243874f6f ]

open() with O_ACCMODE|O_DIRECT flags secondly will fail.

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)

Server nfsd4_decode_share_access() will fail with error nfserr_bad_xdr when
client use incorrect share access mode of 0.

Fix this by using NFS4_SHARE_ACCESS_BOTH share access mode in client,
just like firstly opening.

Fixes: ce4ef7c0a8 ("NFS: Split out NFS v4 file operations")
Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-13 21:01:04 +02:00
..
blocklayout treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
filelayout NFS: fix an incorrect limit in filelayout_decode_layout() 2021-06-03 09:00:35 +02:00
flexfilelayout pnfs/flexfiles: Fix misplaced barrier in nfs4_ff_layout_prepare_ds 2021-11-18 14:04:22 +01:00
cache_lib.c
cache_lib.h
callback.c
callback.h NFSv4.1: Fix uninitialised variable in devicenotify 2022-02-16 12:54:18 +01:00
callback_proc.c NFSv4/pNFS: Fix another issue with a list iterator pointing to the head 2022-04-08 14:40:30 +02:00
callback_xdr.c NFS: remove unneeded check in decode_devicenotify_args() 2022-04-08 14:40:27 +02:00
client.c NFS: Fix initialisation of nfs_client cl_flags field 2022-02-16 12:54:17 +01:00
delegation.c NFSv4: Fix delegation return in cases where we have to retry 2021-07-20 16:05:47 +02:00
delegation.h NFSv4: Fix delegation return in cases where we have to retry 2021-07-20 16:05:47 +02:00
dir.c NFSv4: fix open failure with O_ACCMODE flag 2022-04-13 21:01:04 +02:00
direct.c NFS: swap-out must always use STABLE writes. 2022-04-13 21:01:02 +02:00
dns_resolve.c NFS: remove duplicate headers 2020-05-27 10:10:12 -04:00
dns_resolve.h
export.c
file.c NFS: swap IO handling is slightly different for O_DIRECT IO 2022-04-13 21:01:02 +02:00
fs_context.c NFS: fs_context: validate UDP retrans to prevent shift out-of-bounds 2021-05-11 14:47:34 +02:00
fscache-index.c nfs: fscache: use timespec64 in inode auxdata 2020-01-15 10:54:30 -05:00
fscache.c NFSv4: Fix fscache cookie aux_data to ensure change_attr is included 2020-05-08 22:20:24 +01:00
fscache.h nfs: fscache: use timespec64 in inode auxdata 2020-01-15 10:54:30 -05:00
getroot.c NFS: Ensure security label is set for root inode 2020-03-30 19:56:50 -04:00
inode.c Revert "NFSv4: Handle the special Linux file open access mode" 2022-04-13 21:01:04 +02:00
internal.h NFSv4: fix open failure with O_ACCMODE flag 2022-04-13 21:01:04 +02:00
io.c
iostat.h
Kconfig nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default 2021-03-30 14:31:49 +02:00
Makefile NFSv4.2: add client side xattr caching. 2020-07-13 17:52:46 -04:00
mount_clnt.c NFSv3: fix rpc receive buffer size for MOUNT call 2020-05-14 18:42:44 -04:00
namespace.c NFS: fix nfs_path in case of a rename retry 2020-10-06 10:21:18 -04:00
netns.h
nfs.h
nfs2super.c
nfs2xdr.c NFS: Return valid errors from nfs2/3_decode_dirent() 2022-04-08 14:40:25 +02:00
nfs3_fs.h NFS: Additional refactoring for fs_context conversion 2020-01-15 10:15:17 -05:00
nfs3acl.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
nfs3client.c NFS: Additional refactoring for fs_context conversion 2020-01-15 10:15:17 -05:00
nfs3proc.c nfs: fix acl memory leak of posix_acl_create() 2021-07-20 16:05:51 +02:00
nfs3super.c
nfs3xdr.c NFS: Return valid errors from nfs2/3_decode_dirent() 2022-04-08 14:40:25 +02:00
nfs4_fs.h NFSv4 handle port presence in fs_location server string 2022-02-16 12:54:18 +01:00
nfs4client.c nfs: nfs4clinet: check the return value of kstrdup() 2022-02-16 12:54:18 +01:00
nfs4file.c NFSv4: fix open failure with O_ACCMODE flag 2022-04-13 21:01:04 +02:00
nfs4getroot.c
nfs4idmap.c Fix user namespace leak 2021-11-18 14:04:23 +01:00
nfs4idmap.h
nfs4namespace.c NFSv4 handle port presence in fs_location server string 2022-02-16 12:54:18 +01:00
nfs4proc.c NFSv4.1: don't retry BIND_CONN_TO_SESSION on session error 2022-04-08 14:40:29 +02:00
nfs4renewd.c NFSv4.0: nfs4_do_fsinfo() should not do implicit lease renewals 2020-02-04 12:27:55 -05:00
nfs4session.c
nfs4session.h
nfs4state.c NFSv4: Protect the state recovery thread against direct reclaim 2022-04-13 21:01:01 +02:00
nfs4super.c NFS: Adjust fs_context error logging 2021-01-19 18:27:30 +01:00
nfs4sysctl.c
nfs4trace.c pNFS/flexfiles: Add tracing for layout errors 2020-01-15 10:54:33 -05:00
nfs4trace.h NFSv4: Wait for stateid updates after CLOSE/OPEN_DOWNGRADE 2020-10-02 08:43:09 -04:00
nfs4xdr.c NFSv4 remove zero number of fs_locations entries error check 2022-02-16 12:54:18 +01:00
nfs42.h NFSv4.2: add the extended attribute proc functions. 2020-07-13 17:52:45 -04:00
nfs42proc.c NFSv4.2: fix reference count leaks in _nfs42_proc_copy_notify() 2022-04-13 21:01:01 +02:00
nfs42xattr.c NFSv4.2: fix failure to unregister shrinker 2020-11-12 10:40:02 -05:00
nfs42xdr.c NFSv42: Don't fail clone() unless the OP_CLONE operation failed 2021-12-01 09:19:03 +01:00
nfsroot.c nfsroot: Default mount option should ask for built-in NFS version 2020-11-02 10:29:03 -05:00
nfstrace.c
nfstrace.h nfs: define and use the NFS_INO_INVALID_XATTR flag 2020-07-13 17:52:45 -04:00
pagelist.c NFS: Avoid writeback threads getting stuck in mempool_alloc() 2022-04-13 21:01:03 +02:00
pnfs.c NFSv4/pNFS: Fix another issue with a list iterator pointing to the head 2022-04-08 14:40:30 +02:00
pnfs.h NFSv4/pNFS: Fix another issue with a list iterator pointing to the head 2022-04-08 14:40:30 +02:00
pnfs_dev.c
pnfs_nfs.c NFS: nfsiod should not block forever in mempool_alloc() 2022-04-13 21:01:03 +02:00
proc.c NFS: Add softreval behaviour to nfs_lookup_revalidate() 2020-01-24 16:51:13 -05:00
read.c NFS: Trace short NFS READs 2020-06-11 13:33:48 -04:00
super.c The one new feature this time, from Anna Schumaker, is READ_PLUS, which 2020-10-22 09:44:27 -07:00
symlink.c
sysctl.c
sysfs.c NFSv4: Fix up RCU annotations for struct nfs_netns_client 2020-10-15 13:31:08 -04:00
sysfs.h NFSv4: Fix up RCU annotations for struct nfs_netns_client 2020-10-15 13:31:08 -04:00
unlink.c NFS: Avoid referencing the cred twice in async rename/unlink 2020-03-16 08:34:29 -04:00
write.c NFS: Avoid writeback threads getting stuck in mempool_alloc() 2022-04-13 21:01:03 +02:00