]> www.infradead.org Git - users/hch/misc.git/commitdiff
nfsd: Initialize ssc before laundromat_work to prevent NULL dereference
authorLi Lingfeng <lilingfeng3@huawei.com>
Mon, 14 Apr 2025 14:38:52 +0000 (22:38 +0800)
committerChuck Lever <chuck.lever@oracle.com>
Sun, 11 May 2025 23:48:27 +0000 (19:48 -0400)
In nfs4_state_start_net(), laundromat_work may access nfsd_ssc through
nfs4_laundromat -> nfsd4_ssc_expire_umount. If nfsd_ssc isn't initialized,
this can cause NULL pointer dereference.

Normally the delayed start of laundromat_work allows sufficient time for
nfsd_ssc initialization to complete. However, when the kernel waits too
long for userspace responses (e.g. in nfs4_state_start_net ->
nfsd4_end_grace -> nfsd4_record_grace_done -> nfsd4_cld_grace_done ->
cld_pipe_upcall -> __cld_pipe_upcall -> wait_for_completion path), the
delayed work may start before nfsd_ssc initialization finishes.

Fix this by moving nfsd_ssc initialization before starting laundromat_work.

Fixes: f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")
Cc: stable@vger.kernel.org
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfssvc.c

index 9b3d6cff0e1e248f0b9cae9f4557c22a7cec165c..8ed143ef8b41153554f9b8dc6666eb4c60b06577 100644 (file)
@@ -396,13 +396,13 @@ static int nfsd_startup_net(struct net *net, const struct cred *cred)
        if (ret)
                goto out_filecache;
 
+#ifdef CONFIG_NFSD_V4_2_INTER_SSC
+       nfsd4_ssc_init_umount_work(nn);
+#endif
        ret = nfs4_state_start_net(net);
        if (ret)
                goto out_reply_cache;
 
-#ifdef CONFIG_NFSD_V4_2_INTER_SSC
-       nfsd4_ssc_init_umount_work(nn);
-#endif
        nn->nfsd_net_up = true;
        return 0;