From: Zhenhao Wan <whi4ed0g@gmail.com>
To: "Boris Brezillon" <boris.brezillon@collabora.com>,
"Steven Price" <steven.price@arm.com>,
"Liviu Dudau" <liviu.dudau@arm.com>,
"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>,
"Grant Likely" <grant.likely@linaro.org>,
"Heiko Stuebner" <heiko@sntech.de>,
"Danilo Krummrich" <dakr@kernel.org>,
"Matthew Brost" <matthew.brost@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Alice Ryhl" <aliceryhl@google.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
Lyude Paul <lyude@redhat.com>,
nouveau@lists.freedesktop.org, Dave Airlie <airlied@redhat.com>,
Zhenhao Wan <whi4ed0g@gmail.com>,
Yuhao Jiang <danisjiang@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH v2 0/2] drm/gpuvm: reject zero-length VM_BIND ranges at the shared gate
Date: Wed, 02 Sep 2026 20:28:41 +0800 [thread overview]
Message-ID: <20260902-drm-gpuvm-zerorange-v2-v2-0-da63269c6ec4@gmail.com> (raw)
v1 fixed this in the nouveau driver by rejecting a zero-length range in
nouveau_uvmm_validate_range(). Danilo pointed out that this should be
fixed in GPUVM instead, and he is right: the defect is in the core, so
this v2 moves the fix there.
A zero-length range passes drm_gpuvm_range_valid() (0 is page-aligned and
addr + 0 does not overflow), and the GPUVA interval tree then computes a
node's last key as addr + range - 1, which underflows to addr - 1. The
resulting inverted interval corrupts the augmented rb-tree. Because both
the underflowing arithmetic and the single validation gate live in
drm_gpuvm.c, the core protects no one: nouveau and msm are affected, while
xe and imagination are saved only by their own explicit checks near the
ioctl boundary. Patch 2 adds the rejection to drm_gpuvm_range_valid(),
closing the hole for all callers at once.
Fixing only the core would, however, interact badly with panthor. Its
synchronous VM_BIND path already treats a zero-length op as a no-op
(returns 0), but its asynchronous path does not: a zero-length async
MAP/UNMAP reaches drm_gpuvm_sm_map()/drm_gpuvm_sm_unmap(). Today a
zero-length async map into unmapped space can already insert a malformed
node there, so patch 1 fixes a pre-existing corruption on its own; and
once the core starts rejecting a zero range, panthor_vm_bind_run_job()
would additionally escalate the resulting -EINVAL to
panthor_vm_declare_unusable(), permanently killing the VM. Patch 1
therefore makes panthor's asynchronous path treat a zero-length op as a
no-op, matching its synchronous path, and must be applied before patch 2.
Both patches are Cc: stable.
Changes since v1:
- Move the fix from the nouveau driver into the GPUVM core
(drm_gpuvm_range_valid()), per Danilo's feedback.
- Add a preparatory panthor patch so the core change does not regress
panthor's asynchronous VM_BIND path.
- Link to v1: https://lore.kernel.org/all/20260812-nouveau-uvmm-pt-fixes-v1-1-ab3a823f946e@gmail.com
Signed-off-by: Zhenhao Wan <whi4ed0g@gmail.com>
---
Zhenhao Wan (2):
drm/panthor: Treat a zero-length VM_BIND op as a no-op
drm/gpuvm: reject zero-length range in drm_gpuvm_range_valid()
drivers/gpu/drm/drm_gpuvm.c | 6 ++++--
drivers/gpu/drm/panthor/panthor_mmu.c | 9 +++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
---
base-commit: db2ddb87143519e20a95aa36c60b36107b736a58
change-id: 20260902-drm-gpuvm-zerorange-v2-a2148df386b8
Best regards,
--
Zhenhao Wan <whi4ed0g@gmail.com>
next reply other threads:[~2026-09-02 12:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 12:28 Zhenhao Wan [this message]
2026-09-02 12:28 ` [PATCH v2 1/2] drm/panthor: Treat a zero-length VM_BIND op as a no-op Zhenhao Wan
2026-09-02 12:28 ` [PATCH v2 2/2] drm/gpuvm: reject zero-length range in drm_gpuvm_range_valid() Zhenhao Wan
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=20260902-drm-gpuvm-zerorange-v2-v2-0-da63269c6ec4@gmail.com \
--to=whi4ed0g@gmail.com \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=aliceryhl@google.com \
--cc=boris.brezillon@collabora.com \
--cc=dakr@kernel.org \
--cc=danisjiang@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=grant.likely@linaro.org \
--cc=heiko@sntech.de \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=lyude@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=nouveau@lists.freedesktop.org \
--cc=simona@ffwll.ch \
--cc=stable@vger.kernel.org \
--cc=steven.price@arm.com \
--cc=thomas.hellstrom@linux.intel.com \
--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®