diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-11-21 04:23:48 -0500 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-11-21 04:30:58 -0500 |
commit | d1d788302e8c76e5138dfa61f4a5eee4f72a748f (patch) | |
tree | 4e8504aeaafefb11d7c973836da3323f72f02795 /drivers/gpu | |
parent | 16c59ef33b389217c29122235e475557bc1412a1 (diff) |
drm/i915: Prevent integer overflow when validating the execbuffer
Commit 2549d6c2 removed the vmalloc used for temporary storage of the
relocation lists used during execbuffer. However, our use of vmalloc was
being protected by an integer overflow check which we do want to
preserve!
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 17b1cba3b5f1..bc4164590054 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
@@ -3630,8 +3630,15 @@ validate_exec_list(struct drm_i915_gem_exec_object2 *exec, | |||
3630 | 3630 | ||
3631 | for (i = 0; i < count; i++) { | 3631 | for (i = 0; i < count; i++) { |
3632 | char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr; | 3632 | char __user *ptr = (char __user *)(uintptr_t)exec[i].relocs_ptr; |
3633 | size_t length = exec[i].relocation_count * sizeof(struct drm_i915_gem_relocation_entry); | 3633 | int length; /* limited by fault_in_pages_readable() */ |
3634 | 3634 | ||
3635 | /* First check for malicious input causing overflow */ | ||
3636 | if (exec[i].relocation_count > | ||
3637 | INT_MAX / sizeof(struct drm_i915_gem_relocation_entry)) | ||
3638 | return -EINVAL; | ||
3639 | |||
3640 | length = exec[i].relocation_count * | ||
3641 | sizeof(struct drm_i915_gem_relocation_entry); | ||
3635 | if (!access_ok(VERIFY_READ, ptr, length)) | 3642 | if (!access_ok(VERIFY_READ, ptr, length)) |
3636 | return -EFAULT; | 3643 | return -EFAULT; |
3637 | 3644 | ||