]> www.infradead.org Git - users/jedix/linux-maple.git/commit
drm/amdgpu: Fix integer overflow issues in amdgpu_userq_fence.c
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 23 May 2025 16:05:58 +0000 (19:05 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 3 Jun 2025 19:06:35 +0000 (15:06 -0400)
commit98a46a408998102af5c45adce0871acd7967bb59
tree6389cdbb587d724c8093867b9b9ed98fc3311788
parent5cccf10f652122a17b40df9d672ccf2ed69cd82f
drm/amdgpu: Fix integer overflow issues in amdgpu_userq_fence.c

This patch only affects 32bit systems.  There are several integer
overflows bugs here but only the "sizeof(u32) * num_syncobj"
multiplication is a problem at runtime.  (The last lines of this patch).

These variables are u32 variables that come from the user.  The issue
is the multiplications can overflow leading to us allocating a smaller
buffer than intended.  For the first couple integer overflows, the
syncobj_handles = memdup_user() allocation is immediately followed by
a kmalloc_array():

syncobj = kmalloc_array(num_syncobj_handles, sizeof(*syncobj), GFP_KERNEL);

In that situation the kmalloc_array() works as a bounds check and we
haven't accessed the syncobj_handlesp[] array yet so the integer overflow
is harmless.

But the "num_syncobj" multiplication doesn't have that and the integer
overflow could lead to an out of bounds access.

Fixes: a292fdecd728 ("drm/amdgpu: Implement userqueue signal/wait IOCTL")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c