mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
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]>
This commit is contained in:
parent
d85536cde9
commit
1bafcbf59f
1 changed files with 4 additions and 1 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue