From nobody Fri Dec 19 14:36:10 2025 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98EB0253947; Mon, 14 Apr 2025 14:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744640373; cv=none; b=uVV8Xxjyuxs/qrtjb64gPTppZaJsWwrvB9EO4IKpMIx2FzOV9EMrXUwtqO36p2RgYaF8mL0pXWBBjNlfsH6vBOVvlR1o557ii9zhdkKiAqcIpaRbxqH7pESDl77TY/jhlq9Eh7hxe2ZqVZdNQK2K3ofjt2Hp8yBKO7KsoivpZwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744640373; c=relaxed/simple; bh=q7jbEhr50P4j5cB6h/OjmIXHLzxIFXaZIyKktMb1zRM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=tr/B82WLPgVzD6BMcpomNo23zyYIr1W9JoqKp6V8tgoaR+uAjIJFg/1XIlHCVlvOUW0zNXvz8Dv+fpdYhuFBOfRxeJ/3MBtrXIOmhnFqd6vgz1ZsnobTwzh4nxp+dKv13HVvYuTDGgowwvp+tEOOeid+ZrMuUGvU6gx7FFVkxNA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4ZbqD939GlzsSLB; Mon, 14 Apr 2025 22:19:21 +0800 (CST) Received: from kwepemg500017.china.huawei.com (unknown [7.202.181.81]) by mail.maildlp.com (Postfix) with ESMTPS id 5C3C01400D4; Mon, 14 Apr 2025 22:19:27 +0800 (CST) Received: from huawei.com (10.175.127.227) by kwepemg500017.china.huawei.com (7.202.181.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 14 Apr 2025 22:19:26 +0800 From: Li Lingfeng To: , , , , , , CC: , , , , , , , Subject: [PATCH] nfsd: Initialize ssc before laundromat_work to prevent NULL dereference Date: Mon, 14 Apr 2025 22:38:52 +0800 Message-ID: <20250414143852.1308979-1-lilingfeng3@huawei.com> X-Mailer: git-send-email 2.31.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemg500017.china.huawei.com (7.202.181.81) Content-Type: text/plain; charset="utf-8" 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-serve= r copy completed.") Signed-off-by: Li Lingfeng Reviewed-by: Jeff Layton --- fs/nfsd/nfssvc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 9b3d6cff0e1e..8ed143ef8b41 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -396,13 +396,13 @@ static int nfsd_startup_net(struct net *net, const st= ruct cred *cred) if (ret) goto out_filecache; =20 +#ifdef CONFIG_NFSD_V4_2_INTER_SSC + nfsd4_ssc_init_umount_work(nn); +#endif ret =3D nfs4_state_start_net(net); if (ret) goto out_reply_cache; =20 -#ifdef CONFIG_NFSD_V4_2_INTER_SSC - nfsd4_ssc_init_umount_work(nn); -#endif nn->nfsd_net_up =3D true; return 0; =20 --=20 2.31.1