From: Janne Grunau <j@jannau.net>
To: Daniel Almeida <daniel.almeida@collabora.com>
Cc: "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>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Sami Tolvanen" <samitolvanen@google.com>,
"Lyude Paul" <lyude@redhat.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org, nova-gpu@lists.linux.dev,
stable+noautosel@kernel.org,
"Deborah Brouwer" <deborah.brouwer@collabora.com>
Subject: Re: [PATCH v3 3/5] rust: drm: gem: shmem: Implement prime_import_sg_table callback
Date: Sat, 5 Dec 2026 14:35:15 +0100 [thread overview]
Message-ID: <20261205133515.GA551683@robin.jannau.net> (raw)
In-Reply-To: <0FBD4F41-517B-4108-AC90-9D89F960AA5F@collabora.com>
On Fri, Dec 04, 2026 at 06:15:17PM -0300, Daniel Almeida wrote:
>
>
> > On 3 Dec 2026, at 07:14, Janne Grunau <j@jannau.net> wrote:
> >
> > The C drm_gem_shmem_prime_import_sg_table() helper function uses
> > `__drm_gem_shmem_create()` to create shmem objects. In the absence of a
> > `gem_create_object` callback this allocates just a `struct
> > drm_gem_shmem_object` resulting in buffer overflows when using it as
> > Rust `Object<t>`.
> > Implementing the `gem_create_object` callback for RUST DRM drivers is
> > not sufficient as `__drm_gem_shmem_create()` uses `kfree(obj)` in error
> > paths. This is unsound if the DriverObject contains fields with
> > non-trivial `Drop` implementations as noted in [1].
> >
> > Imported BOs have no userspace creation arguments, so extend
> > `DriverObject` with a `create_imported(dev, size)` constructor and
> > implement it for Tyr's `BoData`, Nova, and the in-tree KUnit driver.
> >
> > Tested with the asahi downstream driver.
> >
> > Link: https://lore.kernel.org/rust-for-linux/20261118114102.490384-1-aliceryhl@google.com/ [1]
> > Fixes: 80df573af9ef ("rust: drm: gem: shmem: Add DRM shmem helper abstraction")
> > Cc: stable+noautosel@kernel.org # no in tree users
> > Suggested-by: Alice Ryhl <aliceryhl@google.com>
> > Co-developed-by: Sami Tolvanen <samitolvanen@google.com>
> > Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> > Tested-by: Deborah Brouwer <deborah.brouwer@collabora.com>
> > Signed-off-by: Janne Grunau <j@jannau.net>
> > ---
[...]
> > diff --git a/rust/kernel/drm/driver.rs b/rust/kernel/drm/driver.rs
> > index f6db91e81e79..7e8e842421a4 100644
> > --- a/rust/kernel/drm/driver.rs
> > +++ b/rust/kernel/drm/driver.rs
> > @@ -118,7 +118,7 @@ pub trait Driver {
> > type RegistrationData<'a>: Send + Sync + 'a;
> >
> > /// The type used to manage memory for this driver.
> > - type Object: AllocImpl;
> > + type Object: AllocImpl<Driver = Self>;
>
> I think this should be its own, preceding patch, IMHO.
>
> This change is needed regardless. The problem only became apparent now with
> imported buffers, but it is otherwise a pre-existing issue.
I don't disagree but I forgot to split this off before I sent v4 out.
I don't think it justifies a respin. We're very close to -rc6 and I'd
like to see this in the pull request for v7.5.
Janne
next prev parent reply other threads:[~2026-12-05 13:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 10:14 [PATCH v3 0/5] Fix import of dma-buf buffers as DRM GEM shmem objects Janne Grunau
2026-12-03 10:14 ` [PATCH v3 1/5] rust: drm: gem: shmem: Do not use drm_gem_shmem_dumb_create() Janne Grunau
2026-12-04 20:30 ` Daniel Almeida
2026-12-03 10:14 ` [PATCH v3 2/5] drm/gem/shmem: Initialize private objects via drm_gem_shmem_init() too Janne Grunau
2026-12-04 20:40 ` Daniel Almeida
2026-12-03 10:14 ` [PATCH v3 3/5] rust: drm: gem: shmem: Implement prime_import_sg_table callback Janne Grunau
2026-12-04 11:43 ` Alice Ryhl
2026-12-04 21:15 ` Daniel Almeida
2026-12-05 13:35 ` Janne Grunau [this message]
2026-12-05 13:36 ` Daniel Almeida
2026-12-03 10:14 ` [PATCH v3 4/5] rust: drm: gem: add an is_imported() accessor Janne Grunau
2026-12-04 21:16 ` Daniel Almeida
2026-12-03 10:14 ` [PATCH v3 5/5] rust: drm: gem: shmem: Do not free SG table of imported objects Janne Grunau
2026-12-04 11:49 ` Alice Ryhl
2026-12-04 13:51 ` Janne Grunau
2026-12-04 14:21 ` Alice Ryhl
2026-12-04 21:22 ` Daniel Almeida
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=20261205133515.GA551683@robin.jannau.net \
--to=j@jannau.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=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=samitolvanen@google.com \
--cc=simona@ffwll.ch \
--cc=stable+noautosel@kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=tzimmermann@suse.de \
--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®