Re: [PATCH] x86: simplefb: avoid overflow

From: David Herrmann
Date: Fri Sep 06 2013 - 05:55:34 EST


Hi

On Fri, Sep 6, 2013 at 11:32 AM, Tom Gundersen <teg@xxxxxxx> wrote:
> lfb_size can easily be say 4M, which would make the bitshit overflow and
> the test fail.
>
> Signed-off-by: Tom Gundersen <teg@xxxxxxx>
> Cc: David Herrmann <dh.herrmann@xxxxxxxxx>
> Cc: H. Peter Anvin <hpa@xxxxxxxxx>
> ---
> arch/x86/kernel/sysfb_simplefb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/sysfb_simplefb.c b/arch/x86/kernel/sysfb_simplefb.c
> index 22513e9..fff44a5 100644
> --- a/arch/x86/kernel/sysfb_simplefb.c
> +++ b/arch/x86/kernel/sysfb_simplefb.c
> @@ -72,7 +72,7 @@ __init int create_simplefb(const struct screen_info *si,
> * the part that is occupied by the framebuffer */
> len = mode->height * mode->stride;
> len = PAGE_ALIGN(len);
> - if (len > si->lfb_size << 16) {
> + if (len > ((unsigned long) si->lfb_size) << 16) {

Nice catch. vesafb uses "lfb_size * 65535" which causes an implicit
cast. I thought <<16 looks nicer but that doesn't do any implicit
cast..

Nothing crucial, as it only causes the simple-fb conversion to fail.
But would still be good to see in -rc2:
Reviewed-by: David Herrmann <dh.herrmann@xxxxxxxxx>

Thanks
David

> printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n");
> return -EINVAL;
> }
> --
> 1.8.4
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/