mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:04:51 +01:00
drm/amdgpu: add upper bound check on user inputs in wait ioctl
Huge input values in amdgpu_userq_wait_ioctl can lead to a OOM and could be exploited. So check these input value against AMDGPU_USERQ_MAX_HANDLES which is big enough value for genuine use cases and could potentially avoid OOM. v2: squash in Srini's fix Signed-off-by: Sunil Khatri <sunil.khatri@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit fcec012c664247531aed3e662f4280ff804d1476) Cc: stable@vger.kernel.org
This commit is contained in:
parent
ea78f8c68f
commit
64ac7c09fc
1 changed files with 5 additions and 0 deletions
|
|
@ -671,6 +671,11 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void *data,
|
|||
if (!amdgpu_userq_enabled(dev))
|
||||
return -ENOTSUPP;
|
||||
|
||||
if (wait_info->num_syncobj_handles > AMDGPU_USERQ_MAX_HANDLES ||
|
||||
wait_info->num_bo_write_handles > AMDGPU_USERQ_MAX_HANDLES ||
|
||||
wait_info->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)
|
||||
return -EINVAL;
|
||||
|
||||
num_read_bo_handles = wait_info->num_bo_read_handles;
|
||||
bo_handles_read = memdup_user(u64_to_user_ptr(wait_info->bo_read_handles),
|
||||
size_mul(sizeof(u32), num_read_bo_handles));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue