FAILED: patch "[PATCH] NFSD: Set nn->cld_net before registering the cld pipe" failed to apply to 6.1-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 14996e662f3b734427e2d645cacffc27b779f7d1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026110432-unearth-superjet-be12@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 14996e662f3b734427e2d645cacffc27b779f7d1 Mon Sep 17 00:00:00 2001
From: Chuck Lever <[email protected]>
Date: Tue, 1 Sep 2026 16:19:46 -0400
Subject: [PATCH] NFSD: Set nn->cld_net before registering the cld pipe
rpc_mkpipe_dentry() instantiates the pipe's dentry before it returns, so the cld pipe can be opened as soon as nfsd4_cld_register_net() has run. __nfsd4_init_cld_pipe() does not store the new cld_net in nn->cld_net until after that call. cld_pipe_downcall() reaches the cld_net only through that pointer and takes cn_lock without checking it, so a write() that lands in the window oopses.
Store nn->cld_net once @cn is fully initialized and before the pipe is registered, and clear it again when registration fails.
fs/nfsd/nfs4recover.c +10 -4
@@ -941,18 +941,24 @@ __nfsd4_init_cld_pipe(struct net *net) }spin_lock_init (&cn->cn_lock);INIT_LIST_HEAD (&cn->cn_list); +#ifdef CONFIG_NFSD_LEGACY_CLIENT_TRACKING + cn->cn_has_legacy = false; +#endif + +/* +* The pipe's methods reach @cn through nn->cld_net, so set +* it before the pipe can be opened. +*/ + nn->cld_net = cn; ret =nfsd4_cld_register_net (net, cn->cn_pipe);if (unlikely (ret)) goto err_destroy_data; -#ifdef CONFIG_NFSD_LEGACY_CLIENT_TRACKING - cn->cn_has_legacy = false; -#endif - nn->cld_net = cn;return 0 ; err_destroy_data: + nn->cld_net =NULL ;rpc_destroy_pipe_data (cn->cn_pipe); err:kfree (cn);
Sasha Levin
maintainerPATCH 1/1 NFSD: Set nn->cld_net before registering the cld pipe
From: Chuck Lever <[email protected]>
[ Upstream commit 14996e662f3b734427e2d645cacffc27b779f7d1 ]
rpc_mkpipe_dentry() instantiates the pipe's dentry before it returns, so the cld pipe can be opened as soon as nfsd4_cld_register_net() has run. __nfsd4_init_cld_pipe() does not store the new cld_net in nn->cld_net until after that call. cld_pipe_downcall() reaches the cld_net only through that pointer and takes cn_lock without checking it, so a write() that lands in the window oopses.
Store nn->cld_net once @cn is fully initialized and before the pipe is registered, and clear it again when registration fails.
--- fs/nfsd/nfs4recover.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/nfsd/nfs4recover.c +8 -2
@@ -1020,6 +1020,13 @@ __nfsd4_init_cld_pipe(struct net *net) }spin_lock_init (&cn->cn_lock);INIT_LIST_HEAD (&cn->cn_list); + cn->cn_has_legacy = false; + +/* +* The pipe's methods reach @cn through nn->cld_net, so set +* it before the pipe can be opened. +*/ + nn->cld_net = cn; dentry =nfsd4_cld_register_net (net, cn->cn_pipe);if (IS_ERR (dentry)) {
@@ -1028,11 +1035,10 @@ __nfsd4_init_cld_pipe(struct net *net) } cn->cn_pipe->dentry = dentry; - cn->cn_has_legacy = false; - nn->cld_net = cn;return 0 ; err_destroy_data: + nn->cld_net =NULL ;rpc_destroy_pipe_data (cn->cn_pipe); err:kfree (cn);
Signature · 1 line
2.53.0