[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAG-2HqXG0R_sEZGekVPX5kYxjrRdviG_kdqsLTWEgQ1r-Qc0OQ@mail.gmail.com>
Date: Fri, 6 Sep 2013 13:57:22 +0200
From: Tom Gundersen <teg@...m.no>
To: David Herrmann <dh.herrmann@...il.com>
Cc: Geert Uytterhoeven <geert@...ux-m68k.org>,
"the arch/x86 maintainers" <x86@...nel.org>,
linux-kernel <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] x86: simplefb: avoid overflow
On Fri, Sep 6, 2013 at 1:24 PM, David Herrmann <dh.herrmann@...il.com> wrote:
> Hi
>
> On Fri, Sep 6, 2013 at 12:59 PM, Geert Uytterhoeven
> <geert@...ux-m68k.org> wrote:
>> On Fri, Sep 6, 2013 at 11:55 AM, David Herrmann <dh.herrmann@...il.com> wrote:
>>> On Fri, Sep 6, 2013 at 11:32 AM, Tom Gundersen <teg@...m.no> wrote:
>>>> lfb_size can easily be say 4M, which would make the bitshit overflow and
>>>> the test fail.
>>>>
>>>> Signed-off-by: Tom Gundersen <teg@...m.no>
>>>> Cc: David Herrmann <dh.herrmann@...il.com>
>>>> Cc: H. Peter Anvin <hpa@...or.com>
>>>> ---
>>>> 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) {
>>
>> On 32-bit, "unsigned long" is the same size as __u32, so this doesn't
>> make any difference.
>
> lfb_size cannot be 4M on 32bit machines. Well, if it is, the firmware
> passed bogus information as you cannot have a 262G-region on 32bit.
> But on 64bit it can pass 4M just fine.
> So we don't care for the 32bit case here, only 64bit. The (__u64) cast
> would be more obvious. Don't know.. It's just a sanity check, anyways,
> so I'm fine with it.
I used unsigned long simply to match the type of len...
>>> 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..
>>
>> "lfb_size * 65535" is the same. "lfb_size" is __u32, "65535" is int.
>> So there's no implicit cast. Or am I missing something?
>
> Yepp, indeed. My bad, so vesafb doesn't do any better here.
>
> I wonder, though, which firmware passes such values. It means the
> lfb_size area is reserved >4G. We do have huge VMEM these days..
> Tom, on what hardware did you hit that?
As always when weird things happen:
DMI: Apple Inc. MacBookAir5,1/Mac-66F35F19FE2A0D05, BIOS
MBA51.88Z.00EF.B01.1207271122 07/27/2012
Cheers,
Tom
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists