]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
nfsd: initialise nfsd_info.mutex early.
authorNeilBrown <neilb@suse.de>
Mon, 24 Jun 2024 23:04:56 +0000 (09:04 +1000)
committerChuck Lever <chuck.lever@oracle.com>
Tue, 25 Jun 2024 14:15:39 +0000 (10:15 -0400)
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 <sourabhjain@linux.ibm.com>
Closes: https://lore.kernel.org/all/c2e9f6de-1ec4-4d3a-b18d-d5a6ec0814a0@linux.ibm.com/
Signed-off-by: NeilBrown <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfsctl.c
fs/nfsd/nfssvc.c

index 533b65057e18efc4537eb4f9d8130ee2df572485..c848ebe5d08f121cff5ffb7b5a64e148194fa960 100644 (file)
@@ -2169,6 +2169,8 @@ static __net_init int nfsd_net_init(struct net *net)
        nn->nfsd_svcstats.program = &nfsd_program;
        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);
index cd9a6a1a9fc8f41ee0e87d31681e00523a6fe836..89d7918de7b1a24a6aceb38fee2ad7a6bd78a7e6 100644 (file)
@@ -672,7 +672,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);