From: sashiko-bot@kernel.org
To: "Lyude Paul" <lyude@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 4/5] drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+
Date: Thu, 30 Jul 2026 20:10:18 +0000 [thread overview]
Message-ID: <20260730201018.9B0361F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260730195523.1467423-5-lyude@redhat.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Dynamically allocating `struct drm_driver` with `devm_kzalloc` creates a Use-After-Free on device unbind.
--
--- Patch [4]: [PATCH v2 4/5] drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+ ---
commit 5c23d4459a380de49a6e089b9ca550a380ff5d97
Author: Lyude Paul <lyude@redhat.com>
drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+
Atomic modesetting support was never added for pre-nv50 chipsets, so make
sure we don't allow it to be forced on. Additionally, print a small warning
when it's not supported.
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index ae489dc1b1943..33f60f5d4d9f3 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -770,8 +770,12 @@ nouveau_drm_device_new(struct device *parent, struct nvkm_device *device)
> goto done;
> }
>
> - if (nouveau_atomic)
> - drm_driver->driver_features |= DRIVER_ATOMIC;
> + if (nouveau_atomic) {
> + if (drm->device.info.family >= NV_DEVICE_INFO_V0_TESLA)
> + drm_driver->driver_features |= DRIVER_ATOMIC;
[Severity: High]
Earlier in nouveau_drm_device_new(), drm_driver is dynamically allocated
with devm_kzalloc():
drm_driver = devm_kzalloc(parent, sizeof(*drm_driver), GFP_KERNEL);
if (!drm_driver)
return ERR_PTR(-ENOMEM);
Can this create a use-after-free on device unbind?
If userspace opens the DRM device node, it takes a reference on the
drm_device object. If the PCI device is hot-unplugged or manually unbound,
devres cleanup frees the drm_driver (along with nouveau_drm).
Later, when userspace closes the DRM file descriptor, drm_release() calls
drm_dev_needs_global_mutex() which evaluates dev->driver->driver_features,
and eventually executes dev->driver->postclose(), dereferencing the freed
memory.
> + else
> + NV_WARN(drm, "Atomic modesetting not supported (needs nv50+)\n");
> + }
>
> ret = nvif_device_map(&drm->device);
> if (ret) {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260730195523.1467423-1-lyude@redhat.com?part=4
next prev parent reply other threads:[~2026-07-30 20:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 19:51 [PATCH v2 0/5] drm/nouveau: Enable atomic modesetting by default Lyude Paul
2026-07-30 19:51 ` [PATCH v2 1/5] drm/nouveau: Fix cleanup bug in nouveau_drm_device_new() Lyude Paul
2026-07-30 20:13 ` sashiko-bot
2026-07-30 19:51 ` [PATCH v2 2/5] drm/nouveau: Print the nouveau.atomic parameter in nouveau_display_options() Lyude Paul
2026-07-30 19:51 ` [PATCH v2 3/5] drm/nouveau: Fix drm_driver struct/nouveau.atomic parameter handling Lyude Paul
2026-07-30 20:04 ` sashiko-bot
2026-07-30 19:51 ` [PATCH v2 4/5] drm/nouveau/kms: Only allow enabling atomic modesetting on nv50+ Lyude Paul
2026-07-30 20:10 ` sashiko-bot [this message]
2026-07-30 19:51 ` [PATCH v2 5/5] drm/nouveau/kms/nv50-: Enable atomic modesetting by default Lyude Paul
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=20260730201018.9B0361F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lyude@redhat.com \
--cc=sashiko-reviews@lists.linux.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