From: sashiko-bot@kernel.org
To: "Peiyang He" <peiyang_he@smail.nju.edu.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/nouveau/uvmm: fix UAF in bind job cleanup
Date: Tue, 01 Sep 2026 06:49:06 +0000 [thread overview]
Message-ID: <20260901064906.A95BE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <7F26D29D0BD60619+20260901063255.661503-1-peiyang_he@smail.nju.edu.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Unwinding a successfully prepared OP_MAP_SPARSE operation in nouveau_uvmm_bind_job_submit() causes a guaranteed NULL pointer dereference.
- [High] Unwinding a successfully prepared OP_UNMAP_SPARSE operation leaves the region permanently dirty, causing uninterruptible hangs for future operations.
--
commit 203035037bce29ea5a47c8cbbdd0cff202e6dbea
Author: Peiyang He <peiyang_he@smail.nju.edu.cn>
Subject: drm/nouveau/uvmm: fix UAF in bind job cleanup
This patch clears op->reg on the unwind_continue paths for OP_UNMAP_SPARSE.
This prevents a stale region pointer from being passed to cleanup after an
async sparse unmap fails, avoiding a use-after-free.
> diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> index f5e4756b4de4a..aad14316cbefd 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> @@ -1318,6 +1318,7 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job,
> op->reg = nouveau_uvma_region_find(uvmm, op->va.addr,
> op->va.range);
> if (!op->reg || op->reg->dirty) {
> + op->reg = NULL;
> ret = -ENOENT;
> goto unwind_continue;
> }
> @@ -1327,6 +1328,7 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job,
> op->va.range);
> if (IS_ERR(op->ops)) {
> ret = PTR_ERR(op->ops);
> + op->reg = NULL;
> goto unwind_continue;
> }
[Severity: High]
This isn't a bug introduced by this patch, but looking at the unwind path
triggered by goto unwind_continue, does the unwind loop cause a null pointer
dereference for OP_MAP_SPARSE operations?
When unwinding a successfully prepared OP_MAP_SPARSE operation, the code
unconditionally calls drm_gpuva_ops_free(&uvmm->base, op->ops). However,
op->ops is never allocated for OP_MAP_SPARSE and remains NULL.
The drm_gpuva_ops_free() function does not check for NULL and evaluates
&(ops)->list inside the drm_gpuva_for_each_op_safe() iterator:
drm_gpuvm.c:drm_gpuva_ops_free() {
struct drm_gpuva_op *op, *next;
drm_gpuva_for_each_op_safe(op, next, ops) {
list_del(&op->entry);
...
Could this crash if a VM_BIND job submits an OP_MAP_SPARSE operation
followed by a malformed operation that fails?
[Severity: High]
This is also a pre-existing issue in the same unwind path, but does
unwinding a successfully prepared OP_UNMAP_SPARSE operation leave the region
permanently dirty?
The prepare phase for OP_UNMAP_SPARSE calls nouveau_uvma_region_dirty(op->reg).
If a subsequent operation fails, the unwind loop restores the region to the
maple tree and unconditionally clears op->reg = NULL without clearing the
dirty flag or signaling the completion:
nouveau_uvmm.c:nouveau_uvmm_bind_job_submit() unwind path {
...
case OP_UNMAP_SPARSE:
__nouveau_uvma_region_insert(uvmm, op->reg);
nouveau_uvmm_sm_unmap_prepare_unwind(uvmm, &op->new, op->ops);
break;
...
drm_gpuva_ops_free(&uvmm->base, op->ops);
op->ops = NULL;
op->reg = NULL;
...
Because op->reg is cleared here, the nouveau_uvmm_bind_job_cleanup() function
skips it, meaning nouveau_uvma_region_complete(op->reg) is never called.
Will future tasks attempting to map over this leaked region hang forever
waiting on ®->complete in bind_validate_map_common()?
--
Sashiko AI review · https://sashiko.dev/#/patchset/7F26D29D0BD60619+20260901063255.661503-1-peiyang_he@smail.nju.edu.cn?part=1
next prev parent reply other threads:[~2026-09-01 6:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 6:32 [PATCH] drm/nouveau/uvmm: fix UAF in bind job cleanup Peiyang He
2026-09-01 6:49 ` sashiko-bot [this message]
2026-09-01 7:36 ` Peiyang He
2026-09-02 2:38 ` Peiyang He
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=20260901064906.A95BE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=peiyang_he@smail.nju.edu.cn \
--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