[PATCH] rust_binder: disallow binder fd transfers
From: Carlos Llamas
Date: Tue Nov 17 2026 - 18:19:43 EST
Transferring a binder device fd via BINDER_TYPE_FD or BINDER_TYPE_FDA
has no valid use case and can create direct reference cycles that
prevent Process::release() from running when a queued transaction is
left unread. Moreover, a binder file is bound to the opening process's
task, credentials, and mmap state, so transferring it to another
process breaks binder's per-process ownership model.
Disallow binder device fd transfers by returning EINVAL in
Allocation::info_add_fd().
Signed-off-by: Carlos Llamas <cmllamas@xxxxxxxxxx>
---
drivers/android/binder/allocation.rs | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/android/binder/allocation.rs b/drivers/android/binder/allocation.rs
index 927bf47d5d20..8cd4c2a4402a 100644
--- a/drivers/android/binder/allocation.rs
+++ b/drivers/android/binder/allocation.rs
@@ -182,6 +182,13 @@ pub(crate) fn info_add_fd(
buffer_offset: usize,
close_on_free: bool,
) -> Result {
+ // SAFETY: `file` is valid; read `f_op` with `READ_ONCE` semantics.
+ let f_op = unsafe { (&raw const (*file.as_ptr()).f_op).read_volatile() };
+ if core::ptr::eq(f_op, &crate::rust_binder_fops.0) {
+ // Binder FD transfers are not allowed.
+ return Err(EINVAL);
+ }
+
self.get_or_init_info().file_list.files_to_translate.push(
FileEntry {
file,
--
2.56.1.703.gf848ed807c-goog