From: sashiko-bot@kernel.org
To: "Pierre-Eric Pelloux-Prayer" <pierre-eric.pelloux-prayer@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v1 1/2] drm/amdgpu: move debug_vm handling to amdgpu_cs_parser_fini
Date: Mon, 22 Jun 2026 09:39:29 +0000 [thread overview]
Message-ID: <20260622093929.EEC1C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260622092859.3600-1-pierre-eric.pelloux-prayer@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Moving `amdgpu_vm_bo_invalidate()` to `amdgpu_cs_parser_fini()` accesses BO structures without holding their `dma_resv` reservation locks, leading to data races, potential use-after-free vulnerabilities, and lockdep assertions.
--
commit 130b94ccdb3ef241f2576b6d31544c37bb57192b
Author: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
drm/amdgpu: move debug_vm handling to amdgpu_cs_parser_fini
The commit restarts the CS if the validation is still in progress, but when
debug_vm is enabled, all BOs are invalidated, causing an infinite loop. This
patch moves the BO invalidation to amdgpu_cs_parser_fini to avoid that.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index d63fbc7c568de..7e75c536dab3d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
[ ... ]
> @@ -1382,6 +1369,8 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
> /* Cleanup the parser structure */
> static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser)
> {
> + struct amdgpu_device *adev = parser->adev;
> + struct amdgpu_bo_list_entry *e;
> unsigned int i;
>
> amdgpu_sync_free(&parser->sync);
[ ... ]
> @@ -1397,8 +1386,21 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser)
>
> if (parser->ctx)
> amdgpu_ctx_put(parser->ctx);
> - if (parser->bo_list)
> + if (parser->bo_list) {
> + if (adev->debug_vm) {
> + /* Invalidate all BOs to test for userspace bugs */
> + amdgpu_bo_list_for_each_entry(e, parser->bo_list) {
> + struct amdgpu_bo *bo = e->bo;
> +
> + /* ignore duplicates */
> + if (!bo)
> + continue;
> +
> + amdgpu_vm_bo_invalidate(bo, false);
[Severity: High]
Does moving this invalidation here result in accessing the BO structures
without their reservation locks?
Earlier in amdgpu_cs_parser_fini(), drm_exec_fini() is called to drop
all dma_resv locks acquired during parsing:
amdgpu_cs_parser_fini() {
...
amdgpu_sync_free(&parser->sync);
drm_exec_fini(&parser->exec);
...
Since amdgpu_vm_bo_invalidate() iterates over the bo->vm_bo list, which
is protected by the BO's reservation lock, could this unlocked access
lead to a data race or a use-after-free if it races with concurrent
mapping operations like amdgpu_vm_bo_del()?
Additionally, if any of the BOs are always-valid, this will eventually call
amdgpu_vm_bo_moved(), which triggers an amdgpu_vm_assert_locked(vm) lockdep
assertion since the root PD lock was already dropped.
> + }
> + }
> amdgpu_bo_list_put(parser->bo_list);
> + }
>
> for (i = 0; i < parser->nchunks; i++)
> kvfree(parser->chunks[i].kdata);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260622092859.3600-1-pierre-eric.pelloux-prayer@amd.com?part=1
next prev parent reply other threads:[~2026-06-22 9:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-22 9:28 [PATCH v1 1/2] drm/amdgpu: move debug_vm handling to amdgpu_cs_parser_fini Pierre-Eric Pelloux-Prayer
2026-06-22 9:28 ` [PATCH v1 2/2] drm/amdgpu: remove left-over variable Pierre-Eric Pelloux-Prayer
2026-06-22 9:39 ` sashiko-bot [this message]
2026-06-22 12:19 ` [PATCH v1 1/2] drm/amdgpu: move debug_vm handling to amdgpu_cs_parser_fini Christian König
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=20260622093929.EEC1C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=pierre-eric.pelloux-prayer@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox