From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751768Ab3IFLJO (ORCPT ); Fri, 6 Sep 2013 07:09:14 -0400 Received: from terminus.zytor.com ([198.137.202.10]:53231 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751108Ab3IFLJN (ORCPT ); Fri, 6 Sep 2013 07:09:13 -0400 Message-ID: <5229B7BB.5020804@zytor.com> Date: Fri, 06 Sep 2013 04:08:43 -0700 From: "H. Peter Anvin" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Geert Uytterhoeven CC: David Herrmann , Tom Gundersen , the arch/x86 maintainers , linux-kernel , Ingo Molnar , Thomas Gleixner Subject: Re: [PATCH] x86: simplefb: avoid overflow References: <1378459933-367-1-git-send-email-teg@jklm.no> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/06/2013 03:59 AM, Geert Uytterhoeven wrote: > On Fri, Sep 6, 2013 at 11:55 AM, David Herrmann wrote: >> On Fri, Sep 6, 2013 at 11:32 AM, Tom Gundersen wrote: >>> lfb_size can easily be say 4M, which would make the bitshit overflow and >>> the test fail. >>> >>> Signed-off-by: Tom Gundersen >>> Cc: David Herrmann >>> Cc: H. Peter Anvin >>> --- >>> 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. > >> 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? > << 16 is * 65536 not 65535... -hpa