From: "Eliot Courtney" <ecourtney@nvidia.com>
To: "Gary Guo" <gary@garyguo.net>,
"Danilo Krummrich" <dakr@kernel.org>,
"Eliot Courtney" <ecourtney@nvidia.com>,
"Lyude Paul" <lyude@redhat.com>
Cc: "David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Alice Ryhl" <aliceryhl@google.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Alexandre Courbot" <acourbot@nvidia.com>,
dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: drm: fix unsound initialization in drm::Device::new
Date: Tue, 28 Apr 2026 22:13:31 +0900 [thread overview]
Message-ID: <DI4TC7VUL93B.3D7KWP3ZACBZY@nvidia.com> (raw)
In-Reply-To: <DI4SUYYUVHU4.29HTA4KRQYCG6@garyguo.net>
On Tue Apr 28, 2026 at 9:50 PM JST, Gary Guo wrote:
> On Tue Apr 28, 2026 at 1:43 PM BST, Danilo Krummrich wrote:
>> On Tue Apr 28, 2026 at 2:20 PM CEST, Eliot Courtney wrote:
>>> If pinned initialization of drm::Device::Data fails, it calls
>>> drm::Device::release via drm_dev_put. This materializes a reference to
>>> &drm::Device, but it's not fully constructed yet, because initializing
>>> `data` failed. It should not be dropped either. Instead, if pinned
>>> initialization fails, make sure drm::Device::release isn't called.
>>>
>>> Fixes: 2e9fdbe5ec7a ("rust: drm: device: drop_in_place() the drm::Device in release()")
>>> Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
>>
>> There's already a patch from Lyude for this [1].
>>
>> That said, I like the approach with the ALLOC_VTABLE.
>>
>> @Lyude: Do you mind if we pick Eliot's patch?
Sorry, I should have checked before sending this!
>>
>> Thanks,
>> Danilo
>>
>> [1] https://lore.kernel.org/lkml/20260320233645.950190-2-lyude@redhat.com/
>
> I have to second this and I think this solution is very clean. It does mean
> that we're always duplicating vtable though, for just one pointer of difference.
>
> Is it possible to have a shared vtable for drm devices that's in the
> allocated-but-not-initialized state?
It looks like __drm_dev_alloc reads `driver_features` from `drm_driver`
so we'd have to have multiple shared ones if we ever have anything other
than FEAT_GEM for that. And I guess it relies on nothing ever changing
to read more from `drm_driver` during alloc. So I feel it's a bit
fragile, personally.
>
> Best,
> Gary
next prev parent reply other threads:[~2026-04-28 13:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 12:20 [PATCH] rust: drm: fix unsound initialization in drm::Device::new Eliot Courtney
2026-04-28 12:43 ` Danilo Krummrich
2026-04-28 12:50 ` Gary Guo
2026-04-28 13:13 ` Eliot Courtney [this message]
2026-04-29 8:03 ` Alice Ryhl
2026-04-29 11:34 ` Gary Guo
2026-05-01 10:50 ` Eliot Courtney
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=DI4TC7VUL93B.3D7KWP3ZACBZY@nvidia.com \
--to=ecourtney@nvidia.com \
--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=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--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 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.