]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
accel/amdxdna: Fix an integer overflow in aie2_query_ctx_status_array()
authorLizhi Hou <lizhi.hou@amd.com>
Tue, 9 Sep 2025 15:45:31 +0000 (08:45 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:02:25 +0000 (14:02 +0100)
commit359653edd5374fbba28f93043554dcc494aee85f
treebd5db2bcbac638540149c06b660933ec795e4035
parent79197c6007f2afbfd7bcf5b9b80ccabf8483d774
accel/amdxdna: Fix an integer overflow in aie2_query_ctx_status_array()

[ Upstream commit 9e16c8bf9aebf629344cfd4cd5e3dc7d8c3f7d82 ]

The unpublished smatch static checker reported a warning.

drivers/accel/amdxdna/aie2_pci.c:904 aie2_query_ctx_status_array()
warn: potential user controlled sizeof overflow
'args->num_element * args->element_size' '1-u32max(user) * 1-u32max(user)'

Even this will not cause a real issue, it is better to put a reasonable
limitation for element_size and num_element. Add condition to make sure
the input element_size <= 4K and num_element <= 1K.

Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/dri-devel/aL56ZCLyl3tLQM1e@stanley.mountain/
Fixes: 2f509fe6a42c ("accel/amdxdna: Add ioctl DRM_IOCTL_AMDXDNA_GET_ARRAY")
Reviewed-by: Maciej Falkowski <maciej.falkowski@linux.intel.com>
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Link: https://lore.kernel.org/r/20250909154531.3469979-1-lizhi.hou@amd.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/accel/amdxdna/aie2_pci.c