WSL2-Linux-Kernel/fs/nfs
ChenXiaoSong 6f52d4cda0 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 20:59:15 +02:00
..
blocklayout block: Add bio_max_segs 2021-02-26 15:49:51 -07:00
filelayout NFS: fix an incorrect limit in filelayout_decode_layout() 2021-05-20 12:17:08 -04:00
flexfilelayout pnfs/flexfiles: Fix misplaced barrier in nfs4_ff_layout_prepare_ds 2021-11-18 19:17:00 +01:00
Kconfig nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default 2021-03-08 11:47:47 -05:00
Makefile NFSv4.2: add client side xattr caching. 2020-07-13 17:52:46 -04:00
cache_lib.c NFS client updates for Linux 4.15 2017-11-17 14:18:00 -08:00
cache_lib.h NFS client updates for Linux 4.15 2017-11-17 14:18:00 -08:00
callback.c SUNRPC: Set rq_auth_stat in the pg_authenticate() callout 2021-08-10 14:18:35 -04:00
callback.h NFSv4.1: Fix uninitialised variable in devicenotify 2022-02-16 12:56:08 +01:00
callback_proc.c NFSv4/pNFS: Fix another issue with a list iterator pointing to the head 2022-04-08 14:23:54 +02:00
callback_xdr.c NFS: remove unneeded check in decode_devicenotify_args() 2022-04-08 14:23:48 +02:00
client.c NFSv4.1 query for fs_location attr on a new file system 2022-02-16 12:56:09 +01:00
delegation.c NFSv4: Add lease breakpoints in case of a delegation recall or return 2021-06-13 19:36:28 -04:00
delegation.h NFSv4: Fix delegation return in cases where we have to retry 2021-06-13 19:36:27 -04:00
dir.c NFSv4: fix open failure with O_ACCMODE flag 2022-04-13 20:59:15 +02:00
direct.c NFS: swap-out must always use STABLE writes. 2022-04-13 20:59:13 +02:00
dns_resolve.c NFS: remove duplicate headers 2020-05-27 10:10:12 -04:00
dns_resolve.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
export.c nfs: don't atempt blocking locks on nfs reexports 2021-08-26 15:32:10 -04:00
file.c NFS: swap IO handling is slightly different for O_DIRECT IO 2022-04-13 20:59:12 +02:00
fs_context.c NFSv4 introduce max_connect mount options 2021-08-27 16:37:17 -04:00
fscache-index.c nfs: fscache: use timespec64 in inode auxdata 2020-01-15 10:54:30 -05:00
fscache.c NFS: Fix fscache read from NFS after cache error 2021-07-08 14:03:26 -04:00
fscache.h nfs: fscache: use timespec64 in inode auxdata 2020-01-15 10:54:30 -05:00
getroot.c nfs: update has_sec_mnt_opts after cloning lsm options from parent 2021-06-28 09:34:39 -04:00
inode.c Revert "NFSv4: Handle the special Linux file open access mode" 2022-04-13 20:59:14 +02:00
internal.h NFSv4: fix open failure with O_ACCMODE flag 2022-04-13 20:59:15 +02:00
io.c NFS: Fix up incorrect documentation 2021-04-05 09:04:20 -04:00
iostat.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mount_clnt.c nfs: hornor timeo and retrans option when mounting NFSv3 2021-04-05 09:04:21 -04:00
namespace.c nfs: Remove trailing semicolon in macros 2021-05-27 09:19:33 -04:00
netns.h NFS: Add sysfs support for per-container identifier 2019-07-06 14:54:49 -04:00
nfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nfs2super.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
nfs2xdr.c NFS: Return valid errors from nfs2/3_decode_dirent() 2022-04-08 14:23:46 +02:00
nfs3_fs.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
nfs3acl.c vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
nfs3client.c NFS: Additional refactoring for fs_context conversion 2020-01-15 10:15:17 -05:00
nfs3proc.c NFSv3: Delete duplicate judgement in nfs3_async_handle_jukebox 2021-08-27 16:36:21 -04:00
nfs3super.c treewide: Add SPDX license identifier for more missed files 2019-05-21 10:50:45 +02:00
nfs3xdr.c NFS: Return valid errors from nfs2/3_decode_dirent() 2022-04-08 14:23:46 +02:00
nfs4_fs.h NFSv4 handle port presence in fs_location server string 2022-02-16 12:56:10 +01:00
nfs4client.c nfs: nfs4clinet: check the return value of kstrdup() 2022-02-16 12:56:08 +01:00
nfs4file.c NFSv4: fix open failure with O_ACCMODE flag 2022-04-13 20:59:15 +02:00
nfs4getroot.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nfs4idmap.c Fix user namespace leak 2021-11-18 19:17:02 +01:00
nfs4idmap.h
nfs4namespace.c NFSv4 handle port presence in fs_location server string 2022-02-16 12:56:10 +01:00
nfs4proc.c NFSv4.1: don't retry BIND_CONN_TO_SESSION on session error 2022-04-08 14:23:51 +02:00
nfs4renewd.c treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
nfs4session.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
nfs4session.h NFSv4.1: use BITS_PER_LONG macro in nfs4session.h 2020-12-14 06:51:07 -05:00
nfs4state.c NFSv4: Protect the state recovery thread against direct reclaim 2022-04-13 20:59:12 +02:00
nfs4super.c NFS: Adjust fs_context error logging 2021-01-10 13:32:39 -05:00
nfs4sysctl.c nfs: Do not convert nfs_idmap_cache_timeout to jiffies 2018-01-18 15:10:47 -05:00
nfs4trace.c pNFS/flexfiles: Add tracing for layout errors 2020-01-15 10:54:33 -05:00
nfs4trace.h treewide: Add missing semicolons to __assign_str uses 2021-06-30 09:19:14 -04:00
nfs4xdr.c NFSv4 remove zero number of fs_locations entries error check 2022-02-16 12:56:09 +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 20:59:11 +02:00
nfs42xattr.c nfs: Fix a typo in the file nfs42xattr.c 2021-04-05 09:04:20 -04:00
nfs42xdr.c NFSv42: Don't fail clone() unless the OP_CLONE operation failed 2021-12-01 09:04:47 +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 NFSv4: Catch and trace server filehandle encoding errors 2021-04-14 09:36:29 -04:00
nfstrace.h Merge branch 'work.namei' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2021-07-03 11:41:14 -07:00
pagelist.c NFS: Avoid writeback threads getting stuck in mempool_alloc() 2022-04-13 20:59:13 +02:00
pnfs.c NFSv4/pNFS: Fix another issue with a list iterator pointing to the head 2022-04-08 14:23:54 +02:00
pnfs.h NFSv4/pNFS: Fix another issue with a list iterator pointing to the head 2022-04-08 14:23:54 +02:00
pnfs_dev.c NFSv4/pnfs: Add tracing for the deviceid cache 2020-12-16 17:25:24 -05:00
pnfs_nfs.c NFS: nfsiod should not block forever in mempool_alloc() 2022-04-13 20:59:13 +02:00
proc.c NFS: NFSv2/v3 clients should never be setting NFS_CAP_XATTR 2022-04-08 14:22:52 +02:00
read.c NFS: Always provide aligned buffers to the RPC read layers 2021-08-30 13:21:38 -04:00
super.c NFSv4 introduce max_connect mount options 2021-08-27 16:37:17 -04:00
symlink.c nfs: pass the correct prototype to read_cache_page 2019-05-09 16:26:57 -04:00
sysctl.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
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: Fix open coded versions of nfs_set_cache_invalid() 2021-03-08 16:13:55 -05:00
write.c NFS: Avoid writeback threads getting stuck in mempool_alloc() 2022-04-13 20:59:13 +02:00