kernel_samsung_a53x/fs/nfsd
Jeff Layton b9cd1e8628 nfsd: clean up potential nfsd_file refcount leaks in COPY codepath
[ Upstream commit 6ba434cb1a8d403ea9aad1b667c3ea3ad8b3191f ]

There are two different flavors of the nfsd4_copy struct. One is
embedded in the compound and is used directly in synchronous copies. The
other is dynamically allocated, refcounted and tracked in the client
struture. For the embedded one, the cleanup just involves releasing any
nfsd_files held on its behalf. For the async one, the cleanup is a bit
more involved, and we need to dequeue it from lists, unhash it, etc.

There is at least one potential refcount leak in this code now. If the
kthread_create call fails, then both the src and dst nfsd_files in the
original nfsd4_copy object are leaked.

The cleanup in this codepath is also sort of weird. In the async copy
case, we'll have up to four nfsd_file references (src and dst for both
flavors of copy structure). They are both put at the end of
nfsd4_do_async_copy, even though the ones held on behalf of the embedded
one outlive that structure.

Change it so that we always clean up the nfsd_file refs held by the
embedded copy structure before nfsd4_copy returns. Rework
cleanup_async_copy to handle both inter and intra copies. Eliminate
nfsd4_cleanup_intra_ssc since it now becomes a no-op.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 12:28:30 +01:00
..
acl.h NFSD: add posix ACLs to struct nfsd_attrs 2024-11-19 12:28:04 +01:00
auth.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
auth.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
blocklayout.c nfsd: move nfserrno() to vfs.c 2024-11-19 12:28:26 +01:00
blocklayoutxdr.c nfsd: move nfserrno() to vfs.c 2024-11-19 12:28:26 +01:00
blocklayoutxdr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cache.h nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_reply_cache_stats_fops 2024-11-19 12:28:24 +01:00
current_stateid.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
export.c nfsd: report per-export stats 2024-11-19 12:27:31 +01:00
export.h nfsd: move nfserrno() to vfs.c 2024-11-19 12:28:26 +01:00
fault_inject.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
filecache.c nfsd: allow nfsd_file_get to sanely handle a NULL pointer 2024-11-19 12:28:30 +01:00
filecache.h nfsd: fix handling of cached open files in nfsd4_open codepath 2024-11-19 12:28:29 +01:00
flexfilelayout.c nfsd: move nfserrno() to vfs.c 2024-11-19 12:28:26 +01:00
flexfilelayoutxdr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
flexfilelayoutxdr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
idmap.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig nfsd: allow disabling NFSv2 at compile time 2024-11-19 12:28:26 +01:00
lockd.c Keep read and write fds with each nlm_file 2024-11-19 12:27:44 +01:00
Makefile nfsd: allow disabling NFSv2 at compile time 2024-11-19 12:28:26 +01:00
netns.h NFSD: replace delayed_work with work_struct for nfsd_client_shrinker 2024-11-19 12:28:30 +01:00
nfs2acl.c NFSD: Finish converting the NFSv2 GETACL result encoder 2024-11-19 12:28:26 +01:00
nfs3acl.c NFSD: Finish converting the NFSv3 GETACL result encoder 2024-11-19 12:28:26 +01:00
nfs3proc.c NFSD: Add an NFSD_FILE_GC flag to enable nfsd_file garbage collection 2024-11-19 12:28:26 +01:00
nfs3xdr.c NFSD: Clean up WRITE arg decoders 2024-11-19 12:28:23 +01:00
nfs4acl.c NFSD: add posix ACLs to struct nfsd_attrs 2024-11-19 12:28:04 +01:00
nfs4callback.c NFSD: add support for sending CB_RECALL_ANY 2024-11-19 12:28:29 +01:00
nfs4idmap.c nfsd: move nfserrno() to vfs.c 2024-11-19 12:28:26 +01:00
nfs4layouts.c NFSD: Add tracepoints to report NFSv4 callback completions 2024-11-19 12:28:22 +01:00
nfs4proc.c nfsd: clean up potential nfsd_file refcount leaks in COPY codepath 2024-11-19 12:28:30 +01:00
nfs4recover.c nfsd: Propagate some error code returned by memdup_user() 2024-11-19 12:28:21 +01:00
nfs4state.c nfsd: allow nfsd_file_get to sanely handle a NULL pointer 2024-11-19 12:28:30 +01:00
nfs4xdr.c Revert "SUNRPC: Use RMW bitops in single-threaded hot paths" 2024-11-19 12:28:29 +01:00
nfscache.c nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_reply_cache_stats_fops 2024-11-19 12:28:24 +01:00
nfsctl.c NFSD: register/unregister of nfsd-client shrinker at nfsd startup/shutdown time 2024-11-19 12:28:29 +01:00
nfsd.h NFSD: register/unregister of nfsd-client shrinker at nfsd startup/shutdown time 2024-11-19 12:28:29 +01:00
nfsfh.c NFSD: Remove CONFIG_NFSD_V3 2024-11-19 12:27:54 +01:00
nfsfh.h NFSD: Use const pointers as parameters to fh_ helpers 2024-11-19 12:28:27 +01:00
nfsproc.c NFSD: Use set_bit(RQ_DROPME) 2024-11-19 12:28:29 +01:00
nfssvc.c NFSD: Use only RQ_DROPME to signal the need to drop a reply 2024-11-19 12:28:29 +01:00
nfsxdr.c NFSD: Clean up WRITE arg decoders 2024-11-19 12:28:23 +01:00
pnfs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
state.h NFSD: add delegation reaper to react to low memory condition 2024-11-19 12:28:29 +01:00
stats.c nfsd: use DEFINE_PROC_SHOW_ATTRIBUTE to define nfsd_proc_ops 2024-11-19 12:28:24 +01:00
stats.h nfsd: make nfsd_stats.th_cnt atomic_t 2024-11-19 12:27:50 +01:00
trace.c NFSD: Add SPDX header for fs/nfsd/trace.c 2024-11-19 12:27:20 +01:00
trace.h nfsd: fix handling of cached open files in nfsd4_open codepath 2024-11-19 12:28:29 +01:00
vfs.c NFSD: Add an NFSD_FILE_GC flag to enable nfsd_file garbage collection 2024-11-19 12:28:26 +01:00
vfs.h NFSD: Pass the target nfsd_file to nfsd_commit() 2024-11-19 12:28:26 +01:00
xdr.h SUNRPC: Change return value type of .pc_encode 2024-11-19 12:27:48 +01:00
xdr3.h SUNRPC: Change return value type of .pc_encode 2024-11-19 12:27:48 +01:00
xdr4.h NFSD: enhance inter-server copy cleanup 2024-11-19 12:28:30 +01:00
xdr4cb.h NFSD: add support for sending CB_RECALL_ANY 2024-11-19 12:28:29 +01:00