* [PATCH] drm/amdkfd: Correctly handle multi-xcc mqd size in CRIU restore
@ 2026-11-23 19:25 David Francis
2026-11-23 19:34 ` sashiko-bot
2026-11-23 20:14 ` Yat Sin, David
0 siblings, 2 replies; 3+ messages in thread
From: David Francis @ 2026-11-23 19:25 UTC (permalink / raw)
To: amd-gfx; +Cc: David Francis, David Yat Sin, Alex Deucher
kfd_criu_restore_queue validates that a CRIU restore has the
correct mqd size, but doesn't correctly handle that the mqd
will be scaled but the number of xccs.
Change the check to handle multiple xccs correctly.
Cc: David Yat Sin <david.yatsin@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Fixes: 47ea05f246be ("drm/amdkfd: Check bounds on CRIU restore queue type and mqd size")
Signed-off-by: David Francis <David.Francis@amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
index 6cc0365e9b11..6a9d7d31c8d4 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
@@ -1030,7 +1030,8 @@ int kfd_criu_restore_queue(struct kfd_process *p,
goto exit;
}
- if (q_data->mqd_size != mqd_size_from_queue_type(pdd->dev->dqm, q_data->type)) {
+ if (q_data->mqd_size != mqd_size_from_queue_type(pdd->dev->dqm, q_data->type) *
+ NUM_XCC(pdd->dev->xcc_mask)) {
ret = -EINVAL;
goto exit;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amdkfd: Correctly handle multi-xcc mqd size in CRIU restore
2026-11-23 19:25 [PATCH] drm/amdkfd: Correctly handle multi-xcc mqd size in CRIU restore David Francis
@ 2026-11-23 19:34 ` sashiko-bot
2026-11-23 20:14 ` Yat Sin, David
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-23 19:34 UTC (permalink / raw)
To: David Francis, amd-gfx
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: missing bounds check in
kfd_criu_restore_queue() [1]
--
commit b6c60f35cb12af1932936a6a6d849d52fd98120b
Author: David Francis <David.Francis@amd.com>
drm/amdkfd: Correctly handle multi-xcc mqd size in CRIU restore
This commit scales the expected mqd_size check in kfd_criu_restore_queue()
by the number of XCCs on the device.
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> index b68e884b1c37a..2b86d359c4065 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> @@ -1041,7 +1041,8 @@ int kfd_criu_restore_queue(struct kfd_process *p,
> goto exit;
> }
>
> - if (q_data->mqd_size != mqd_size_from_queue_type(pdd->dev->dqm, q_data->type)) {
> + if (q_data->mqd_size != mqd_size_from_queue_type(pdd->dev->dqm, q_data->type) *
> + NUM_XCC(pdd->dev->xcc_mask)) {
> ret = -EINVAL;
> goto exit;
> }
[Severity: Critical]
This problem wasn't introduced by this patch, but can an unvalidated
q_data->priority cause an out-of-bounds read of pipe_priority_map[]
[1]?
kfd_criu_restore_queue() checks q_data->type and q_data->mqd_size after
copy_from_user(), then set_queue_properties_from_criu() copies
q_data->priority into qp.priority without checking it against
KFD_MAX_QUEUE_PRIORITY (15):
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c:set_queue_properties_from_criu() {
qp->is_interop = false;
qp->queue_percent = q_data->q_percent;
qp->priority = q_data->priority;
...
}
When pqm_create_queue() invokes the hardware-specific update_mqd() ->
set_priority() path, qp.priority indexes directly into the 16-element
pipe_priority_map[] array and writes the result into the MQD, which can
crash the kernel or leak out-of-bounds kernel memory through a
userspace-mapped MQD.
[1] https://sashiko.dev/#/bug/linux-ce93c1d0-79a1-4b46-89c1-185592185549
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261123192532.2062064-1-David.Francis@amd.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] drm/amdkfd: Correctly handle multi-xcc mqd size in CRIU restore
2026-11-23 19:25 [PATCH] drm/amdkfd: Correctly handle multi-xcc mqd size in CRIU restore David Francis
2026-11-23 19:34 ` sashiko-bot
@ 2026-11-23 20:14 ` Yat Sin, David
1 sibling, 0 replies; 3+ messages in thread
From: Yat Sin, David @ 2026-11-23 20:14 UTC (permalink / raw)
To: Francis, David, amd-gfx@lists.freedesktop.org; +Cc: Deucher, Alexander
AMD General
Reviewed-by: David Yat Sin <david.yatsin@amd.com>
> -----Original Message-----
> From: Francis, David <David.Francis@amd.com>
> Sent: Monday, November 23, 2026 2:26 PM
> To: amd-gfx@lists.freedesktop.org
> Cc: Francis, David <David.Francis@amd.com>; Yat Sin, David
> <David.YatSin@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>
> Subject: [PATCH] drm/amdkfd: Correctly handle multi-xcc mqd size in CRIU restore
>
> kfd_criu_restore_queue validates that a CRIU restore has the correct mqd size, but
> doesn't correctly handle that the mqd will be scaled but the number of xccs.
>
> Change the check to handle multiple xccs correctly.
>
> Cc: David Yat Sin <david.yatsin@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Fixes: 47ea05f246be ("drm/amdkfd: Check bounds on CRIU restore queue type and
> mqd size")
> Signed-off-by: David Francis <David.Francis@amd.com>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> index 6cc0365e9b11..6a9d7d31c8d4 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
> @@ -1030,7 +1030,8 @@ int kfd_criu_restore_queue(struct kfd_process *p,
> goto exit;
> }
>
> - if (q_data->mqd_size != mqd_size_from_queue_type(pdd->dev->dqm,
> q_data->type)) {
> + if (q_data->mqd_size != mqd_size_from_queue_type(pdd->dev->dqm,
> q_data->type) *
> + NUM_XCC(pdd->dev->xcc_mask)) {
> ret = -EINVAL;
> goto exit;
> }
> --
> 2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-23 20:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 19:25 [PATCH] drm/amdkfd: Correctly handle multi-xcc mqd size in CRIU restore David Francis
2026-11-23 19:34 ` sashiko-bot
2026-11-23 20:14 ` Yat Sin, David
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.