From: Georgios Androutsopoulos <georgeandrout13@gmail.com>
To: gregkh@linuxfoundation.org, cmllamas@google.com, aliceryhl@google.com
Cc: arve@android.com, tkjos@android.com, brauner@kernel.org,
ojeda@kernel.org, boqun.feng@gmail.com, gary@garyguo.net,
bjorn3_gh@protonmail.com, lossin@kernel.org,
a.hindborg@kernel.org, tmgross@umich.edu, dakr@kernel.org,
paul@paul-moore.com, work@onurozkan.dev,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
Georgios Androutsopoulos <georgeandrout13@gmail.com>
Subject: [PATCH v3] rust_binder: add ownership assertion to Node::add_death
Date: Tue, 16 Jun 2026 13:09:56 -0400 [thread overview]
Message-ID: <20260616170956.2580772-1-georgeandrout13@gmail.com> (raw)
In-Reply-To: <20260610133241.374115-1-georgeandrout13@gmail.com>
The `// SAFETY:` comment in NodeDeath::set_cleared assumes that a
NodeDeath is never inserted into the death list of any Node other than
its owner. However, this invariant is not enforced by the safe function
Node::add_death, which inserts NodeDeath into the death list without
checking that death.node == self, leaving a risk for future code that
may miss this implicit invariant and cause undefined behavior.
Add an assertion to make this precondition explicit and catch potential
violations early.
Link: https://github.com/Rust-for-Linux/linux/issues/1237
Signed-off-by: Georgios Androutsopoulos <georgeandrout13@gmail.com>
---
Changes in v3:
- Reverted to assert!() following feedback from Alice Ryhl.
Link to v2: https://lore.kernel.org/rust-for-linux/20260610133241.374115-1-georgeandrout13@gmail.com/
---
drivers/android/binder/node.rs | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs
index 69f757ff7461..20eaaefbd4cc 100644
--- a/drivers/android/binder/node.rs
+++ b/drivers/android/binder/node.rs
@@ -333,6 +333,10 @@ pub(crate) fn add_death(
death: ListArc<DTRWrap<NodeDeath>, 1>,
guard: &mut Guard<'_, ProcessInner, SpinLockBackend>,
) {
+ assert!(
+ core::ptr::eq(self, &**death.node),
+ "attempt to add NodeDeath to the wrong death list"
+ );
self.inner.access_mut(guard).death_list.push_back(death);
}
--
2.47.3
prev parent reply other threads:[~2026-06-16 17:10 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 3:55 [PATCH] rust_binder: add ownership assertion to Node::add_death Georgios Androutsopoulos
2026-06-10 5:45 ` Onur Özkan
2026-06-10 6:07 ` Miguel Ojeda
2026-06-10 13:39 ` Gary Guo
2026-06-11 8:15 ` Miguel Ojeda
2026-06-11 10:31 ` Gary Guo
2026-06-11 13:22 ` Miguel Ojeda
2026-06-10 13:32 ` [PATCH v2] " Georgios Androutsopoulos
2026-06-10 14:21 ` Miguel Ojeda
2026-06-11 7:42 ` Alice Ryhl
2026-06-11 22:26 ` George Androutsopoulos
2026-06-16 7:12 ` Alice Ryhl
2026-06-16 17:09 ` Georgios Androutsopoulos [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=20260616170956.2580772-1-georgeandrout13@gmail.com \
--to=georgeandrout13@gmail.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=arve@android.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=paul@paul-moore.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=tkjos@android.com \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.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