Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] rust_binder: add ownership assertion to Node::add_death
@ 2026-06-10  3:55 Georgios Androutsopoulos
  2026-06-10  5:45 ` Onur Özkan
  2026-06-10 13:32 ` [PATCH v2] " Georgios Androutsopoulos
  0 siblings, 2 replies; 9+ messages in thread
From: Georgios Androutsopoulos @ 2026-06-10  3:55 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Carlos Llamas, Alice Ryhl
  Cc: Arve Hjønnevåg, Todd Kjos, Christian Brauner,
	Miguel Ojeda, Boqun Feng, Gary Guo, Björn Roy Baron,
	Benno Lossin, Andreas Hindborg, Trevor Gross, Danilo Krummrich,
	Paul Moore, linux-kernel, rust-for-linux,
	Georgios Androutsopoulos

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>
---
 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);
     }
 

base-commit: 287afdc7671a03081f48f3407bc59862c202bd4b
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-06-11 10:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-10 13:32 ` [PATCH v2] " Georgios Androutsopoulos
2026-06-10 14:21   ` Miguel Ojeda
2026-06-11  7:42   ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox