]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/amdkfd: fix a vulnerability of integer overflow in kfd debugger
authorEric Huang <jinhuieric.huang@amd.com>
Tue, 12 May 2026 14:19:52 +0000 (10:19 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 May 2026 16:01:13 +0000 (12:01 -0400)
get_queue_ids() computes array_size = num_queues * sizeof(uint32_t),
which could overflow on 32-bit size_t build. using array_size()
instead, it saturates to SIZE_MAX on overflow.

Signed-off-by: Eric Huang <jinhuieric.huang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 2d57a0475f085c08b49312dfd8edcb461845f285)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c

index e0a31e11f0ff76ff368ba15a2eb2dc5a8d13ab9d..0d7296c739ed7bb942c13e9b4dd044657578f040 100644 (file)
@@ -3308,12 +3308,14 @@ static void copy_context_work_handler(struct work_struct *work)
 
 static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array)
 {
-       size_t array_size = num_queues * sizeof(uint32_t);
-
        if (!usr_queue_id_array)
                return NULL;
 
-       return memdup_user(usr_queue_id_array, array_size);
+       if (num_queues > KFD_MAX_NUM_OF_QUEUES_PER_PROCESS)
+               return ERR_PTR(-EINVAL);
+
+       return memdup_user(usr_queue_id_array,
+                          array_size(num_queues, sizeof(uint32_t)));
 }
 
 int resume_queues(struct kfd_process *p,