aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <[email protected]>2018-09-26 18:11:22 +0200
committerBartlomiej Zolnierkiewicz <[email protected]>2018-09-26 18:11:22 +0200
commit1bafcbf59fed92af58955024452f45430d3898c5 (patch)
treeee45bb8b910f281248c4528ddc290e75e4253241
parentd85536cde91fcfed6fb8d983783bd2b92c843939 (diff)
fbdev/omapfb: fix omapfb_memory_read infoleak
OMAPFB_MEMORY_READ ioctl reads pixels from the LCD's memory and copies them to a userspace buffer. The code has two issues: - The user provided width and height could be large enough to overflow the calculations - The copy_to_user() can copy uninitialized memory to the userspace, which might contain sensitive kernel information. Fix these by limiting the width & height parameters, and only copying the amount of data that we actually received from the LCD. Signed-off-by: Tomi Valkeinen <[email protected]> Reported-by: Jann Horn <[email protected]> Cc: [email protected] Cc: [email protected] Cc: Will Deacon <[email protected]> Cc: Jann Horn <[email protected]> Cc: Tony Lindgren <[email protected]> Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]>
-rw-r--r--drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c b/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c
index ef69273074ba..a3edb20ea4c3 100644
--- a/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c
@@ -496,6 +496,9 @@ static int omapfb_memory_read(struct fb_info *fbi,
if (!access_ok(VERIFY_WRITE, mr->buffer, mr->buffer_size))
return -EFAULT;
+ if (mr->w > 4096 || mr->h > 4096)
+ return -EINVAL;
+
if (mr->w * mr->h * 3 > mr->buffer_size)
return -EINVAL;
@@ -509,7 +512,7 @@ static int omapfb_memory_read(struct fb_info *fbi,
mr->x, mr->y, mr->w, mr->h);
if (r > 0) {
- if (copy_to_user(mr->buffer, buf, mr->buffer_size))
+ if (copy_to_user(mr->buffer, buf, r))
r = -EFAULT;
}