Skip to content

Commit ea78f8c

Browse files
amd-sukhatrialexdeucher
authored andcommitted
drm/amdgpu: add upper bound check on user inputs in signal ioctl
Huge input values in amdgpu_userq_signal_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. 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 be267e1) Cc: stable@vger.kernel.org
1 parent 7b7d769 commit ea78f8c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
static const struct dma_fence_ops amdgpu_userq_fence_ops;
3636
static struct kmem_cache *amdgpu_userq_fence_slab;
3737

38+
#define AMDGPU_USERQ_MAX_HANDLES (1U << 16)
39+
3840
int amdgpu_userq_fence_slab_init(void)
3941
{
4042
amdgpu_userq_fence_slab = kmem_cache_create("amdgpu_userq_fence",
@@ -478,6 +480,11 @@ int amdgpu_userq_signal_ioctl(struct drm_device *dev, void *data,
478480
if (!amdgpu_userq_enabled(dev))
479481
return -ENOTSUPP;
480482

483+
if (args->num_syncobj_handles > AMDGPU_USERQ_MAX_HANDLES ||
484+
args->num_bo_write_handles > AMDGPU_USERQ_MAX_HANDLES ||
485+
args->num_bo_read_handles > AMDGPU_USERQ_MAX_HANDLES)
486+
return -EINVAL;
487+
481488
num_syncobj_handles = args->num_syncobj_handles;
482489
syncobj_handles = memdup_user(u64_to_user_ptr(args->syncobj_handles),
483490
size_mul(sizeof(u32), num_syncobj_handles));

0 commit comments

Comments
 (0)