From: sashiko-bot@kernel.org
To: "Binbin Deng" <18983559317@163.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v1] drm/amdkfd: Fix use-after-free in the process creation error path
Date: Fri, 09 Oct 2026 13:40:06 +0000 [thread overview]
Message-ID: <sashiko-outbox-165655@kernel.org> (raw)
In-Reply-To: <20261009132619.40151-1-18983559317@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] amdkfd: incomplete fix for UAF in create_process() error path
--
commit dcdae9cca3430fa247abfc570505faf612c7c75d
Author: Binbin Deng <18983559317@163.com>
drm/amdkfd: Fix use-after-free in the process creation error path
This commit attempts to fix a use-after-free race during process creation
by adding an SRCU grace period wait in the error path after removing the
process from the hash table.
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
> @@ -1761,6 +1761,7 @@ struct kfd_process *create_process(const struct task_struct *thread, bool primar
> kfd_process_free_id(process);
> err_register_notifier:
> hash_del_rcu(&process->kfd_processes);
> + synchronize_srcu(&kfd_processes_srcu);
[Severity: High]
Does this synchronize_srcu() guarantee no threads are accessing the object
when we eventually reach kfree(process) at the end of the error path?
If a concurrent reader finds the process before it is removed from the hash
table, it will increment the reference count and then immediately drop the
SRCU lock:
kfd_lookup_process_by_mm() {
...
p = find_process_by_mm(mm);
if (p)
kref_get(&p->ref);
srcu_read_unlock(&kfd_processes_srcu, idx);
...
}
Because the concurrent reader has already dropped the SRCU lock,
synchronize_srcu() will return immediately.
The create_process() error path then continues tearing down the state and
eventually reaches the err_event_init label:
create_process() {
...
err_event_init:
mutex_destroy(&process->mutex);
kfree(process);
...
}
This unconditionally frees the process memory, completely bypassing the
kref mechanism.
Could this cause a use-after-free if the concurrent reader is still actively
holding and using the pointer?
> svm_range_list_fini(process);
> err_init_svm_range_list:
> kfd_process_free_outstanding_kfd_bos(process);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009132619.40151-1-18983559317@163.com?part=1
next prev parent reply other threads:[~2026-10-09 13:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 13:26 [PATCH v1] drm/amdkfd: Fix use-after-free in the process creation error path Binbin Deng
2026-10-09 13:40 ` sashiko-bot [this message]
2026-10-09 14:38 ` Kuehling, Felix
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-165655@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=18983559317@163.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.