drm/amdkfd: Check bounds in allocate_event_notification_slot
Subsystems (3)
PATCH v2 1/1 drm/amdkfd: Check bounds in allocate_event_notification_slot
The valid event ids go from 0 to KFD_SIGNAL_EVENT_LIMIT
allocate_event_notification_slot has an option to specify an event id to allocate at, used by CRIU. We weren't checking the bounds on that value.
Check them.
v2: Lower bounds check is unecessary because of idr_alloc already rejecting negative numbers. Upper bounds check should be KFD_SIGNAL_EVENT_LIMIT since the signal mode mappings might not yet exist
--- 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 42 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of David Francis
Sent: Wednesday, June 24, 2026 9:38 AM
To: [email protected]
Cc: Francis, David <[email protected]>
Subject: [PATCH v2] drm/amdkfd: Check bounds inallocate_event_notification_slotThe valid event ids go from 0 to
KFD_SIGNAL_EVENT_LIMIT
allocate_event_notification_slothas an option to specify an event id to allocate at, used by CRIU. We weren't checking the bounds on that value.Check them.
v2: Lower bounds check is unecessary because of
idr_allocalready rejecting negative numbers. Upper bounds check should beKFD_SIGNAL_EVENT_LIMITsince the signal mode mappings might not yet existSigned-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 +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 {--
2.34.1