Commit 7dcd2499 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Rephrase pwrite bounds checking to avoid any potential overflow

... and do the same for pread.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: stable@kernel.org
parent ce9d419d
...@@ -471,12 +471,8 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data, ...@@ -471,12 +471,8 @@ i915_gem_pread_ioctl(struct drm_device *dev, void *data,
return -ENOENT; return -ENOENT;
obj_priv = to_intel_bo(obj); obj_priv = to_intel_bo(obj);
/* Bounds check source. /* Bounds check source. */
* if (args->offset > obj->size || args->size > obj->size - args->offset) {
* XXX: This could use review for overflow issues...
*/
if (args->offset > obj->size || args->size > obj->size ||
args->offset + args->size > obj->size) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
...@@ -939,12 +935,8 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data, ...@@ -939,12 +935,8 @@ i915_gem_pwrite_ioctl(struct drm_device *dev, void *data,
return -ENOENT; return -ENOENT;
obj_priv = to_intel_bo(obj); obj_priv = to_intel_bo(obj);
/* Bounds check destination. /* Bounds check destination. */
* if (args->offset > obj->size || args->size > obj->size - args->offset) {
* XXX: This could use review for overflow issues...
*/
if (args->offset > obj->size || args->size > obj->size ||
args->offset + args->size > obj->size) {
ret = -EINVAL; ret = -EINVAL;
goto err; goto err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment