Skip to contentSkip to conversation

drm/amdkfd: Check bounds on CRIU restore event id

PATCH In review David Francis 2 participants 2 messages Jun 24 – Jul 6

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

v3: Also change error message to reflect new error condition

---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +4 -1
index e9be798c0a2b..52347726c6b0 100644
@@ -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 {
@@ -204,7 +207,7 @@ static int create_signal_event(struct file *devkfd, struct kfd_process *p,
 
 	ret = allocate_event_notification_slot(p, ev, restore_id);
 	if (ret) {
-		pr_warn("Signal event wasn't created because out of kernel memory\n");
+		pr_warn("Failed to create signal event notification slot\n");
 		return ret;
 	}
 
Signature · 1 line
2.34.1
Reviewed-by on v3 1/1
#1 lore raw

AMD General

Quoted 51 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of David Francis
Sent: Wednesday, June 24, 2026 9:48 AM
To: [email protected]
Cc: Russell, Kent <[email protected]>; Francis, David <[email protected]>
Subject: [PATCH v3] 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

v3: Also change error message to reflect new error condition

---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +3 -0
index e9be798c0a2b..52347726c6b0 100644
@@ -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 {
drivers/gpu/drm/amd/amdkfd/kfd_events.c +1 -1
@@ -204,7 +207,7 @@ static int create_signal_event(struct file *devkfd, struct
 kfd_process *p,
 
      ret = allocate_event_notification_slot(p, ev, restore_id);
      if (ret) {
-             pr_warn("Signal event wasn't created because out of kernel
 memory\n");
+             pr_warn("Failed to create signal event notification slot\n");
              return ret;
      }

--
2.34.1