linux-yocto/fs/nfs
Trond Myklebust 92278ae369 NFS: Fix a race when updating an existing write
commit 76d2e3890fb169168c73f2e4f8375c7cc24a765e upstream.

After nfs_lock_and_join_requests() tests for whether the request is
still attached to the mapping, nothing prevents a call to
nfs_inode_remove_request() from succeeding until we actually lock the
page group.
The reason is that whoever called nfs_inode_remove_request() doesn't
necessarily have a lock on the page group head.

So in order to avoid races, let's take the page group lock earlier in
nfs_lock_and_join_requests(), and hold it across the removal of the
request in nfs_inode_remove_request().

Reported-by: Jeff Layton <jlayton@kernel.org>
Tested-by: Joe Quanaim <jdq@meta.com>
Tested-by: Andrew Steffen <aksteffen@meta.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Fixes: bd37d6fce1 ("NFSv4: Convert nfs_lock_and_join_requests() to use nfs_page_find_head_request()")
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-08-28 16:31:05 +02:00
..
blocklayout pNFS: Fix uninited ptr deref in block/scsi layout 2025-08-20 18:30:50 +02:00
filelayout nfs: don't share pNFS DS connections between net namespaces 2025-06-04 14:43:52 +02:00
flexfilelayout pNFS/flexfiles: don't attempt pnfs on fatal DS errors 2025-08-15 12:14:04 +02:00
cache_lib.c
cache_lib.h
callback_proc.c pNFS: Add a flag argument to pnfs_destroy_layouts_byclid() 2024-07-08 13:47:26 -04:00
callback_xdr.c SUNRPC: Fix integer overflow in decode_rc_list() 2024-10-03 16:19:13 -04:00
callback.c sunrpc: allow svc threads to fail initialisation cleanly 2024-09-20 19:31:03 -04:00
callback.h NFSv4: Add CB_GETATTR support for delegated attributes 2024-07-08 13:47:25 -04:00
client.c NFS: Fix the setting of capabilities when automounting a new filesystem 2025-08-20 18:30:14 +02:00
delegation.c NFSv4: Check for delegation validity in nfs_start_delegation_return_locked() 2025-05-29 11:02:03 +02:00
delegation.h NFSv4: Fix a deadlock when recovering state on a sillyrenamed file 2025-03-07 18:25:27 +01:00
dir.c NFS: Fix wakeup of __nfs_lookup_revalidate() in unblock_revalidate() 2025-08-15 12:14:04 +02:00
direct.c NFS: Adjust delegated timestamps for O_DIRECT reads and writes 2025-03-07 18:25:27 +01:00
dns_resolve.c NFS: Move common includes outside ifdef 2023-08-24 13:24:15 -04:00
dns_resolve.h
export.c NFS: Fix filehandle bounds checking in nfs_fh_to_dentry() 2025-08-15 12:14:04 +02:00
file.c NFS: fix nfs_release_folio() to not deadlock via kcompactd writeback 2025-03-13 13:01:58 +01:00
fs_context.c nfs: add 'noalignwrite' option for lock-less 'lost writes' prevention 2024-09-23 15:03:13 -04:00
fscache.c nfs: Fix oops in nfs_netfs_init_request() when copying to cache 2025-01-17 13:40:34 +01:00
fscache.h netfs: Speed up buffered reading 2024-09-12 12:20:41 +02:00
getroot.c nfs: fix the comment of nfs_get_root 2024-09-23 15:03:13 -04:00
inode.c nfs: Clean up /proc/net/rpc/nfs when nfs_fs_proc_net_init() fails. 2025-07-10 16:04:45 +02:00
internal.h NFS: Fix the setting of capabilities when automounting a new filesystem 2025-08-20 18:30:14 +02:00
io.c
iostat.h mm: add comments for allocation helpers explaining why they are macros 2024-07-12 15:52:20 -07:00
Kconfig nfs: add missing selections of CONFIG_CRC32 2025-04-25 10:47:50 +02:00
localio.c nfs: fix incorrect error handling in LOCALIO 2025-02-08 09:57:59 +01:00
Makefile nfs: add LOCALIO support 2024-09-23 15:03:30 -04:00
mount_clnt.c NFS: remove unused struct 'mnt_fhstatus' 2024-07-08 13:47:24 -04:00
namespace.c fs: pass the request_mask to generic_fillattr 2023-08-09 08:56:36 +02:00
netns.h nfs: make the rpc_stat per net namespace 2024-03-09 09:14:51 -05:00
nfs.h nfs: move nfs4_xattr_handlers to .rodata 2023-10-09 16:24:20 +02:00
nfs2super.c fs: nfs: add missing MODULE_DESCRIPTION() macros 2024-07-08 13:47:24 -04:00
nfs2xdr.c nfs_common: factor out nfs_errtbl and nfs_stat_to_errno 2024-09-23 15:03:29 -04:00
nfs3_fs.h
nfs3acl.c
nfs3client.c NFS: enable nconnect for RDMA 2024-03-09 09:14:51 -05:00
nfs3proc.c NFS: Don't allow waiting for exiting tasks 2025-05-29 11:02:03 +02:00
nfs3super.c fs: nfs: add missing MODULE_DESCRIPTION() macros 2024-07-08 13:47:24 -04:00
nfs3xdr.c nfs_common: factor out nfs_errtbl and nfs_stat_to_errno 2024-09-23 15:03:29 -04:00
nfs4_fs.h nfs: simplify and guarantee owner uniqueness. 2024-09-23 15:03:12 -04:00
nfs4client.c NFS: Fix the setting of capabilities when automounting a new filesystem 2025-08-20 18:30:14 +02:00
nfs4file.c filelock: split leases out of struct file_lock 2024-02-05 13:11:44 +01:00
nfs4getroot.c
nfs4idmap.c
nfs4idmap.h
nfs4namespace.c
nfs4proc.c NFS: Fix the setting of capabilities when automounting a new filesystem 2025-08-20 18:30:14 +02:00
nfs4renewd.c
nfs4session.c
nfs4session.h nfs: add missing selections of CONFIG_CRC32 2025-04-25 10:47:50 +02:00
nfs4state.c NFSv4: Treat ENETUNREACH errors as fatal for state recovery 2025-05-29 11:02:06 +02:00
nfs4super.c fs: nfs: add missing MODULE_DESCRIPTION() macros 2024-07-08 13:47:24 -04:00
nfs4sysctl.c fs: Remove the now superfluous sentinel elements from ctl_table array 2023-12-28 04:57:57 -08:00
nfs4trace.c nfs/blocklayout: SCSI layout trace points for reservation key reg/unreg 2024-07-08 13:47:27 -04:00
nfs4trace.h nfs/blocklayout: SCSI layout trace points for reservation key reg/unreg 2024-07-08 13:47:27 -04:00
nfs4xdr.c NFS: fix open_owner_id_maxsz and related fields. 2025-04-10 14:39:24 +02:00
nfs42.h NFSv4.2: fix listxattr maximum XDR buffer size 2024-02-28 16:18:18 -05:00
nfs42proc.c NFSv4.2: mark OFFLOAD_CANCEL MOVEABLE 2025-02-08 09:57:59 +01:00
nfs42xattr.c mm, slab: remove last vestiges of SLAB_MEM_SPREAD 2024-03-12 20:32:19 -07:00
nfs42xdr.c NFSv4.2: fix COPY_NOTIFY xdr buf size calculation 2025-02-08 09:57:59 +01:00
nfsroot.c NFS: Fix an off by one in root_nfs_cat() 2024-03-09 09:14:51 -05:00
nfstrace.c
nfstrace.h nfs: add LOCALIO support 2024-09-23 15:03:30 -04:00
pagelist.c NFS: Fix a race when updating an existing write 2025-08-28 16:31:05 +02:00
pnfs_dev.c nfs: remove the unused max_deviceinfo_size field from struct pnfs_layoutdriver_type 2024-07-10 13:23:17 -04:00
pnfs_nfs.c nfs: don't share pNFS DS connections between net namespaces 2025-06-04 14:43:52 +02:00
pnfs.c pNFS: Handle RPC size limit for layoutcommits 2025-08-20 18:30:50 +02:00
pnfs.h nfs: don't share pNFS DS connections between net namespaces 2025-06-04 14:43:52 +02:00
proc.c Return the delegation when deleting sillyrenamed files 2024-07-08 13:47:26 -04:00
read.c fs/nfs/read: fix double-unlock bug in nfs_return_empty_folio() 2025-06-27 11:11:15 +01:00
super.c nfs: ignore SB_RDONLY when remounting nfs 2025-06-19 15:32:08 +02:00
symlink.c nfs: Remove calls to folio_set_error 2024-05-31 12:31:41 +02:00
sysctl.c fs: Remove the now superfluous sentinel elements from ctl_table array 2023-12-28 04:57:57 -08:00
sysfs.c NFS: Shut down the nfs_client only after all the superblocks 2025-04-10 14:39:26 +02:00
sysfs.h
unlink.c Return the delegation when deleting sillyrenamed files 2024-07-08 13:47:26 -04:00
write.c NFS: Fix a race when updating an existing write 2025-08-28 16:31:05 +02:00