linux-stable/fs/nfs
Trond Myklebust f230d40147 NFS: Fix a race when updating an existing write
commit 76d2e3890f 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-09-04 14:28:44 +02:00
..
blocklayout pNFS: Fix uninited ptr deref in block/scsi layout 2025-08-28 16:24:25 +02:00
filelayout nfs: don't share pNFS DS connections between net namespaces 2025-06-04 14:38:07 +02:00
flexfilelayout pNFS/flexfiles: don't attempt pnfs on fatal DS errors 2025-08-28 16:24:13 +02:00
cache_lib.c
cache_lib.h
callback_proc.c
callback_xdr.c SUNRPC: Fix integer overflow in decode_rc_list() 2024-10-17 15:11:53 +02:00
callback.c
callback.h
client.c NFS: Fix the setting of capabilities when automounting a new filesystem 2025-08-28 16:24:32 +02:00
delegation.c NFSv4: Check for delegation validity in nfs_start_delegation_return_locked() 2025-06-04 14:37:54 +02:00
delegation.h
dir.c
direct.c
dns_resolve.c
dns_resolve.h
export.c NFS: Fix filehandle bounds checking in nfs_fh_to_dentry() 2025-08-28 16:24:13 +02:00
file.c
fs_context.c
fscache-index.c
fscache.c
fscache.h
getroot.c
inode.c nfs: Clean up /proc/net/rpc/nfs when nfs_fs_proc_net_init() fails. 2025-07-10 15:57:44 +02:00
internal.h NFS: Fix the setting of capabilities when automounting a new filesystem 2025-08-28 16:24:32 +02:00
io.c
iostat.h
Kconfig nfs: add missing selections of CONFIG_CRC32 2025-05-02 07:44:12 +02:00
Makefile
mount_clnt.c
namespace.c
netns.h
nfs2super.c
nfs2xdr.c
nfs3_fs.h
nfs3acl.c
nfs3client.c
nfs3proc.c
nfs3super.c
nfs3xdr.c
nfs4_fs.h
nfs4client.c NFS: Fix the setting of capabilities when automounting a new filesystem 2025-08-28 16:24:32 +02:00
nfs4file.c
nfs4getroot.c
nfs4idmap.c
nfs4idmap.h
nfs4namespace.c
nfs4proc.c NFS: Fix the setting of capabilities when automounting a new filesystem 2025-08-28 16:24:32 +02:00
nfs4renewd.c
nfs4session.c
nfs4session.h nfs: add missing selections of CONFIG_CRC32 2025-05-02 07:44:12 +02:00
nfs4state.c NFSv4: Treat ENETUNREACH errors as fatal for state recovery 2025-06-04 14:37:55 +02:00
nfs4super.c
nfs4sysctl.c
nfs4trace.c
nfs4trace.h
nfs4xdr.c
nfs42.h
nfs42proc.c NFSv4.2: mark OFFLOAD_CANCEL MOVEABLE 2025-03-13 12:50:10 +01:00
nfs42xattr.c
nfs42xdr.c NFSv4.2: fix COPY_NOTIFY xdr buf size calculation 2025-03-13 12:50:10 +01:00
nfs.h
nfsroot.c
nfstrace.c
nfstrace.h NFS: Add a tracepoint to show the results of nfs_set_cache_invalid() 2024-11-14 13:13:35 +01:00
pagelist.c NFS: Fix a race when updating an existing write 2025-09-04 14:28:44 +02:00
pnfs_dev.c
pnfs_nfs.c nfs: don't share pNFS DS connections between net namespaces 2025-06-04 14:38:07 +02:00
pnfs.c pNFS: Handle RPC size limit for layoutcommits 2025-08-28 16:24:25 +02:00
pnfs.h nfs: don't share pNFS DS connections between net namespaces 2025-06-04 14:38:07 +02:00
proc.c
read.c
super.c nfs: ignore SB_RDONLY when remounting nfs 2025-06-27 11:05:16 +01:00
symlink.c
sysctl.c
sysfs.c
sysfs.h
unlink.c
write.c NFS: Fix a race when updating an existing write 2025-09-04 14:28:44 +02:00