drm/amdkfd: Check bounds on CRIU restore event id
Subsystems (3)
PATCH v2 1/1 drm/amdkfd: Check bounds on CRIU restore event id
The valid amdkfd event ids go from 0 to KFD_SIGNAL_EVENT_LIMIT - 1.
During CRIU restore, ensure that the provided event ids are in that range.
v2: No need for lower bound check since idr_alloc rejects negative inputs
--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3 -0
@@ -107,6 +107,9 @@ static int allocate_event_notification_slot(struct kfd_process *p, }if (restore_id) { +if (*restore_id >=KFD_SIGNAL_EVENT_LIMIT ) +return -EINVAL ; + id =idr_alloc (&p->event_idr, ev, *restore_id, *restore_id +1 ,GFP_KERNEL ); }else {
Signature · 1 line
2.34.1
AMD General
Quoted 27 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of David Francis
Sent: June 2, 2026 2:47 PM
To: [email protected]
Cc: Francis, David <[email protected]>
Subject: [PATCH V2] drm/amdkfd: Check bounds on CRIU restore event idThe valid amdkfd event ids go from 0 to
KFD_SIGNAL_EVENT_LIMIT- 1.During CRIU restore, ensure that the provided event ids are in that range.
v2: No need for lower bound check since
idr_allocrejects negative inputsSigned-off-by David Francis <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdkfd/kfd_events.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_events.c static int allocate_event_notification_slot(struct · line 115
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3
-0@@ -107,6 +107,9 @@ static int allocate_event_notification_slot(struct kfd_process *p, }if (restore_id) { +if (*restore_id >=KFD_SIGNAL_EVENT_LIMIT ) +return -EINVAL ; + id =idr_alloc (&p->event_idr, ev, *restore_id, *restore_id +1 ,GFP_KERNEL );
Not sure if I'm being nit-picky, but if restore_id is negative, then idr_alloc will return -EINVAL. That -EINVAL will go back up to the create_signal_event call, which gives a pr_warn of "Signal event wasn't created because out of kernel memory" , even though the issue was bad input. Mostly, I'm wondering if we need to add something in dmesg if idr_alloc fails for that reason, since someone could end up spending time debugging OOM when the issue is an invalid param. Or is a negative restore_id indicative of OOM?
Kent
Quoted 3 lines
} else {--
2.34.1
Quoted 2 lines
Not sure if I'm being nit-picky, but if
restore_idis negative, thenidr_allocwill return-EINVAL. That-EINVALwill go back up to thecreate_signal_eventcall, which gives > apr_warnof "Signal event wasn't created because out of kernel memory" , even though the issue was bad input. Mostly, I'm wondering if we need to add something > in dmesg ifidr_allocfails for that reason, since someone could end up spending time debugging OOM when the issue is an invalid param. Or is a negativerestore_idindicative of OOM?
Not a nit pick; nice catch.
I think "Signal event wasn't created because out of kernel memory" is just straight wrong - idr_alloc can fail with -ENOSPC if there isn't an available ID,, which is different from being out of memory.
David Francis
________________________________________
From: Russell, Kent <[email protected]>
Sent: Friday, June 5, 2026 12:16 PM
To: Francis, David; [email protected]
Cc: Francis, David
Subject: RE: [PATCH V2] drm/amdkfd: Check bounds on CRIU restore event id
AMD General
Quoted 27 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of David Francis
Sent: June 2, 2026 2:47 PM
To: [email protected]
Cc: Francis, David <[email protected]>
Subject: [PATCH V2] drm/amdkfd: Check bounds on CRIU restore event idThe valid amdkfd event ids go from 0 to
KFD_SIGNAL_EVENT_LIMIT- 1.During CRIU restore, ensure that the provided event ids are in that range.
v2: No need for lower bound check since
idr_allocrejects negative inputsSigned-off-by David Francis <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdkfd/kfd_events.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_events.c static int allocate_event_notification_slot(struct · line 115
Quoted 9 lines
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3
-0@@ -107,6 +107,9 @@ static int allocate_event_notification_slot(struct kfd_process *p, }if (restore_id) { +if (*restore_id >=KFD_SIGNAL_EVENT_LIMIT ) +return -EINVAL ; + id =idr_alloc (&p->event_idr, ev, *restore_id, *restore_id +1 ,GFP_KERNEL );
Not sure if I'm being nit-picky, but if restore_id is negative, then idr_alloc will return -EINVAL. That -EINVAL will go back up to the create_signal_event call, which gives a pr_warn of "Signal event wasn't created because out of kernel memory" , even though the issue was bad input. Mostly, I'm wondering if we need to add something in dmesg if idr_alloc fails for that reason, since someone could end up spending time debugging OOM when the issue is an invalid param. Or is a negative restore_id indicative of OOM?
Kent
Quoted 3 lines
} else {--
2.34.1