mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 20:46:48 +02:00
accel/amdxdna: Fix an integer overflow in aie2_query_ctx_status_array()
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: 2f509fe6a4 ("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
This commit is contained in:
parent
b4505b6ad9
commit
9e16c8bf9a
|
|
@ -898,6 +898,12 @@ static int aie2_query_ctx_status_array(struct amdxdna_client *client,
|
|||
|
||||
drm_WARN_ON(&xdna->ddev, !mutex_is_locked(&xdna->dev_lock));
|
||||
|
||||
if (args->element_size > SZ_4K || args->num_element > SZ_1K) {
|
||||
XDNA_DBG(xdna, "Invalid element size %d or number of element %d",
|
||||
args->element_size, args->num_element);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
array_args.element_size = min(args->element_size,
|
||||
sizeof(struct amdxdna_drm_hwctx_entry));
|
||||
array_args.buffer = args->buffer;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user