[14/25] drm/i915: Rephrase pwrite bounds checking to avoid any potential overflow

From: Greg KH
Date: Tue Nov 22 2011 - 20:03:59 EST


2.6.32-longterm review patch. If anyone has any objections, please let me know.

------------------
Content-Length: 1407
Lines: 47

From: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>

commit 7dcd2499deab8f10011713c40bc2f309c9b65077 upstream

... and do the same for pread.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
drivers/gpu/drm/i915/i915_gem.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -482,12 +482,8 @@ i915_gem_pread_ioctl(struct drm_device *
return -EBADF;
obj_priv = obj->driver_private;

- /* Bounds check source.
- *
- * XXX: This could use review for overflow issues...
- */
- if (args->offset > obj->size || args->size > obj->size ||
- args->offset + args->size > obj->size) {
+ /* Bounds check source. */
+ if (args->offset > obj->size || args->size > obj->size - args->offset) {
ret = -EINVAL;
goto err;
}
@@ -960,12 +956,8 @@ i915_gem_pwrite_ioctl(struct drm_device
return -EBADF;
obj_priv = obj->driver_private;

- /* Bounds check destination.
- *
- * XXX: This could use review for overflow issues...
- */
- if (args->offset > obj->size || args->size > obj->size ||
- args->offset + args->size > obj->size) {
+ /* Bounds check destination. */
+ if (args->offset > obj->size || args->size > obj->size - args->offset) {
ret = -EINVAL;
goto err;
}


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/