FAILED: patch "[PATCH] NFSD: Guard admin state-revocation walks with NFSD_NET_UP" failed to apply to 6.12-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 6.12-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.12.y
git checkout FETCH_HEAD
git cherry-pick -x 2f3e6638aebc0ab8afb8b4e9816ea9a1cad85378
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090353-oat-exclude-4fc9@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 2f3e6638aebc0ab8afb8b4e9816ea9a1cad85378 Mon Sep 17 00:00:00 2001
From: Chuck Lever <[email protected]>
Date: Sun, 21 Jun 2026 12:25:51 -0400
Subject: [PATCH] NFSD: Guard admin state-revocation walks with NFSD_NET_UP
Writing to /proc/fs/nfsd/unlock_filesystem, or sending the NFSD_CMD_UNLOCK_FILESYSTEM or NFSD_CMD_UNLOCK_EXPORT netlink command, walks the NFSv4 client hash tables to revoke open state and cancel async COPY operations. All three handlers gate that walk on nn->nfsd_serv, but a listener added via portlist or netlink listener_set sets nn->nfsd_serv before any nfsd thread starts. nfsd_startup_net() has not yet allocated nn->conf_id_hashtbl, so the walkers dereference a NULL table. A local administrator with CAP_SYS_ADMIN can crash the kernel this way without ever starting the server.
nn->nfsd_serv is set when the service is created, which precedes table allocation. NFSD_NET_UP instead brackets the window where the tables are live: set at the end of nfsd_startup_net() and cleared in nfsd_shutdown_net() after they are freed, both under nfsd_mutex. Gating the three unlock paths on NFSD_NET_UP fixes the startup-time NULL dereference while preserving the earlier post-shutdown use-after-free fix.
fs/nfsd/nfs4proc.c +3 -4
@@ -1588,10 +1588,9 @@ static bool nfsd4_copy_on_sb(const struct nfsd4_copy *copy,* @net: net namespace containing the copy operations * @sb: targeted superblock * -* Context: Caller must hold nfsd_mutex with nn->nfsd_serv confirmed -* non-NULL. nfs4_state_destroy_net() frees conf_id_hashtbl -* at server shutdown without clearing the pointer, so a -* walk without these guarantees iterates freed slab memory. +* Context: Caller must hold nfsd_mutex with NFSD_NET_UP set. Outside +* that window nn->conf_id_hashtbl is unallocated or freed, +* so the walk would dereference a NULL or dangling pointer. */ void nfsd4_cancel_copy_by_sb (struct net *net,struct super_block *sb) {
fs/nfsd/nfs4state.c +6 -8
@@ -1946,10 +1946,9 @@ static void revoke_one_stid(struct nfsd_net *nn, struct nfs4_client *clp,* The clients which own the states will subsequently be notified that the * states have been "admin-revoked". * -* Context: Caller must hold nfsd_mutex with nn->nfsd_serv confirmed -* non-NULL. nfs4_state_destroy_net() frees conf_id_hashtbl -* at server shutdown without clearing the pointer, so a -* walk without these guarantees iterates freed slab memory. +* Context: Caller must hold nfsd_mutex with NFSD_NET_UP set. Outside +* that window nn->conf_id_hashtbl is unallocated or freed, +* so the walk would dereference a NULL or dangling pointer. */ void nfsd4_revoke_states (struct nfsd_net *nn,struct super_block *sb) {
@@ -2024,10 +2023,9 @@ static struct nfs4_stid *find_one_export_stid(struct nfs4_client *clp,* Userspace (exportfs -u) sends this after removing the last client * for a path, enabling the underlying filesystem to be unmounted. * -* Context: Caller must hold nfsd_mutex with nn->nfsd_serv confirmed -* non-NULL. nfs4_state_destroy_net() frees conf_id_hashtbl -* at server shutdown without clearing the pointer, so a -* walk without these guarantees iterates freed slab memory. +* Context: Caller must hold nfsd_mutex with NFSD_NET_UP set. Outside +* that window nn->conf_id_hashtbl is unallocated or freed, +* so the walk would dereference a NULL or dangling pointer. */ void nfsd4_revoke_export_states (struct nfsd_net *nn,const struct path *path) {
fs/nfsd/nfsctl.c +3 -3
@@ -299,7 +299,7 @@ static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size) error =nlmsvc_unlock_all_by_sb (path.dentry->d_sb);mutex_lock (&nfsd_mutex); nn =net_generic (netns (file), nfsd_net_id); -if (nn->nfsd_serv) { +if (test_bit (NFSD_NET_UP , &nn->flags)) {nfsd4_cancel_copy_by_sb (netns (file), path.dentry->d_sb);nfsd4_revoke_states (nn, path.dentry->d_sb); }else {
@@ -2424,7 +2424,7 @@ int nfsd_nl_unlock_filesystem_doit(struct sk_buff *skb, error =nlmsvc_unlock_all_by_sb (path.dentry->d_sb);mutex_lock (&nfsd_mutex); -if (nn->nfsd_serv) { +if (test_bit (NFSD_NET_UP , &nn->flags)) {nfsd4_cancel_copy_by_sb (net, path.dentry->d_sb);nfsd4_revoke_states (nn, path.dentry->d_sb); }else {
@@ -2471,7 +2471,7 @@ int nfsd_nl_unlock_export_doit(struct sk_buff *skb, struct genl_info *info)return error;mutex_lock (&nfsd_mutex); -if (nn->nfsd_serv) { +if (test_bit (NFSD_NET_UP , &nn->flags)) {nfsd_file_close_export (net, &path);nfsd4_revoke_export_states (nn, &path); }else
Sasha Levin
maintainerPATCH 1/1 NFSD: Guard admin state-revocation walks with NFSD_NET_UP
From: Chuck Lever <[email protected]>
[ Upstream commit 2f3e6638aebc0ab8afb8b4e9816ea9a1cad85378 ]
Writing to /proc/fs/nfsd/unlock_filesystem, or sending the NFSD_CMD_UNLOCK_FILESYSTEM or NFSD_CMD_UNLOCK_EXPORT netlink command, walks the NFSv4 client hash tables to revoke open state and cancel async COPY operations. All three handlers gate that walk on nn->nfsd_serv, but a listener added via portlist or netlink listener_set sets nn->nfsd_serv before any nfsd thread starts. nfsd_startup_net() has not yet allocated nn->conf_id_hashtbl, so the walkers dereference a NULL table. A local administrator with CAP_SYS_ADMIN can crash the kernel this way without ever starting the server.
nn->nfsd_serv is set when the service is created, which precedes table allocation. NFSD_NET_UP instead brackets the window where the tables are live: set at the end of nfsd_startup_net() and cleared in nfsd_shutdown_net() after they are freed, both under nfsd_mutex. Gating the three unlock paths on NFSD_NET_UP fixes the startup-time NULL dereference while preserving the earlier post-shutdown use-after-free fix.
--- fs/nfsd/nfsctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfsctl.c +1 -1
@@ -301,7 +301,7 @@ static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size) error =nlmsvc_unlock_all_by_sb (path.dentry->d_sb);mutex_lock (&nfsd_mutex); nn =net_generic (netns (file), nfsd_net_id); -if (nn->nfsd_serv) +if (nn->nfsd_net_up)nfsd4_revoke_states (nn, path.dentry->d_sb);else error = -EINVAL ;
Signature · 1 line
2.53.0