From: sashiko-bot@kernel.org
To: "Jesse Zhang" <Jesse.Zhang@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/amdkfd: return the memory violation data to the debugger
Date: Wed, 18 Nov 2026 06:06:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-220202@kernel.org> (raw)
In-Reply-To: <20261118055009.3005630-2-Jesse.Zhang@amd.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/amdkfd: use-after-free in kfd_process_destroy_pdds()
[1]
--
commit 27e966c319a74439c4a48d13a51742cea89473d5
Author: Jesse Zhang <Jesse.Zhang@amd.com>
drm/amdkfd: return the memory violation data to the debugger
This commit records the size of GPU VM fault exception data in
kfd_dbg_ev_raise() and frees vm_fault_exc_data when destroying the process
device.
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> index 546721b4d59ac..16131fdc55468 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -1253,6 +1253,7 @@ static void kfd_process_destroy_pdds(struct kfd_process *p)
> atomic_dec(&pdd->dev->kfd->kfd_processes_count);
> mutex_destroy(&pdd->doorbell_mutex);
>
> + kfree(pdd->vm_fault_exc_data);
> kfree(pdd);
> p->pdds[i] = NULL;
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but can
kfd_process_destroy_pdds() dereference freed pdd->dev and pdd->dev->kfd
memory [1] during device teardown?
When a KFD process exits, it is removed from kfd_processes_table before its
release work runs on kfd_process_wq. If kgd2kfd_teardown_processes() runs
after the last process is removed from kfd_processes_table, it returns early
and skips waiting for kfd_processes_count to reach zero:
drivers/gpu/drm/amd/amdkfd/kfd_device.c:kgd2kfd_teardown_processes() {
...
mutex_lock(&kfd_processes_mutex);
if (hash_empty(kfd_processes_table)) {
mutex_unlock(&kfd_processes_mutex);
return;
}
...
mutex_unlock(&kfd_processes_mutex);
/* wait all kfd processes use adev terminate */
while (!!atomic_read(&adev->kfd.dev->kfd_processes_count))
cond_resched();
}
CPU0 CPU1 (kworker)
kgd2kfd_teardown_processes()
if (hash_empty(kfd_processes_table))
return;
<device teardown frees kfd_node/kfd_dev>
kfd_process_wq_release()
kfd_process_destroy_pdds()
atomic_dec(&pdd->dev->kfd->...);
<-- use-after-free
[1] https://sashiko.dev/#/bug/linux-89a2e0c3-8eea-4d17-956c-8aac02272705
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118055009.3005630-1-Jesse.Zhang@amd.com?part=2
next prev parent reply other threads:[~2026-11-18 6:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 5:49 [PATCH 1/3] drm/amdkfd: only flush the TLB of devices whose queues got suspended Jesse Zhang
2026-11-18 5:49 ` [PATCH 2/3] drm/amdkfd: return the memory violation data to the debugger Jesse Zhang
2026-11-18 6:06 ` sashiko-bot [this message]
2026-11-18 5:50 ` [PATCH 3/3] drm/amdkfd: don't keep the debugger pointer when DBG_TRAP_ENABLE fails Jesse Zhang
2026-11-18 6:07 ` sashiko-bot
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=sashiko-outbox-220202@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Jesse.Zhang@amd.com \
--cc=amd-gfx@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.