Skip to content

Commit 6dfa2fa

Browse files
committed
drm/etnaviv: limit submit sizes
Currently we allow rediculous amounts of kernel memory being allocated via the etnaviv GEM_SUBMIT ioctl, which is a pretty easy DoS vector. Put some reasonable limits in to fix this. The commandstream size is limited to 64KB, which was already a soft limit on older kernels after which the kernel only took submits on a best effort base, so there is no userspace that tries to submit commandstreams larger than this. Even if the whole commandstream is a single incrementing address load, the size limit also limits the number of potential relocs and referenced buffers to slightly under 64K, so use the same limit for those arguments. The performance monitoring infrastructure currently supports less than 50 performance counter signals, so limiting them to 128 on a single submit seems like a reasonably future-proof number for now. This number can be bumped if needed without breaking the interface. Cc: [email protected] Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Lucas Stach <[email protected]> Reviewed-by: Christian Gmeiner <[email protected]>
1 parent 96894b7 commit 6dfa2fa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,12 @@ int etnaviv_ioctl_gem_submit(struct drm_device *dev, void *data,
469469
return -EINVAL;
470470
}
471471

472+
if (args->stream_size > SZ_64K || args->nr_relocs > SZ_64K ||
473+
args->nr_bos > SZ_64K || args->nr_pmrs > 128) {
474+
DRM_ERROR("submit arguments out of size limits\n");
475+
return -EINVAL;
476+
}
477+
472478
/*
473479
* Copy the command submission and bo array to kernel space in
474480
* one go, and do this outside of any locks.

0 commit comments

Comments
 (0)