From: Jim Cromie via B4 Relay <devnull+jim.cromie.gmail.com@kernel.org>
To: Lyude Paul <lyude@redhat.com>, Danilo Krummrich <dakr@kernel.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Dave Airlie <airlied@redhat.com>
Cc: dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org,
linux-kernel@vger.kernel.org, Jim Cromie <jim.cromie@gmail.com>
Subject: [PATCH 1/3] drm/nouveau: Fix NULL pointer dereferences in GETPARAM ioctl
Date: Fri, 02 Oct 2026 12:09:12 -0600 [thread overview]
Message-ID: <20261002-my-fixups-v1-1-a83d20f9d3fe@gmail.com> (raw)
In-Reply-To: <20261002-my-fixups-v1-0-a83d20f9d3fe@gmail.com>
From: Jim Cromie <jim.cromie@gmail.com>
When hardware or firmware initialization fails, the graphics engine
(gr) or device functions may remain NULL. Attempting to access these
during the GETPARAM ioctl (e.g., NOUVEAU_GETPARAM_GRAPH_UNITS) results
in a kernel NULL pointer dereference, causing a crash when userspace
(GNOME/Mesa) attempts to probe the device.
Add safety checks for 'gr', 'gr->func', and 'nvkm_device->func' in the
ioctl handler. Return -ENODEV to signal the missing hardware state to
userspace, and use NV_ERROR_ONCE to provide diagnostic proof in the
kernel log without risking a console flood.
NOTE:
I encountered these crashes while booting unrelated code (in
dynamic-debug) on real HW. There was also some fwupd updates around
this time, so it could all be transient/unreproducible. But it did
happen, and could happen again in unforseen circumstances.
Signed-off-by: Jim Cromie <jim.cromie@gmail.com>
---
drivers/gpu/drm/nouveau/nouveau_abi16.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_abi16.c b/drivers/gpu/drm/nouveau/nouveau_abi16.c
index 4542d5f4ded8..cb1810dee8e5 100644
--- a/drivers/gpu/drm/nouveau/nouveau_abi16.c
+++ b/drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -306,7 +306,12 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
getparam->value = 1;
break;
case NOUVEAU_GETPARAM_GRAPH_UNITS:
- getparam->value = nvkm_gr_units(gr);
+ if (gr && gr->func) {
+ getparam->value = nvkm_gr_units(gr);
+ } else {
+ NV_ERROR_ONCE(drm, "GETPARAM_GRAPH_UNITS: no gr engine or func\n");
+ return -ENODEV;
+ }
break;
case NOUVEAU_GETPARAM_EXEC_PUSH_MAX: {
int ib_max = getparam_dma_ib_max(device);
@@ -315,11 +320,23 @@ nouveau_abi16_ioctl_getparam(ABI16_IOCTL_ARGS)
break;
}
case NOUVEAU_GETPARAM_VRAM_BAR_SIZE:
- getparam->value = nvkm_device->func->resource_size(nvkm_device, NVKM_BAR1_FB);
+ if (nvkm_device && nvkm_device->func && nvkm_device->func->resource_size) {
+ getparam->value =
+ nvkm_device->func->resource_size(nvkm_device, NVKM_BAR1_FB);
+ } else {
+ NV_ERROR_ONCE(drm, "GETPARAM_VRAM_BAR_SIZE: no device func\n");
+ return -ENODEV;
+ }
break;
case NOUVEAU_GETPARAM_VRAM_USED: {
- struct ttm_resource_manager *vram_mgr = ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
- getparam->value = (u64)ttm_resource_manager_usage(vram_mgr);
+ struct ttm_resource_manager *vram_mgr =
+ ttm_manager_type(&drm->ttm.bdev, TTM_PL_VRAM);
+ if (vram_mgr) {
+ getparam->value = (u64)ttm_resource_manager_usage(vram_mgr);
+ } else {
+ NV_ERROR_ONCE(drm, "GETPARAM_VRAM_USED: no vram mgr\n");
+ return -ENODEV;
+ }
break;
}
case NOUVEAU_GETPARAM_HAS_VMA_TILEMODE:
--
2.55.0
next prev parent reply other threads:[~2026-10-02 18:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 18:09 [PATCH 0/3] nouveau: fix 3 null-ptr derefs Jim Cromie via B4 Relay
2026-10-02 18:09 ` Jim Cromie via B4 Relay [this message]
2026-10-02 18:09 ` [PATCH 2/3] drm/nouveau: Fix NULL pointer dereference in GET_ZCULL_INFO ioctl Jim Cromie via B4 Relay
2026-10-02 18:09 ` [PATCH 3/3] drm/nouveau/gsp: Fix NULL dereference in nvkm_gsp_gcx_ready() Jim Cromie via B4 Relay
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=20261002-my-fixups-v1-1-a83d20f9d3fe@gmail.com \
--to=devnull+jim.cromie.gmail.com@kernel.org \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jim.cromie@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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®