Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Reviewed-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Signed-off-by: Alysa Liu <Alysa.Liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 98ff46a5ea090c14d2cdb4f5b993b05d74f3949f)
Cc: stable@vger.kernel.org

authored by

Alysa Liu and committed by
Alex Deucher
74b73fa5 11b31549

+15
+3
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
··· 776 776 goto out_unlock; 777 777 } 778 778 779 + if (args->num_of_nodes > kfd_topology_get_num_devices()) 780 + return -EINVAL; 781 + 779 782 /* Fill in process-aperture information for all available 780 783 * nodes, but not more than args->num_of_nodes as that is 781 784 * the amount of memory allocated by user
+1
drivers/gpu/drm/amd/amdkfd/kfd_priv.h
··· 1191 1191 return NULL; 1192 1192 } 1193 1193 int kfd_topology_enum_kfd_devices(uint8_t idx, struct kfd_node **kdev); 1194 + uint32_t kfd_topology_get_num_devices(void); 1194 1195 int kfd_numa_node_to_apic_id(int numa_node_id); 1195 1196 uint32_t kfd_gpu_node_num(void); 1196 1197
+11
drivers/gpu/drm/amd/amdkfd/kfd_topology.c
··· 2297 2297 return res; 2298 2298 } 2299 2299 2300 + uint32_t kfd_topology_get_num_devices(void) 2301 + { 2302 + uint32_t num_devices; 2303 + 2304 + down_read(&topology_lock); 2305 + num_devices = sys_props.num_devices; 2306 + up_read(&topology_lock); 2307 + 2308 + return num_devices; 2309 + } 2310 + 2300 2311 /* kfd_topology_enum_kfd_devices - Enumerate through all devices in KFD 2301 2312 * topology. If GPU device is found @idx, then valid kfd_dev pointer is 2302 2313 * returned through @kdev