milos-linux/fs/nfsd
Yang Erkun 613257f919 Revert "NFSD: Defer sub-object cleanup in export put callbacks"
commit 516403d4d85607fdef3ca41d4a56b54e5566fa9a upstream.

This reverts commit 48db892356.

Commit 48db892356 ("NFSD: Defer sub-object cleanup in export
put callbacks") moved path_put() and auth_domain_put() out of
svc_export_put() and expkey_put() and behind queue_rcu_work() to
close a claimed use-after-free in e_show() and c_show() against
ex_path and ex_client->name. Discussion in [1] shows neither
the diagnosis nor the remedy survives review.

The downstream teardown of both sub-objects is already RCU-deferred.
auth_domain_put() reaches svcauth_unix_domain_release(), which frees
the unix_domain and its ->name through call_rcu(). path_put()
reaches dentry_free(), which frees the dentry through call_rcu(),
and prepend_path() is already structured to tolerate concurrent
dentry teardown. A reader in cache_seq_start_rcu() therefore
observes both sub-objects through the next grace period regardless
of whether svc_export_put() runs synchronously, so the synchronous
form was never unsafe.

The crash signature in the report cited by commit 48db892356
("NFSD: Defer sub-object cleanup in export put callbacks") has a
different root cause: a /proc/net/rpc cache file held open across
network-namespace exit lets cache_destroy_net() free cd->hash_table
while a reader is still walking it. The correct fix pins cd->net for
the open fd's lifetime and does not require any deferral inside
svc_export_put().

Meanwhile, deferring path_put() out of svc_export_put() reintroduces
the regression that commit 69d803c40e ("nfsd: Revert "nfsd:
release svc_expkey/svc_export with rcu_work"") repaired: after
"exportfs -r" drops the last cache reference, the mount reference
held through ex_path lingers in the workqueue, so a subsequent
umount fails with EBUSY.

Restore the synchronous path_put() and auth_domain_put() in
svc_export_put() and expkey_put() and the call_rcu()/kfree_rcu()
free of the containing structures. The unrelated fix for
ex_uuid/ex_stats from commit 2530766492 ("nfsd: fix UAF when
access ex_uuid or ex_stats") is preserved.

Link: https://lore.kernel.org/all/10019b42-4589-4f9f-8d5b-d8197db1ce3c@huawei.com/ [1]
Fixes: 48db892356 ("NFSD: Defer sub-object cleanup in export put callbacks")
Cc: stable@vger.kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Tested-by: Alexandr Alexandrov <alexandr.alexandrov@oracle.com>
Signed-off-by: Yang Erkun <yangerkun@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-06-27 11:08:17 +01:00
..
acl.h NFSD: Add support for XDR decoding POSIX draft ACLs 2026-01-29 09:48:33 -05:00
auth.c
auth.h
blocklayout.c NFSD: Enforce timeout on layout recall and integrate lease manager fencing 2026-03-29 21:25:09 -04:00
blocklayoutxdr.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
blocklayoutxdr.h NFSD/blocklayout: Introduce layout content structure 2025-11-16 18:20:11 -05:00
cache.h
current_stateid.h
debugfs.c nfsd: add a runtime switch for disabling delegated timestamps 2026-03-29 21:25:09 -04:00
export.c Revert "NFSD: Defer sub-object cleanup in export put callbacks" 2026-06-27 11:08:17 +01:00
export.h Revert "NFSD: Defer sub-object cleanup in export put callbacks" 2026-06-27 11:08:17 +01:00
filecache.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
filecache.h
flexfilelayout.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
flexfilelayoutxdr.c
flexfilelayoutxdr.h
idmap.h
Kconfig NFSD: Sign filehandles 2026-03-29 21:25:09 -04:00
localio.c
lockd.c lockd: Have nlm_fopen() return errno values 2026-03-29 21:25:09 -04:00
Makefile NFSD: Add instructions on how to deal with xdrgen files 2026-01-26 10:10:58 -05:00
netlink.c NFSD: Add a key for signing filehandles 2026-03-29 21:25:09 -04:00
netlink.h tools: ynl-gen: add regeneration comment 2025-11-25 19:20:42 -08:00
netns.h NFSD: convert callback RPC program to per-net namespace 2026-04-03 09:27:52 -04:00
nfs2acl.c NFS: NFSERR_INVAL is not defined by NFSv2 2026-01-26 10:10:58 -05:00
nfs3acl.c
nfs3proc.c vfs-6.19-rc1.directory.locking 2025-12-01 16:13:46 -08:00
nfs3xdr.c nfsd: fix comment typo in nfs3xdr 2026-04-03 09:28:47 -04:00
nfs4acl.c NFSD: Add support for XDR decoding POSIX draft ACLs 2026-01-29 09:48:33 -05:00
nfs4callback.c NFSD: convert callback RPC program to per-net namespace 2026-04-03 09:27:52 -04:00
nfs4idmap.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nfs4layouts.c NFSD: Enforce timeout on layout recall and integrate lease manager fencing 2026-03-29 21:25:09 -04:00
nfs4proc.c nfsd: update mtime/ctime on COPY in presence of delegated attributes 2026-05-10 12:41:03 -04:00
nfs4recover.c nfsd: switch purge_old() to use start_removing_noperm() 2026-03-06 10:24:12 +01:00
nfs4state.c nfsd-7.1 fixes: 2026-05-15 13:11:41 -07:00
nfs4xdr.c nfsd: use dynamic allocation for oversized NFSv4.0 replay cache 2026-03-29 21:25:09 -04:00
nfs4xdr_gen.c Add RPC language definition of NFSv4 POSIX ACL extension 2026-01-29 09:48:33 -05:00
nfs4xdr_gen.h Add RPC language definition of NFSv4 POSIX ACL extension 2026-01-29 09:48:33 -05:00
nfscache.c nfsd/sunrpc: move rq_cachetype into struct nfsd_thread_local_info 2026-03-29 21:25:09 -04:00
nfsctl.c Revert "NFSD: Defer sub-object cleanup in export put callbacks" 2026-06-27 11:08:17 +01:00
nfsd.h nfsd: add a runtime switch for disabling delegated timestamps 2026-03-29 21:25:09 -04:00
nfsfh.c NFSD 7.1 Release Notes 2026-04-20 10:44:02 -07:00
nfsfh.h
nfsproc.c NFS: NFSERR_INVAL is not defined by NFSv2 2026-01-26 10:10:58 -05:00
nfssvc.c nfsd/sunrpc: move rq_cachetype into struct nfsd_thread_local_info 2026-03-29 21:25:09 -04:00
nfsxdr.c nfsd: fix comment typo in nfsxdr 2026-04-03 09:29:07 -04:00
pnfs.h NFSD: Enforce timeout on layout recall and integrate lease manager fencing 2026-03-29 21:25:09 -04:00
state.h nfsd: update mtime/ctime on CLONE in presense of delegated attributes 2026-05-10 12:39:48 -04:00
stats.c
stats.h
trace.c
trace.h NFSD: Report whether fh_key was actually updated 2026-05-21 17:08:47 -04:00
vfs.c treewide: change inode->i_ino from unsigned long to u64 2026-03-06 14:31:28 +01:00
vfs.h NFSD: Refactor nfsd_setattr()'s ACL error reporting 2026-01-29 09:48:33 -05:00
xdr.h
xdr3.h
xdr4.h nfsd: update mtime/ctime on COPY in presence of delegated attributes 2026-05-10 12:41:03 -04:00
xdr4cb.h