* [PATCH] nfsd: Initialize ssc before laundromat_work to prevent NULL dereference
@ 2025-04-14 14:38 Li Lingfeng
2025-04-14 17:29 ` cel
2025-04-14 17:42 ` Jeff Layton
0 siblings, 2 replies; 3+ messages in thread
From: Li Lingfeng @ 2025-04-14 14:38 UTC (permalink / raw)
To: chuck.lever, jlayton, neilb, neil, okorniev, Dai.Ngo, tom
Cc: linux-nfs, linux-kernel, yukuai1, houtao1, yi.zhang, yangerkun,
lilingfeng, lilingfeng3
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.")
Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
---
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 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;
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] nfsd: Initialize ssc before laundromat_work to prevent NULL dereference
2025-04-14 14:38 [PATCH] nfsd: Initialize ssc before laundromat_work to prevent NULL dereference Li Lingfeng
@ 2025-04-14 17:29 ` cel
2025-04-14 17:42 ` Jeff Layton
1 sibling, 0 replies; 3+ messages in thread
From: cel @ 2025-04-14 17:29 UTC (permalink / raw)
To: jlayton, neil, okorniev, Dai.Ngo, tom, Li Lingfeng
Cc: Chuck Lever, linux-nfs, linux-kernel, yukuai1, houtao1, yi.zhang,
yangerkun, lilingfeng
From: Chuck Lever <chuck.lever@oracle.com>
On Mon, 14 Apr 2025 22:38:52 +0800, Li Lingfeng wrote:
> 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.
>
> [...]
Applied to nfsd-testing, thanks!
[1/1] nfsd: Initialize ssc before laundromat_work to prevent NULL dereference
commit: 05d68df60b9af7765c38073ff117169aa5f52310
--
Chuck Lever
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] nfsd: Initialize ssc before laundromat_work to prevent NULL dereference
2025-04-14 14:38 [PATCH] nfsd: Initialize ssc before laundromat_work to prevent NULL dereference Li Lingfeng
2025-04-14 17:29 ` cel
@ 2025-04-14 17:42 ` Jeff Layton
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2025-04-14 17:42 UTC (permalink / raw)
To: Li Lingfeng, chuck.lever, neilb, neil, okorniev, Dai.Ngo, tom
Cc: linux-nfs, linux-kernel, yukuai1, houtao1, yi.zhang, yangerkun,
lilingfeng
On Mon, 2025-04-14 at 22:38 +0800, Li Lingfeng wrote:
> 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.")
> Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
> ---
> 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 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;
>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-14 17:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-14 14:38 [PATCH] nfsd: Initialize ssc before laundromat_work to prevent NULL dereference Li Lingfeng
2025-04-14 17:29 ` cel
2025-04-14 17:42 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox