From: Uladzislau Rezki <urezki@gmail.com>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Uladzislau Rezki <urezki@gmail.com>,
Kent Overstreet <kent.overstreet@linux.dev>,
"Paul E. McKenney" <paulmck@kernel.org>,
syzbot <syzbot+80e5d6f453f14a53383a@syzkaller.appspotmail.com>,
akpm@linux-foundation.org, josh@joshtriplett.org,
linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, rcu@vger.kernel.org,
syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [rcu?] [bcachefs?] BUG: unable to handle kernel NULL pointer dereference in rcu_core (3)
Date: Tue, 10 Jun 2025 14:33:19 +0200 [thread overview]
Message-ID: <aEgmD6POgqn-jUH1@pc636> (raw)
In-Reply-To: <13d5ecd9-3e9f-4593-b300-9141941a29cb@suse.cz>
On Mon, Jun 09, 2025 at 08:28:56PM +0200, Vlastimil Babka wrote:
> On 6/8/25 20:23, Uladzislau Rezki wrote:
> > On Sun, Jun 08, 2025 at 11:26:28AM -0400, Kent Overstreet wrote:
> >>
> >> I don't think it's that - syzbot's .config already has that enabled.
> >> KASAN, too.
> >>
> >> And the only place we do call_rcu() is from rcu_pending.c, where we've
> >> got a rearming rcu callback - but we track whether it's outstanding, and
> >> we do all relevant operations with a lock held.
> >>
> >> And we only use rcu_pending.c with SRCU, not regular RCU.
> >>
> >> We do use kfree_rcu() in a few places (all boring, I expect), but that
> >> doesn't (generally?) use the rcu callback list.
> >>
> > Right, kvfree_rcu() does not intersect with regular callbacks, it has
> > its own path.
>
> You mean do to the batching? Maybe the batching should be disabled with
> CONFIG_DEBUG_OBJECTS_RCU_HEAD=y if it prevents it from detecting issues?
> Otherwise we now have kvfree_rcu_cb() so the special handling of
> kvfree_rcu() is gone in in the non-batching case.
>
Not really. I meant that in a call_rcu() API there is no any check if
a passed callback which is executed after GP is NULL. If so, we get the
bug about about dereferencing of NULL pointer.
Since it is invoked by the rcu_core() context, we can not identify the
caller in order to blame someone :)
As for batching, we have a support of CONFIG_DEBUG_OBJECTS_RCU_HEAD. It
helps to identify double-freeing and probably leaking.
> > It looks like the problem is here:
> >
> > <snip>
> > f = rhp->func;
> > debug_rcu_head_callback(rhp);
> > WRITE_ONCE(rhp->func, (rcu_callback_t)0L);
> > f(rhp);
> > <snip>
> >
> > we do not check if callback, "f", is a NULL. If it is, the kernel bug
> > is triggered right away. For example:
> >
> > call_rcu(&rh, NULL);
> >
> > @Paul, do you think it makes sense to narrow callers which apparently
> > pass NULL as a callback? To me it seems the case of this bug. But we
> > do not know the source.
> >
> > It would give at least a stack-trace of caller which passes a NULL.
>
> Right, AFAIU this kind of check is now possible, previously NULL was being
> interpreted as a valid __is_kvfree_rcu_offset() (i.e. rcu_head at offset 0).
>
> > --
> > Uladzislau Rezki
> >
>
next prev parent reply other threads:[~2025-06-10 12:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 0:34 [syzbot] [rcu?] [bcachefs?] BUG: unable to handle kernel NULL pointer dereference in rcu_core (3) syzbot
2025-02-05 14:56 ` Paul E. McKenney
2025-06-08 15:26 ` Kent Overstreet
2025-06-08 18:23 ` Uladzislau Rezki
2025-06-09 0:25 ` Paul E. McKenney
2025-06-09 8:35 ` Uladzislau Rezki
2025-06-09 9:47 ` Paul E. McKenney
2025-06-09 14:20 ` Joel Fernandes
2025-06-10 12:19 ` Uladzislau Rezki
2025-06-09 18:28 ` Vlastimil Babka
2025-06-10 12:33 ` Uladzislau Rezki [this message]
2025-06-08 6:58 ` [syzbot] [bcachefs?] [rcu?] " syzbot
2025-06-11 15:58 ` [syzbot] [rcu?] [bcachefs?] " Uladzislau Rezki
2025-06-11 18:02 ` [syzbot] [bcachefs?] [rcu?] " syzbot
2025-06-11 19:15 ` Uladzislau Rezki
2025-06-11 19:57 ` syzbot
2025-06-11 20:58 ` Boqun Feng
2025-06-12 7:42 ` Aleksandr Nogikh
2025-06-12 9:37 ` Uladzislau Rezki
2025-06-12 17:20 ` Boqun Feng
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=aEgmD6POgqn-jUH1@pc636 \
--to=urezki@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=josh@joshtriplett.org \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=paulmck@kernel.org \
--cc=rcu@vger.kernel.org \
--cc=syzbot+80e5d6f453f14a53383a@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=vbabka@suse.cz \
/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;
as well as URLs for NNTP newsgroup(s).