rcutorture: Fix busted_srcud crash on module unload
Subsystems (2)
PATCH 1/1 rcutorture: Fix busted_srcud crash on module unload
From: Fu Wenxin <[email protected]>
Commit e4ed20c1603c ("rcutorture: Exercise DEFINE_STATIC_SRCU_FAST() and init_srcu_struct_fast()") split SRCU torture initialization into two
helpers: srcu_torture_init(), which now only points srcu_ctlp at the static srcu_ctl/srcu_ctlf/srcu_ctlfud structures, and the new srcud_torture_init(), which calls init_srcu_struct(&srcu_ctld) for the dynamically allocated srcu_ctld.
That commit updated srcud_ops to use srcud_torture_init(), but left busted_srcud_ops pairing .init = srcu_torture_init (static srcu_ctl) with .cleanup = srcu_torture_cleanup (which unconditionally calls cleanup_srcu_struct(&srcu_ctld)). As a result srcu_ctld is never initialized when running torture_type=busted_srcud, yet it is torn down at module unload.
cleanup_srcu_struct() then dereferences ssp->srcu_sup, which is still NULL for the zero-initialized srcu_ctld, and faults on the ->lock field accessed by raw_spin_lock_irq_rcu_node():
Unable to handle kernel paging request at virtual address dfff80000000001b ... el1_abort -> do_translation_fault -> do_bad_area -> die_kernel_fault
(The fault address is the KASAN shadow of NULL + offsetof(srcu_usage, lock) == 0xd8.)
This is trivially reproducible:
modprobe rcutorture torture_type=busted_srcud
sleep 45
rmmod rcutorture # panic here
Fix it by making busted_srcud_ops initialize the same srcu_ctld that its cleanup handler tears down, matching srcud_ops.
--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +1 -1
@@ -991,7 +991,7 @@ static struct rcu_torture_ops srcud_ops = {/* As above, but broken due to inappropriate reader extension. */ static struct rcu_torture_ops busted_srcud_ops = { .ttype =SRCU_FLAVOR , - .init = srcu_torture_init, + .init = srcud_torture_init, .cleanup = srcu_torture_cleanup, .readlock = srcu_torture_read_lock, .read_delay = rcu_read_delay,
Signature · 1 line
2.43.7
Quoted 37 lines · On Oct 18, 2026, at 10:36 PM, [email protected] wrote:
From: Fu Wenxin <[email protected]>
Commit
e4ed20c1603c("rcutorture: ExerciseDEFINE_STATIC_SRCU_FAST()andinit_srcu_struct_fast()") split SRCU torture initialization into two
helpers:srcu_torture_init(), which now only pointssrcu_ctlpat the static srcu_ctl/srcu_ctlf/srcu_ctlfud structures, and the newsrcud_torture_init(), which callsinit_srcu_struct(&srcu_ctld)for the dynamically allocatedsrcu_ctld.That commit updated
srcud_opsto usesrcud_torture_init(), but leftbusted_srcud_opspairing .init =srcu_torture_init(staticsrcu_ctl) with .cleanup =srcu_torture_cleanup(which unconditionally callscleanup_srcu_struct(&srcu_ctld)). As a resultsrcu_ctldis never initialized when running torture_type=busted_srcud, yet it is torn down at module unload.
cleanup_srcu_struct()then dereferencesssp->srcu_sup, which is still NULL for the zero-initializedsrcu_ctld, and faults on the ->lock field accessed byraw_spin_lock_irq_rcu_node():Unable to handle kernel paging request at virtual address dfff80000000001b ... el1_abort -> do_translation_fault -> do_bad_area -> die_kernel_fault(The fault address is the KASAN shadow of NULL +
offsetof(srcu_usage, lock)==0xd8.)This is trivially reproducible:
modprobe rcutorture torture_type=busted_srcud
sleep 45
rmmod rcutorture # panic here
Quoted 5 lines
Fix it by making
busted_srcud_opsinitialize the samesrcu_ctldthat its cleanup handler tears down, matchingsrcud_ops.Fixes e4ed20c1603c ("rcutorture: Exercise DEFINE_STATIC_SRCU_FAST() and init_srcu_struct_fast()")Signed-off-by Fu Wenxin <[email protected]>
Applying for 7.5, thanks.
Quoted 20 lines
---
kernel/rcu/rcutorture.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcutorture.c +1
-2@@ -991,7 +991,7 @@ static struct rcu_torture_ops srcud_ops = {/* As above, but broken due to inappropriate reader extension. */ static struct rcu_torture_ops busted_srcud_ops = { .ttype =SRCU_FLAVOR , - .init = srcu_torture_init, + .init = srcud_torture_init, .cleanup = srcu_torture_cleanup, .readlock = srcu_torture_read_lock, .read_delay = rcu_read_delay, --2.43.7
Quoted 29 lines · On 19 October 2026 03:36:44 BST, [email protected] wrote:
From: Fu Wenxin <[email protected]>
Commit
e4ed20c1603c("rcutorture: ExerciseDEFINE_STATIC_SRCU_FAST()andinit_srcu_struct_fast()") split SRCU torture initialization into two
helpers:srcu_torture_init(), which now only pointssrcu_ctlpat the static srcu_ctl/srcu_ctlf/srcu_ctlfud structures, and the newsrcud_torture_init(), which callsinit_srcu_struct(&srcu_ctld)for the dynamically allocatedsrcu_ctld.That commit updated
srcud_opsto usesrcud_torture_init(), but leftbusted_srcud_opspairing .init =srcu_torture_init(staticsrcu_ctl) with .cleanup =srcu_torture_cleanup(which unconditionally callscleanup_srcu_struct(&srcu_ctld)). As a resultsrcu_ctldis never initialized when running torture_type=busted_srcud, yet it is torn down at module unload.
cleanup_srcu_struct()then dereferencesssp->srcu_sup, which is still NULL for the zero-initializedsrcu_ctld, and faults on the ->lock field accessed byraw_spin_lock_irq_rcu_node():Unable to handle kernel paging request at virtual address dfff80000000001b ... el1_abort -> do_translation_fault -> do_bad_area -> die_kernel_fault(The fault address is the KASAN shadow of NULL +
offsetof(srcu_usage, lock)==0xd8.)This is trivially reproducible:
Quoted 8 lines
modprobe rcutorture torture_type=busted_srcud
sleep 45
rmmod rcutorture # panic hereFix it by making
busted_srcud_opsinitialize the samesrcu_ctldthat its cleanup handler tears down, matchingsrcud_ops.Fixes e4ed20c1603c ("rcutorture: Exercise DEFINE_STATIC_SRCU_FAST() and init_srcu_struct_fast()")
Nice catch! I reproduced this bug on my PowerPC host:
Quoted 11 lines
Signed-off-by Fu Wenxin <[email protected]>---
kernel/rcu/rcutorture.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)kernel/rcu/rcutorture.c +0
-0
kernel/rcu/rcutorture.c static struct rcu_torture_ops srcud_ops = { · line 997
Quoted 8 lines
kernel/rcu/rcutorture.c +1
-1@@ -991,7 +991,7 @@ static struct rcu_torture_ops srcud_ops = {/* As above, but broken due to inappropriate reader extension. */ static struct rcu_torture_ops busted_srcud_ops = { .ttype =SRCU_FLAVOR , - .init = srcu_torture_init, + .init = srcud_torture_init, .cleanup = srcu_torture_cleanup, .readlock = srcu_torture_read_lock, .read_delay = rcu_read_delay,
--- Thanks!
"I'm not a very positive person" - Linus torvalds