From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <cel@kernel.org>, NeilBrown <neilb@ownmail.net>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: linux-nfs@vger.kernel.org,
syzbot+9c7b9c5f6dd1d470b605@syzkaller.appspotmail.com
Subject: Re: [PATCH v1] NFSD: Don't start nfsd threads from a pool_threads write
Date: Fri, 09 Oct 2026 12:50:49 -0400 [thread overview]
Message-ID: <2da460c2585851e2c4de977b5bdb5ea1bd5175a3.camel@kernel.org> (raw)
In-Reply-To: <20261009144017.1284586-1-cel@kernel.org>
On Fri, 2026-10-09 at 10:40 -0400, Chuck Lever wrote:
> Writing to pool_threads calls nfsd_set_nrthreads() directly, which
> starts nfsd threads as soon as a svc_serv exists. A portlist write
> creates the svc_serv without running nfsd_startup_net(), so a
> pool_threads write that follows it starts threads in a namespace
> whose NFSv4 state has not been set up. If the server in that
> namespace has been started and shut down before, the hash table
> pointers in struct nfsd_net still point at memory that
> nfs4_state_destroy_net() freed, and the first EXCHANGE_ID those
> threads handle reads it:
>
> BUG: KASAN: slab-use-after-free in add_to_unconfirmed
> nfsd4_exchange_id
> nfsd4_proc_compound
> nfsd_dispatch
>
> A namespace that has never been started dereferences NULL instead.
>
> write_pool_threads() already starts nothing when no svc_serv exists,
> and its comment documents that only the threads file starts NFS.
> Ignore the thread counts in a pool_threads write while NFSD_NET_UP
> is clear as well, so a pool_threads write never starts threads
> before nfsd_startup_net() has run. The reply still reports the
> current thread count for each pool.
>
> Fixes: 0a7ec37727dc ("nfsd: make unconf_id_hashtbl allocated per net")
> Reported-by: syzbot+9c7b9c5f6dd1d470b605@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=9c7b9c5f6dd1d470b605
> Signed-off-by: Chuck Lever <cel@kernel.org>
> ---
> fs/nfsd/nfsctl.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index 2379b838c028..5a606086b811 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -497,7 +497,8 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
> if (nthreads == NULL)
> goto out_free;
>
> - if (size > 0) {
> + /* Threads started now would run without NFSv4 state. */
> + if (size > 0 && test_bit(NFSD_NET_UP, &nn->flags)) {
> for (i = 0; i < npools; i++) {
> rv = get_int(&mesg, &nthreads[i]);
> if (rv == -ENOENT)
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2026-10-09 16:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 14:40 [PATCH v1] NFSD: Don't start nfsd threads from a pool_threads write Chuck Lever
2026-10-09 16:50 ` Jeff Layton [this message]
2026-10-10 4:33 ` kernel test robot
2026-10-10 17:57 ` Chuck Lever
2026-10-10 6:10 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2da460c2585851e2c4de977b5bdb5ea1bd5175a3.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=cel@kernel.org \
--cc=dai.ngo@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@ownmail.net \
--cc=okorniev@redhat.com \
--cc=syzbot+9c7b9c5f6dd1d470b605@syzkaller.appspotmail.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox