From: "Kuehling, Felix" <felix.kuehling@amd.com>
To: "Changyul Lee" <lcy8047@gmail.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>
Cc: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>,
David Yat Sin <david.yatsin@amd.com>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amdkfd: lock event_mutex while counting events for CRIU
Date: Thu, 3 Dec 2026 11:42:26 -0500 [thread overview]
Message-ID: <4b0e4669-47cf-4606-b59e-ca51f1d9fc6a@amd.com> (raw)
In-Reply-To: <20261120031917.1708024-1-lcy8047@gmail.com>
On 2026-11-19 22:19, Changyul Lee wrote:
> criu_get_process_object_info() holds p->mutex while counting events
> in p->event_idr. Event creation and destruction use p->event_mutex,
> so the event IDR can change during the walk. If an event is removed,
> the walk can access a freed IDR node.
>
> Hold p->event_mutex while counting events.
> kfd_criu_checkpoint_events() uses the same lock when walking the
> event IDR. Event creation and destruction do not acquire p->mutex,
> so taking p->event_mutex while holding p->mutex preserves the lock
> order.
>
> Fixes: 40e8a766a761 ("drm/amdkfd: CRIU checkpoint and restore events")
> Signed-off-by: Changyul Lee <lcy8047@gmail.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
I applied the patch to amd-staging-drm-next.
Thanks,
Felix
> ---
> Found with a static analysis tool we are developing.
>
> Compile-tested only, with x86_64_defconfig plus DRM_AMDGPU, HSA_AMD
> and W=1.
>
> drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> index 3d2136adb62b..20e3bbd073a5 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
> @@ -2234,7 +2234,9 @@ static int criu_get_process_object_info(struct kfd_process *p,
> if (ret)
> return ret;
>
> + mutex_lock(&p->event_mutex);
> num_events = kfd_get_num_events(p);
> + mutex_unlock(&p->event_mutex);
>
> svm_range_get_info(p, &num_svm_ranges, &svm_priv_data_size);
>
>
> base-commit: 8dd68a79583aaf6df6fe4feea3ee9e9f26b02993
> --
> 2.43.0
prev parent reply other threads:[~2026-12-03 16:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 3:19 Changyul Lee
2026-12-03 16:42 ` Kuehling, Felix [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=4b0e4669-47cf-4606-b59e-ca51f1d9fc6a@amd.com \
--to=felix.kuehling@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=david.yatsin@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=lcy8047@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rajneesh.bhardwaj@amd.com \
--cc=simona@ffwll.ch \
/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
all inboxes | Powered by JetHome®