[PATCH] fbdev/omapfb: fix omapfb_memory_read infoleak
Bartlomiej Zolnierkiewicz
b.zolnierkie at samsung.com
Wed Sep 26 15:45:52 UTC 2018
[ added dri-devel at lists.freedesktop.org to Cc: ]
On 09/12/2018 09:30 AM, Tomi Valkeinen wrote:
> 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 <tomi.valkeinen at ti.com>
> Reported-by: Jann Horn <jannh at google.com>
> Cc: stable at vger.kernel.org
> Cc: security at kernel.org
> Cc: Will Deacon <will.deacon at arm.com>
> Cc: Jann Horn <jannh at google.com>
> Cc: Tony Lindgren <tony at atomide.com>
Patch queued for 4.19, thanks.
> ---
> drivers/video/fbdev/omap2/omapfb/omapfb-ioctl.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> 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;
> }
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
More information about the dri-devel
mailing list