mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bradley Morgan <brads@mainlining.org>
To: fuwenxin@linux.alibaba.com
Cc: boqun@kernel.org, dave@stgolabs.net, frederic@kernel.org,
	jiangshanlai@gmail.com, joelagnelf@nvidia.com,
	josh@joshtriplett.org, linux-kernel@vger.kernel.org,
	mathieu.desnoyers@efficios.com, neeraj.upadhyay@kernel.org,
	oliver.yang@linux.alibaba.com, paulmck@kernel.org,
	qiang.zhang@linux.dev, rcu@vger.kernel.org, rostedt@goodmis.org,
	urezki@gmail.com, xlpang@linux.alibaba.com
Subject: Re: [PATCH] rcutorture: Fix busted_srcud crash on module unload
Date: Mon, 19 Oct 2026 07:29:31 +0100	[thread overview]
Message-ID: <C98A2196-D74E-4BB5-9B24-DE0B91D6973E@mainlining.org> (raw)
In-Reply-To: <20261019023644.2750352-1-fuwenxin@linux.alibaba.com>

On 19 October 2026 03:36:44 BST, fuwenxin@linux.alibaba.com wrote:
>From: Fu Wenxin <fuwenxin@linux.alibaba.com>
>
>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.
>
>Fixes: e4ed20c1603c ("rcutorture: Exercise DEFINE_STATIC_SRCU_FAST() and init_srcu_struct_fast()")

Nice catch! I reproduced this bug on my PowerPC host:

Reviewed-by: Bradley Morgan <brads@mainlining.org>

Tested-by: Bradley Morgan <brads@mainlining.org> # Power10

>Signed-off-by: Fu Wenxin <fuwenxin@linux.alibaba.com>
>---
> kernel/rcu/rcutorture.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
>index 8a9282a0245cc..7cc78da1356f9 100644
>--- a/kernel/rcu/rcutorture.c
>+++ b/kernel/rcu/rcutorture.c
>@@ -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

      parent reply	other threads:[~2026-10-19  6:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19  2:36 fuwenxin
2026-10-19  6:01 ` Joel Fernandes
2026-10-19  6:29 ` Bradley Morgan [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C98A2196-D74E-4BB5-9B24-DE0B91D6973E@mainlining.org \
    --to=brads@mainlining.org \
    --cc=boqun@kernel.org \
    --cc=dave@stgolabs.net \
    --cc=frederic@kernel.org \
    --cc=fuwenxin@linux.alibaba.com \
    --cc=jiangshanlai@gmail.com \
    --cc=joelagnelf@nvidia.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=oliver.yang@linux.alibaba.com \
    --cc=paulmck@kernel.org \
    --cc=qiang.zhang@linux.dev \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=urezki@gmail.com \
    --cc=xlpang@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®