Skip to contentSkip to conversation

drm/amdkfd: Add upper bound check for num_of_nodes

PATCH Superseded Alysa Liu 2 participants 2 messages Mar 30

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Alysa Liu

author
#0 lore raw

PATCH v2 1/1 drm/amdkfd: Add upper bound check for num_of_nodes

drm/amdkfd: Add upper bound check for num_of_nodes in kfd_ioctl_get_process_apertures_new.

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +3 -0
index 1db565442c48..91f807c9e553 100644
@@ -776,6 +776,9 @@ static int kfd_ioctl_get_process_apertures_new(struct file *filp,
 		goto out_unlock;
 	}
 
+	if (args->num_of_nodes > p->n_pdds)
+		return -EINVAL;
+
 	/* Fill in process-aperture information for all available
 	 * nodes, but not more than args->num_of_nodes as that is
 	 * the amount of memory allocated by user
Signature · 1 line
2.34.1
#1 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Looked into this bit more. We need support max_nodes which includes CPU and GPU agents. P->n_pdds only include GPU agents. You need to add CPU agents also.

Best Regards,
Harish
________________________________
From: Liu, Alysa <[email protected]>
Sent: Monday, March 30, 2026 2:36 PM
To: [email protected] <[email protected]>
Cc: Kasiviswanathan, Harish <[email protected]>; Liu, Alysa <[email protected]>
Subject: [PATCH v2] drm/amdkfd: Add upper bound check for num_of_nodes

drm/amdkfd: Add upper bound check for num_of_nodes in kfd_ioctl_get_process_apertures_new.

---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +3 -0
index 1db565442c48..91f807c9e553 100644
@@ -776,6 +776,9 @@ static int kfd_ioctl_get_process_apertures_new(struct file *filp,
                 goto out_unlock;
         }
 
+       if (args->num_of_nodes > p->n_pdds)
+               return -EINVAL;
+
         /* Fill in process-aperture information for all available
          * nodes, but not more than args->num_of_nodes as that is
          * the amount of memory allocated by user

--
2.34.1