From: Boqun Feng <boqun@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: ojeda@kernel.org, dri-devel@lists.freedesktop.org,
linux-media@vger.kernel.org
Subject: Re: [PATCH 1/3] rust: rcu: add RcuBox type
Date: Fri, 5 Jun 2026 06:58:28 -0700 [thread overview]
Message-ID: <aiLWBAE23BtXzVIU@tardis-2.local> (raw)
In-Reply-To: <20260605134935.B6C0E1F00893@smtp.kernel.org>
On Fri, Jun 05, 2026 at 01:49:35PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Critical] RcuBox::into_foreign drops `self` instead of forgetting it, causing a guaranteed Use-After-Free.
> - [High] RcuBox::drop bypasses the custom Allocator A and hardcodes kvfree_call_rcu() for types that do not require dropping, causing undefined behavior for non-kvfree compatible allocators.
> --
>
[...]
> > +
> > + unsafe fn from_foreign(ptr: *mut c_void) -> Self {
>
> [ ... ]
>
> > +impl<T: Send, A: Allocator> Drop for RcuBox<T, A> {
> > + fn drop(&mut self) {
> > + // SAFETY: The `rcu_head` field is in-bounds of a valid allocation.
> > + let rcu_head = unsafe { &raw mut (*self.0.as_ptr()).rcu_head };
> > + if core::mem::needs_drop::<T>() {
> > + // SAFETY: `rcu_head` is the `rcu_head` field of `RcuBoxInner<T>`. All users will be
> > + // gone in an rcu grace period. This is the destructor, so we may pass ownership of the
> > + // allocation.
> > + unsafe { bindings::call_rcu(rcu_head, Some(drop_rcu_box::<T, A>)) };
> > + } else {
> > + // SAFETY: All users will be gone in an rcu grace period.
> > + // TODO: We are luckily since `kvfree_call_rcu()` works on both kmalloc and vmalloc,
> > + // maybe a new `Allocator` method is needed.
> > + unsafe { bindings::kvfree_call_rcu(rcu_head, self.0.as_ptr().cast()) };
>
> [Severity: High]
> Since `RcuBox` is generic over any custom `A: Allocator`, wouldn't calling
> `kvfree_call_rcu()` here break for allocators other than kmalloc or vmalloc?
>
> Does this need to always route through `A::free()` via `drop_rcu_box`, or
> should `A` be explicitly bounded to an allocator trait that supports
> `kvfree_rcu`?
>
There is a "TODO" here to describe why currently kvfree_call_rcu() is
fine, is this a real issue in the current code base?
Regards,
Boqun
> > + }
> > + }
> > +}
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20260605133541.22569-1-boqun@kernel.org?part=1
next prev parent reply other threads:[~2026-06-05 13:58 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-05 13:35 [PATCH 0/3] rust: sync: Introduce Rcu*Box Boqun Feng
2026-06-05 13:35 ` [PATCH 1/3] rust: rcu: add RcuBox type Boqun Feng
2026-06-05 13:38 ` Boqun Feng
2026-06-05 13:49 ` sashiko-bot
2026-06-05 13:58 ` Boqun Feng [this message]
2026-06-05 14:41 ` Boqun Feng
2026-06-05 14:54 ` Alice Ryhl
2026-06-05 15:33 ` Boqun Feng
2026-06-05 13:35 ` [PATCH 1/3] rust: rcu: Add " Boqun Feng
2026-06-05 13:35 ` [PATCH 2/3] rust: maple_tree: add load_rcu() Boqun Feng
2026-06-05 13:38 ` Boqun Feng
2026-06-05 13:51 ` sashiko-bot
2026-06-05 13:35 ` [PATCH 2/3] rust: maple_tree: Add load_rcu() Boqun Feng
2026-07-15 14:09 ` Alice Ryhl
2026-06-05 13:35 ` [RFC PATCH 3/3] rust: rcu: Introduce RcuFreeBox Boqun Feng
2026-06-05 13:46 ` sashiko-bot
2026-06-05 14:04 ` Alice Ryhl
2026-06-05 14:20 ` Boqun Feng
2026-06-05 14:54 ` Alice Ryhl
2026-06-05 14:04 ` 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=aiLWBAE23BtXzVIU@tardis-2.local \
--to=boqun@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-media@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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