diff options
author | Xi Wang <xi.wang@gmail.com> | 2011-11-23 01:12:01 -0500 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2013-04-05 09:09:34 +0300 |
commit | a6e9dd49814f608da0b1d52ccc3b4b18aa6a0a61 (patch) | |
tree | ee2ecd830eb94eb83f4242247f93114e91f7efe7 | |
parent | 8622f0ea16f1691519cf0f693f0cb9ae99daf583 (diff) | |
download | kernel-mfld-blackbay-a6e9dd49814f608da0b1d52ccc3b4b18aa6a0a61.tar.gz kernel-mfld-blackbay-a6e9dd49814f608da0b1d52ccc3b4b18aa6a0a61.tar.bz2 kernel-mfld-blackbay-a6e9dd49814f608da0b1d52ccc3b4b18aa6a0a61.zip |
drm: integer overflow in drm_mode_dirtyfb_ioctl()
commit a5cd335165e31db9dbab636fd29895d41da55dd2 upstream.
There is a potential integer overflow in drm_mode_dirtyfb_ioctl()
if userspace passes in a large num_clips. The call to kmalloc would
allocate a small buffer, and the call to fb->funcs->dirty may result
in a memory corruption.
Reported-by: Haogang Chen <haogangchen@gmail.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 4 | ||||
-rw-r--r-- | include/drm/drm_mode.h | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 8f64379be04..5b1eb0f31f7 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -2712,6 +2712,10 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev, } if (num_clips && clips_ptr) { + if (num_clips < 0 || num_clips > DRM_MODE_FB_DIRTY_MAX_CLIPS) { + ret = -EINVAL; + goto out_err1; + } clips = kzalloc(num_clips * sizeof(*clips), GFP_KERNEL); if (!clips) { ret = -ENOMEM; diff --git a/include/drm/drm_mode.h b/include/drm/drm_mode.h index 51380c0db82..7502435a370 100644 --- a/include/drm/drm_mode.h +++ b/include/drm/drm_mode.h @@ -410,6 +410,8 @@ struct drm_mode_fb_cmd2 { #define DRM_MODE_FB_DIRTY_ANNOTATE_FILL 0x02 #define DRM_MODE_FB_DIRTY_FLAGS 0x03 +#define DRM_MODE_FB_DIRTY_MAX_CLIPS 256 + /* * Mark a region of a framebuffer as dirty. * |