All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Llamas <cmllamas@google.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Todd Kjos" <tkjos@android.com>,
	"Christian Brauner" <brauner@kernel.org>,
	kernel-team@android.com, linux-kernel@vger.kernel.org,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust_binder: disallow binder fd transfers
Date: Sat, 21 Nov 2026 18:21:51 +0000	[thread overview]
Message-ID: <awHhP5chY30mzbK6@google.com> (raw)
In-Reply-To: <20261118112933.477541-1-aliceryhl@google.com>

On Wed, Nov 18, 2026 at 11:29:32AM +0000, Alice Ryhl wrote:
> 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) };

I see, ok I'll switch to this for v2.

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

We don't but there are other fd's in other drivers that do. This was
flagged by my local LLM review. It was in some tty driver and somewhere
else that override the f_ops. It seems pretty far-fetched that a false
rust_binder_fops would trigger from this, but at least it would protect
against KCSAN reports and similar. So probably best to keep it.

--
Carlos Llamas

      reply	other threads:[~2026-11-21 18:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 23:19 [PATCH] rust_binder: disallow binder fd transfers Carlos Llamas
2026-11-18 11:29 ` Alice Ryhl
2026-11-21 18:21   ` Carlos Llamas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=awHhP5chY30mzbK6@google.com \
    --to=cmllamas@google.com \
    --cc=aliceryhl@google.com \
    --cc=arve@android.com \
    --cc=brauner@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tkjos@android.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.