[PATCH 1/5] rust_binder: read u64 pointer in BC_FREE_BUFFER

From: Alice Ryhl

Date: Thu Nov 26 2026 - 04:54:04 EST


On 32-bit kernels, BC_FREE_BUFFER reads a usize instead of a 64-bit
binder_uintptr_t from userspace. This desynchronizes the command stream
and misinterprets the remaining bytes, causing subsequent commands to
fail or leaking the buffer. Thus, read a u64 pointer on all platforms.

To match legacy C Binder behavior, out of range pointer values are
ignored, rather than reported as an error.

Cc: stable@xxxxxxxxxxxxxxx
Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
---
drivers/android/binder/process.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index e97213250beb..f23dbe98d688 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -1125,7 +1125,8 @@ pub(crate) fn buffer_alloc(
Ok(NewAllocation(res))
}

- pub(crate) fn buffer_get(self: &Arc<Self>, ptr: usize) -> Option<Allocation> {
+ pub(crate) fn buffer_get(self: &Arc<Self>, ptr: u64) -> Option<Allocation> {
+ let ptr = usize::try_from(ptr).ok()?;
let mut inner = self.inner.lock();
let mapping = inner.mapping.as_mut()?;
let offset = ptr.checked_sub(mapping.address)?;

--
2.56.1.839.g22a8290db9-goog