Re: [PATCH] rust_binder: disallow binder fd transfers
From: Alice Ryhl
Date: Wed Nov 18 2026 - 06:29:47 EST
On Tue, Nov 17, 2026 at 11:19:26PM +0000, Carlos Llamas wrote:
> @@ -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);
> + }
We have moved to using atomic_load instead of a volatile read when the C side
uses READ_ONCE. For example:
// SAFETY: `file` is valid, so `f_op` is valid and aligned, and any
// concurrent writes are atomic under LKMM.
let f_op = unsafe { atomic_load(&raw mut (*file.as_ptr()).f_op, Relaxed) };
however the f_op field isn't read/modified with READ/WRITE_ONCE on the C
side, so I think we can use a bare access.
let f_op = unsafe { (*file.as_ptr()).f_op };
Alice