From: sashiko-bot@kernel.org
To: "Guangshuo Li" <lgs201920130244@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/nouveau: fix autosuspend cleanup during teardown
Date: Sat, 08 Aug 2026 13:54:37 +0000 [thread overview]
Message-ID: <20260808135438.13C501F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260808134137.2864847-1-lgs201920130244@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Hot-unplug during an open file descriptor leads to a use-after-free of nouveau_cli via the DRM_NOUVEAU_NVIF ioctl.
--
--- Patch [1]: [PATCH] drm/nouveau: fix autosuspend cleanup during teardown ---
commit ae87ae00f3257ee8e11b10260263c7423ec1666c
Author: Guangshuo Li <lgs201920130244@gmail.com>
drm/nouveau: fix autosuspend cleanup during teardown
nouveau_drm_device_init() calls pm_runtime_use_autosuspend(), but
nouveau_drm_device_fini() does not call the matching
pm_runtime_dont_use_autosuspend().
Cc: stable@vger.kernel.org
> diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c
> index 4d1ad718e09b7..42daad06fdbe3 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_drm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c
> @@ -585,6 +585,7 @@ nouveau_drm_device_fini(struct nouveau_drm *drm)
> if (nouveau_pmops_runtime()) {
> pm_runtime_get_sync(dev->dev);
> pm_runtime_forbid(dev->dev);
> + pm_runtime_dont_use_autosuspend(dev->dev);
> }
>
> nouveau_led_fini(dev);
[Severity: High]
This is a pre-existing issue, but could the subsequent client cleanup in
nouveau_drm_device_fini() lead to a use-after-free if the device is
hot-unplugged while userspace still has an open file descriptor?
If a hot-unplug occurs, nouveau_drm_device_fini() unconditionally frees the
client structures a bit further down in the function:
list_for_each_entry_safe(cli, temp_cli, &drm->clients, head) {
...
nouveau_cli_fini(cli);
kfree(cli);
}
If userspace then issues a DRM_NOUVEAU_NVIF ioctl on the still-open file
descriptor, nouveau_drm_ioctl() handles it:
ret = pm_runtime_get_sync(dev->dev);
if (ret < 0 && ret != -EACCES)
return ret;
...
switch (cmd) {
case DRM_NOUVEAU_NVIF:
ret = nouveau_abi16_ioctl(filp, (void __user *)arg, _IOC_SIZE(cmd));
break;
Because runtime PM is disabled upon device removal, pm_runtime_get_sync()
returns -EACCES, which the ioctl handler ignores. The ioctl proceeds directly
to nouveau_abi16_ioctl(), bypassing the standard drm_dev_is_unplugged() check.
This eventually calls nouveau_abi16_get(), which accesses the freed memory:
struct nouveau_cli *cli = nouveau_cli(file_priv);
mutex_lock(&cli->mutex);
Can this sequence lead to memory corruption or panics during teardown?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260808134137.2864847-1-lgs201920130244@gmail.com?part=1
prev parent reply other threads:[~2026-08-08 13:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 13:41 [PATCH] drm/nouveau: fix autosuspend cleanup during teardown Guangshuo Li
2026-08-08 13:54 ` sashiko-bot [this message]
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=20260808135438.13C501F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lgs201920130244@gmail.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 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.