From: Carlos Llamas <cmllamas@google.com>
To: Jann Horn <jannh@google.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Lorenzo Stoakes" <lorenzo.stoakes@oracle.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
linux-mm@kvack.org, stable@vger.kernel.org
Subject: Re: [PATCH v2 1/2] rust_binder: check ownership before using vma
Date: Mon, 2 Mar 2026 18:36:03 +0000 [thread overview]
Message-ID: <aaXYkwQ0Yg5b7sTb@google.com> (raw)
In-Reply-To: <CAG48ez2M4fj15gqyKrP7ADRUhNQZkpy9m+NSz2N=vo=PSefm0w@mail.gmail.com>
On Mon, Mar 02, 2026 at 06:28:17PM +0100, Jann Horn wrote:
> On Mon, Mar 2, 2026 at 6:18 PM Carlos Llamas <cmllamas@google.com> wrote:
> > On Wed, Feb 18, 2026 at 11:53:26AM +0000, Alice Ryhl wrote:
> > > When installing missing pages (or zapping them), Rust Binder will look
> > > up the vma in the mm by address, and then call vm_insert_page (or
> > > zap_page_range_single). However, if the vma is closed and replaced with
> > > a different vma at the same address, this can lead to Rust Binder
> > > installing pages into the wrong vma.
> > >
> > > By installing the page into a writable vma, it becomes possible to write
> > > to your own binder pages, which are normally read-only. Although you're
> > > not supposed to be able to write to those pages, the intent behind the
> > > design of Rust Binder is that even if you get that ability, it should not
> > > lead to anything bad. Unfortunately, due to another bug, that is not the
> > > case.
> >
> > This all makes sense to me. What I'm missing though is why not reject
> > VM_WRITE mappings all together? Is there a downside or something that
> > prevents us from setting this check?
>
> You could, and it would probably do the job (assuming that you check
> for VM_MAYWRITE instead of VM_WRITE), but I think it'd be more of a
> surface-level mitigation than a robust safety check - in my opinion, a
> robust check should, at a minimum, confirm that the VMA being accessed
> belongs to the right driver, because other drivers might do random
> things you don't expect in their own VMAs. (For example, it wouldn't
> protect against interaction with a driver like C binder which reads
> PTEs back out of the VMA in binder_page_lookup(), makes assumptions
> about what kinds of pages that yields, and writes into those pages.) A
> driver should not be touching VMAs it doesn't own.
Alice just informed me the VM_MAYWRITE check is already in-place:
rust_binder_mmap() ->
Process::mmap() ->
try_clear_maywrite()
I just wasn't aware of this, sorry for the noise.
I also agree with your comments. The following two safety checks should
be addressed by binder:
1. mappings should be read-only.
2. don't operate on unrelated VMAs.
(1) Was already covered and (2) is addressed by this patchset. So we are
all good here. Thanks!
--
Carlos Llamas
next prev parent reply other threads:[~2026-03-02 18:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 11:53 [PATCH v2 0/2] Fix VMA confusion in Rust Binder Alice Ryhl
2026-02-18 11:53 ` [PATCH v2 1/2] rust_binder: check ownership before using vma Alice Ryhl
2026-02-18 13:47 ` Danilo Krummrich
2026-02-18 15:54 ` Liam R. Howlett
2026-02-18 16:39 ` Alice Ryhl
2026-03-02 17:18 ` Carlos Llamas
2026-03-02 17:28 ` Jann Horn
2026-03-02 18:36 ` Carlos Llamas [this message]
2026-02-18 11:53 ` [PATCH v2 2/2] rust_binder: avoid reading the written value in offsets array Alice Ryhl
2026-02-18 16:02 ` Liam R. Howlett
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=aaXYkwQ0Yg5b7sTb@google.com \
--to=cmllamas@google.com \
--cc=Liam.Howlett@oracle.com \
--cc=a.hindborg@kernel.org \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tmgross@umich.edu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox