diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2013-04-05 02:54:52 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2013-04-05 02:54:52 +0000 |
commit | 3e18d2a00c298d50f8017e8c6c2819eec49569df (patch) | |
tree | c44d7056373ee311bfb7ae75295f73ae1480abd5 /sys/dev | |
parent | 013ee6c80f4cdef392d8d4e4bcffd98bea7e642f (diff) |
move the bounds check for execbuffer relocation count closer to linux
ok kettenis@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/pci/drm/i915/i915_drv.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sys/dev/pci/drm/i915/i915_drv.c b/sys/dev/pci/drm/i915/i915_drv.c index ea0f92ae592..839f06c1f92 100644 --- a/sys/dev/pci/drm/i915/i915_drv.c +++ b/sys/dev/pci/drm/i915/i915_drv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i915_drv.c,v 1.16 2013/04/03 19:57:17 kettenis Exp $ */ +/* $OpenBSD: i915_drv.c,v 1.17 2013/04/05 02:54:51 jsg Exp $ */ /* * Copyright (c) 2008-2009 Owain G. Ainsworth <oga@openbsd.org> * @@ -1684,11 +1684,17 @@ i915_gem_get_relocs_from_user(struct drm_i915_gem_exec_object2 *exec_list, u_int32_t buffer_count, struct drm_i915_gem_relocation_entry **relocs) { u_int32_t reloc_count = 0, reloc_index = 0, i; - int ret; + int ret, relocs_max; + + relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry); *relocs = NULL; for (i = 0; i < buffer_count; i++) { - if (reloc_count + exec_list[i].relocation_count < reloc_count) + /* First check for malicious input causing overflow in + * the worst case where we need to allocate the entire + * relocation tree as a single array. + */ + if (exec_list[i].relocation_count > relocs_max - reloc_count) return (EINVAL); reloc_count += exec_list[i].relocation_count; } |