mirror of
https://github.com/torvalds/linux.git
synced 2026-09-25 17:42:03 +02:00
nfsd: initialize DRC hash table before registering shrinker
shrinker_register() precedes the INIT_LIST_HEAD loop and the
drc_hashsize store. On weakly-ordered architectures (arm64, ppc),
a shrinker scan can observe drc_hashsize before the bucket list
heads are initialized, causing a NULL deref in the DRC shrinker
callback.
Move bucket initialization and the drc_hashsize store before
shrinker_register() so the hash table is fully initialized before
it becomes visible to the shrinker.
Fixes: 8eea99a81c ("nfsd: dynamically allocate the nfsd-reply shrinker")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260611-nfsd-testing-v2-18-5b90e276f2d9@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
parent
2c390c8a17
commit
b0c58934f5
|
|
@ -200,14 +200,14 @@ int nfsd_reply_cache_init(struct nfsd_net *nn)
|
|||
nn->nfsd_reply_cache_shrinker->seeks = 1;
|
||||
nn->nfsd_reply_cache_shrinker->private_data = nn;
|
||||
|
||||
shrinker_register(nn->nfsd_reply_cache_shrinker);
|
||||
|
||||
for (i = 0; i < hashsize; i++) {
|
||||
INIT_LIST_HEAD(&nn->drc_hashtbl[i].lru_head);
|
||||
spin_lock_init(&nn->drc_hashtbl[i].cache_lock);
|
||||
}
|
||||
nn->drc_hashsize = hashsize;
|
||||
|
||||
shrinker_register(nn->nfsd_reply_cache_shrinker);
|
||||
|
||||
return 0;
|
||||
out_shrinker:
|
||||
kvfree(nn->drc_hashtbl);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user