From: Alice Ryhl <aliceryhl@google.com>
To: Bilal Hashim <AeeSec@126.com>
Cc: Alice Ryhl <aliceryhl@google.com>,
Miguel Ojeda <ojeda@kernel.org>, Boqun Feng <boqun@kernel.org>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: rbtree: call rb_erase() before KBox::from_raw() in remove_current()
Date: Tue, 1 Dec 2026 13:50:15 +0000 [thread overview]
Message-ID: <20261201135015.2200077-1-aliceryhl@google.com> (raw)
In-Reply-To: <20261127120553.1233-1-AeeSec@126.com>
On Fri, Nov 27, 2026 at 08:05:53PM +0800, Bilal Hashim wrote:
> In CursorMut::remove_current(), KBox::from_raw(this) is currently called
> before bindings::rb_erase(&mut (*this).links, ...). Constructing and
> moving a KBox asserts exclusive (noalias) ownership over the allocation,
> which invalidates the raw pointer `this` and aliases with the subsequent
> bindings::rb_erase() call that mutates the rb_node links in C.
>
> Move bindings::rb_erase() before KBox::from_raw(this), matching the order
> already used in CursorMut::remove_neighbor().
>
> Tested with LLVM=-22 and Rust KUnit doctests in QEMU (372/372 passed,
> including all 11 rbtree doctests).
>
> Signed-off-by: Bilal Hashim <AeeSec@126.com>
Note that `KBox` doesn't actually emit `noalias` today, but it is of
course still semantically wrong.
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Alice
prev parent reply other threads:[~2026-12-01 13:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 12:05 Bilal Hashim
2026-12-01 13:50 ` Alice Ryhl [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=20261201135015.2200077-1-aliceryhl@google.com \
--to=aliceryhl@google.com \
--cc=AeeSec@126.com \
--cc=boqun@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
/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®