From 6ae1603662f680b37b53c6bbcd127f3d93294932 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 12 Jul 2024 20:42:00 +0200 Subject: [PATCH] nfsd: initialise nfsd_info.mutex early. BugLink: https://bugs.launchpad.net/bugs/2070358 nfsd_info.mutex can be dereferenced by svc_pool_stats_start() immediately after the new netns is created. Currently this can trigger an oops. Move the initialisation earlier before it can possibly be dereferenced. Fixes: 7b207ccd9833 ("svc: don't hold reference for poolstats, only mutex.") Reported-by: Sourabh Jain Closes: https://lore.kernel.org/all/c2e9f6de-1ec4-4d3a-b18d-d5a6ec0814a0@linux.ibm.com/ Signed-off-by: NeilBrown Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever (cherry picked from commit e0011bca603c101f2a3c007bdb77f7006fa78fb1) Signed-off-by: Patricia Domingues Acked-by: Kevin Becker Acked-by: Manuel Diewald Signed-off-by: Stefan Bader Signed-off-by: Roxana Nicolescu --- fs/nfsd/nfsctl.c | 2 ++ fs/nfsd/nfssvc.c | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index d8f54eb7455e..16b7de26d5b6 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1676,6 +1676,8 @@ static __net_init int nfsd_net_init(struct net *net) goto out_repcache_error; nn->nfsd_versions = NULL; nn->nfsd4_minorversions = NULL; + nn->nfsd_info.mutex = &nfsd_mutex; + nn->nfsd_serv = NULL; nfsd4_init_leases_net(nn); get_random_bytes(&nn->siphash_key, sizeof(nn->siphash_key)); seqlock_init(&nn->writeverf_lock); diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index a667802e08e7..3cff673bfed8 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -677,7 +677,6 @@ int nfsd_create_serv(struct net *net) return error; } spin_lock(&nfsd_notifier_lock); - nn->nfsd_info.mutex = &nfsd_mutex; nn->nfsd_serv = serv; spin_unlock(&nfsd_notifier_lock);