From: sashiko-bot@kernel.org
To: "Vladislav Zaharov" <vladazaharova2018@gmail.com>
Cc: dri-devel@lists.freedesktop.org,
"Danilo Krummrich" <dakr@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>
Subject: Re: [PATCH v3 1/3] gpu: nova-core: build the debugfs guard before registering the driver
Date: Sat, 12 Sep 2026 07:28:24 +0000 [thread overview]
Message-ID: <20260912072824.CA8CF1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260912071842.622696-2-vladazaharova2018@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The `NovaCore` struct fields are dropped in the wrong order, causing the auxiliary device to be unregistered after the GPU and BAR are destroyed.
--
commit 10c5ae1aadef16818d89098db4af7d31890aea8c
Author: Vladislav Zaharov <vladazaharova2018@gmail.com>
gpu: nova-core: build the debugfs guard before registering the driver
This commit reorders the initialization in try_pin_init! so that the debugfs
guard is built before the driver registration. This ensures that if
initialization fails, the debugfs directory is properly cleaned up instead of
persisting across module reloads. The drop order for the module remains
unchanged.
> diff --git a/drivers/gpu/nova-core/nova_core.rs b/drivers/gpu/nova-core/nova_core.rs
> index 1133c6ce5c554..11fe1d2858a9c 100644
> --- a/drivers/gpu/nova-core/nova_core.rs
> +++ b/drivers/gpu/nova-core/nova_core.rs
> @@ -47,7 +47,8 @@ fn drop(&mut self) {
> #[pin_data]
> struct NovaCoreModule {
> // Fields are dropped in declaration order, so `_driver` is dropped first,
> - // then `_debugfs_guard` clears `DEBUGFS_ROOT`.
> + // then `_debugfs_guard` clears `DEBUGFS_ROOT`. They are initialized the
> + // other way round, see `init()`.
> #[pin]
> _driver: Registration<pci::Adapter<driver::NovaCoreDriver>>,
> _debugfs_guard: DebugfsRootGuard,
[Severity: High]
This isn't a bug introduced by this patch, but since this change discusses
drop orders, does the struct declaration order of NovaCore in
drivers/gpu/nova-core/driver.rs cause the auxiliary device to be unregistered
after the GPU and BAR are destroyed?
drivers/gpu/nova-core/driver.rs:
#[pin_data]
pub(crate) struct NovaCore<'bound> {
#[pin]
pub(crate) gpu: Gpu<'bound>,
bar: pci::Bar<'bound, BAR0_SIZE>,
#[allow(clippy::type_complexity)]
_reg: auxiliary::Registration<'bound, CovariantForLt!(())>,
}
In Rust, struct fields are dropped in declaration order (first to last). In
NovaCore, gpu and bar are declared before _reg. Therefore, the GPU is dropped
and the MMIO region is unmapped before the auxiliary device registration
(_reg) is dropped.
When _reg is subsequently dropped, it synchronously unregisters the child
device and invokes the child driver's (e.g., nova-drm) remove callback. If
the child driver attempts to access the GPU or MMIO BAR during its teardown
(e.g., to disable the display or flush buffers), will it access destroyed
resources or unmapped memory, leading to a UAF and kernel oops?
This deterministic crash would trigger whenever the NovaCore device is
unbound or the module is unloaded.
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260912071842.622696-1-vladazaharova2018@gmail.com?part=1
next prev parent reply other threads:[~2026-09-12 7:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 7:18 [PATCH v3 0/3] gpu: nova-core: retain the GSP-RM log buffers Vladislav Zaharov
2026-09-12 7:18 ` [PATCH v3 1/3] gpu: nova-core: build the debugfs guard before registering the driver Vladislav Zaharov
2026-09-12 7:28 ` sashiko-bot [this message]
2026-09-12 7:18 ` [PATCH v3 2/3] gpu: nova-core: gsp: retain the GSP-RM log buffers after unbind Vladislav Zaharov
2026-09-12 7:27 ` sashiko-bot
2026-09-12 17:55 ` Gary Guo
2026-09-12 7:18 ` [PATCH v3 3/3] Documentation: nova: remove completed GSP log buffer task Vladislav Zaharov
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=20260912072824.CA8CF1F00898@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=acourbot@nvidia.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vladazaharova2018@gmail.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.