Skip to contentSkip to conversation

drm/amdkfd: Check bounds on CRIU restore event id

PATCH Superseded David Francis 1 participant 1 message May 12

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 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.

(The CRIU input is a uint32_t, so it can't be negative, but check just for the sake of the function being clear)

---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3 -0
index e9be798c0a2b..2c63dfe8e189 100644
@@ -107,6 +107,9 @@ static int allocate_event_notification_slot(struct kfd_process *p,
 	}
 
 	if (restore_id) {
+		if (*restore_id <= 0 || *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