summaryrefslogtreecommitdiff
path: root/drivers/android
diff options
context:
space:
mode:
authorGeorgios Androutsopoulos <georgeandrout13@gmail.com>2026-06-16 13:09:56 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-31 14:15:54 +0200
commit19183c0ef0d73ff3ca7caf8a205edcea922f8c24 (patch)
tree6c0ff98591d70a5d037a5d32b28f501d1997b85e /drivers/android
parente38b0c8141cd9bf28a17259d69b5f3c96c4e6b3e (diff)
rust_binder: add ownership assertion to Node::add_death
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> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260616170956.2580772-1-georgeandrout13@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android')
-rw-r--r--drivers/android/binder/node.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs
index b74ef32b0d94..0a82af14cda3 100644
--- a/drivers/android/binder/node.rs
+++ b/drivers/android/binder/node.rs
@@ -335,6 +335,10 @@ impl Node {
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);
}