From: sashiko-bot@kernel.org
To: "Thadeu Lima de Souza Cascardo" <cascardo@igalia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/4] drm/amdgpu: commit pending work when amdgpu_vm_ptes_update fails
Date: Mon, 14 Sep 2026 20:42:39 +0000 [thread overview]
Message-ID: <20260914204240.5F60F1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260914-amdgpu_vm_fixes-v1-4-d6d835591e0f@igalia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Ignored return value of update_funcs->update leads to NULL pointer dereference or silent GPU page faults.
- [High] Dangling pointer / Use-After-Free in amdgpu_vm_pt_alloc when amdgpu_vm_pt_clear fails.
--
commit 7a14ea1f8dd61c2e4083bcbdd9192e590552290f
Author: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
drm/amdgpu: commit pending work when amdgpu_vm_ptes_update fails
This commit changes the error path when amdgpu_vm_ptes_update() fails to
break the loop and commit pending work instead of jumping to error_free.
This fixes an SDMA job memory leak and ensures TLB entries are flushed
and local stack waitlists are cleared properly.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index 5bde36754607f..1495adaaacd89 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -1235,7 +1235,7 @@ int amdgpu_vm_update_range(struct amdgpu_device *adev, struct amdgpu_vm *vm,
> tmp = start + num_entries;
> r = amdgpu_vm_ptes_update(¶ms, start, tmp, addr, flags);
> if (r)
> - goto error_free;
> + break;
[Severity: High]
This is a pre-existing issue, but I noticed a potential use-after-free in the
page table allocation path called from amdgpu_vm_ptes_update():
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c:amdgpu_vm_pt_alloc() {
...
error_free_pt:
amdgpu_bo_unref(&pt_bo);
return r;
}
If amdgpu_vm_pt_clear() fails (e.g., due to memory allocation failure or
fence wait timeout), it jumps to error_free_pt and frees the newly
allocated pt_bo. However, this BO has already been assigned to entry->bo
and added to VM tracking lists by the preceding call to
amdgpu_vm_bo_base_init(). Is it possible that freeing pt_bo here leaves
entry->bo pointing to the freed memory?
[Severity: Critical]
This is a pre-existing issue, but there appears to be an unhandled error
path during PTE updates called from amdgpu_vm_ptes_update():
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c:amdgpu_vm_pte_update_flags() {
...
params->vm->update_funcs->update(params, pt, pe, addr, count, incr,
flags);
}
The update function's return value is completely ignored. If the update
fails (for example, if amdgpu_vm_sdma_update() fails to allocate a job due
to ENOMEM), the job pointer (p->job) is set to NULL. Since the error is
dropped, amdgpu_vm_ptes_update() continues iterating and calls
amdgpu_vm_pte_update_flags() again.
Will this cause amdgpu_vm_sdma_update() to dereference the NULL p->job on
the next iteration, leading to a kernel panic? Or if it's a CPU update,
will ignoring the failure lead to invalid GPU page tables and subsequent
GPU page faults?
>
> amdgpu_res_next(&cursor, num_entries * AMDGPU_GPU_PAGE_SIZE);
> start = tmp;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260914-amdgpu_vm_fixes-v1-0-d6d835591e0f@igalia.com?part=4
prev parent reply other threads:[~2026-09-14 20:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 20:25 [PATCH 0/4] drm/amdgpu: fix bugs when amdgpu_vm_ptes_update fails Thadeu Lima de Souza Cascardo
2026-09-14 20:25 ` [PATCH 1/4] drm/amdgpu: make amdgpu_vm_sdma_commit handle NULL or empty job Thadeu Lima de Souza Cascardo
2026-09-14 20:25 ` [PATCH 2/4] drm/amdgpu: make amdgpu_vm_update_funcs commit return void Thadeu Lima de Souza Cascardo
2026-09-14 20:25 ` [PATCH 3/4] drm/amdgpu: don't free mapping when amdgpu_vm_update_range fails Thadeu Lima de Souza Cascardo
2026-09-14 20:43 ` sashiko-bot
2026-09-15 8:33 ` Christian König
2026-09-15 8:53 ` Natalie Vock
2026-09-15 10:37 ` Thadeu Lima de Souza Cascardo
2026-09-15 11:22 ` Christian König
2026-09-15 11:34 ` Thadeu Lima de Souza Cascardo
2026-09-15 13:56 ` Christian König
2026-09-23 13:56 ` Thadeu Lima de Souza Cascardo
2026-09-23 13:58 ` Christian König
2026-09-23 14:18 ` Thadeu Lima de Souza Cascardo
2026-09-23 14:51 ` Christian König
2026-09-14 20:25 ` [PATCH 4/4] drm/amdgpu: commit pending work when amdgpu_vm_ptes_update fails Thadeu Lima de Souza Cascardo
2026-09-14 20:42 ` 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=20260914204240.5F60F1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cascardo@igalia.com \
--cc=dri-devel@lists.freedesktop.org \
--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.