mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Gary Guo" <gary@garyguo.net>
To: "Alice Ryhl" <aliceryhl@google.com>,
	"Deborah Brouwer" <deborah.brouwer@collabora.com>
Cc: "Danilo Krummrich" <dakr@kernel.org>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"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>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] drm/tyr: safely write GpuInfo to userspace
Date: Fri, 25 Sep 2026 11:29:07 +0100	[thread overview]
Message-ID: <DLOBS2HQYSWS.2W0JMY91EZ48V@garyguo.net> (raw)
In-Reply-To: <CAH5fLgj=h_riWoOvEX_TOH3+0FNbKBtjO1OrxzwHDQq7uzXg_A@mail.gmail.com>

On Fri Sep 25, 2026 at 8:56 AM BST, Alice Ryhl wrote:
> On Thu, Sep 24, 2026 at 7:22 PM Deborah Brouwer
> <deborah.brouwer@collabora.com> wrote:
>>
>> Tyr creates the struct drm_panthor_gpu_info from the Panthor UAPI
>> bindings. It initializes this struct by querying the gpu and then writes
>> the struct into userspace memory faithfully byte-by-byte.
>>
>> Currently, the struct drm_panthor_gpu_info does not have any implicit
>> padding, but if implicit padding were added in the future Rust does not
>> guarantee that it would be initialized. Then when Tyr writes the struct
>> back to userspace it could expose uninitialized kernel memory.
>>
>> Tyr implements the unsafe trait AsBytes for GpuInfo whereby the developer
>> guarantees that struct drm_panthor_gpu_info does not include implicit
>> padding, pointers, or interior mutability. This allows Tyr to safely copy
>> the struct into userspace memory. However, relying on the unsafe trait
>> AsBytes is fragile because if the Panthor UAPI changes, the SAFETY
>> guarantees may no longer be accurate.
>>
>> Instead, use the derive macro `zerocopy_derive::most_traits` for struct
>> drm_panthor_gpu_info. This macro will attempt to implement the zerocopy
>> traits for struct drm_panthor_gpu_info. If the Panthor UAPI changes so
>> that the traits IntoBytes or Immutable can no longer be implemented, Tyr
>> will no longer compile.
>>
>> Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
>
> So this looks good to me
>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>
>
> but needs Miguel's ok since it modifies the Makefile. And I imagine he
> may ask the commit to be split into two.

FWIW I do think this should be two commits, one making Make changes and apply to
both uapi and bindings, and the second adding the Tyr-specific parts.

Best,
Gary



  reply	other threads:[~2026-09-25 10:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 17:22 Deborah Brouwer
2026-09-25  7:56 ` Alice Ryhl
2026-09-25 10:29   ` Gary Guo [this message]
2026-09-25 16:28     ` Deborah Brouwer

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=DLOBS2HQYSWS.2W0JMY91EZ48V@garyguo.net \
    --to=gary@garyguo.net \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=airlied@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=deborah.brouwer@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tamird@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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

all inboxes | Powered by JetHome®