[PATCH 01/51] drm: Be more paranoid with integer overflows

2012-10-25 Thread ville.syrj...@linux.intel.com
From: Ville Syrj?l? 

Make sure 'width * cpp' and 'height * pitch + offset' don't exceed
UINT_MAX.

Signed-off-by: Ville Syrj?l? 
Reviewed-by: Alex Deucher 
---
 drivers/gpu/drm/drm_crtc.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index ef1b221..d9a639c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2280,13 +2280,21 @@ static int framebuffer_check(const struct 
drm_mode_fb_cmd2 *r)

for (i = 0; i < num_planes; i++) {
unsigned int width = r->width / (i != 0 ? hsub : 1);
+   unsigned int height = r->height / (i != 0 ? vsub : 1);
+   unsigned int cpp = drm_format_plane_cpp(r->pixel_format, i);

if (!r->handles[i]) {
DRM_DEBUG_KMS("no buffer object handle for plane %d\n", 
i);
return -EINVAL;
}

-   if (r->pitches[i] < drm_format_plane_cpp(r->pixel_format, i) * 
width) {
+   if ((uint64_t) width * cpp > UINT_MAX)
+   return -ERANGE;
+
+   if ((uint64_t) height * r->pitches[i] + r->offsets[i] > 
UINT_MAX)
+   return -ERANGE;
+
+   if (r->pitches[i] < width * cpp) {
DRM_DEBUG_KMS("bad pitch %u for plane %d\n", 
r->pitches[i], i);
return -EINVAL;
}
-- 
1.7.8.6



[PATCH 01/51] drm: Be more paranoid with integer overflows

2012-10-25 Thread ville . syrjala
From: Ville Syrjälä ville.syrj...@linux.intel.com

Make sure 'width * cpp' and 'height * pitch + offset' don't exceed
UINT_MAX.

Signed-off-by: Ville Syrjälä ville.syrj...@linux.intel.com
Reviewed-by: Alex Deucher alexander.deuc...@amd.com
---
 drivers/gpu/drm/drm_crtc.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index ef1b221..d9a639c 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -2280,13 +2280,21 @@ static int framebuffer_check(const struct 
drm_mode_fb_cmd2 *r)
 
for (i = 0; i  num_planes; i++) {
unsigned int width = r-width / (i != 0 ? hsub : 1);
+   unsigned int height = r-height / (i != 0 ? vsub : 1);
+   unsigned int cpp = drm_format_plane_cpp(r-pixel_format, i);
 
if (!r-handles[i]) {
DRM_DEBUG_KMS(no buffer object handle for plane %d\n, 
i);
return -EINVAL;
}
 
-   if (r-pitches[i]  drm_format_plane_cpp(r-pixel_format, i) * 
width) {
+   if ((uint64_t) width * cpp  UINT_MAX)
+   return -ERANGE;
+
+   if ((uint64_t) height * r-pitches[i] + r-offsets[i]  
UINT_MAX)
+   return -ERANGE;
+
+   if (r-pitches[i]  width * cpp) {
DRM_DEBUG_KMS(bad pitch %u for plane %d\n, 
r-pitches[i], i);
return -EINVAL;
}
-- 
1.7.8.6

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel