linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] x86: simplefb: avoid overflow
@ 2013-10-01 16:18 Tom Gundersen
  2013-10-03 13:59 ` [tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back tip-bot for Tom Gundersen
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Gundersen @ 2013-10-01 16:18 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Tom Gundersen, Geert Uytterhoeven, H. Peter Anvin,
	Ingo Molnar, Stephen Warren, Stephen Warren, Thomas Gleixner

On my MacBook Air lfb_size is 4M, which makes the bitshit overflow, meaning we
fall back to efifb unnecessarily.

Cast to u64 to avoid the overflow.

Signed-off-by: Tom Gundersen <teg@jklm.no>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Stephen Warren <swarren@nvidia.com>,
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
v2: use (__u64) rather than (unsigned long). This is strictly speaking not
    necessary, but as David poited out it makes it more obvious that we
    we won't have problems on 32bit.
v3: remove superfluous parens and use (u64) rather than (__64) as this is not
    shared by userspace.

 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..4ebd636 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 > (u64)si->lfb_size << 16) {
 		printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n");
 		return -EINVAL;
 	}
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back
  2013-10-01 16:18 [PATCH v3] x86: simplefb: avoid overflow Tom Gundersen
@ 2013-10-03 13:59 ` tip-bot for Tom Gundersen
  2013-10-03 18:09   ` Geert Uytterhoeven
  0 siblings, 1 reply; 4+ messages in thread
From: tip-bot for Tom Gundersen @ 2013-10-03 13:59 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, swarren, hpa, mingo, swarren, geert, tglx, teg,
	dh.herrmann

Commit-ID:  e33a29a5ae711162c6b6fefc0a2ef18f4a4254bf
Gitweb:     http://git.kernel.org/tip/e33a29a5ae711162c6b6fefc0a2ef18f4a4254bf
Author:     Tom Gundersen <teg@jklm.no>
AuthorDate: Tue, 1 Oct 2013 18:18:40 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 2 Oct 2013 07:50:40 +0200

x86/simplefb: Fix overflow causing bogus fall-back

On my MacBook Air lfb_size is 4M, which makes the bitshit
overflow (to 256GB - larger than 32 bits), meaning we fall
back to efifb unnecessarily.

Cast to u64 to avoid the overflow.

Signed-off-by: Tom Gundersen <teg@jklm.no>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Link: http://lkml.kernel.org/r/1380644320-1026-1-git-send-email-teg@jklm.no
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 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..4ebd636 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 > (u64)si->lfb_size << 16) {
 		printk(KERN_WARNING "sysfb: VRAM smaller than advertised\n");
 		return -EINVAL;
 	}

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back
  2013-10-03 13:59 ` [tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back tip-bot for Tom Gundersen
@ 2013-10-03 18:09   ` Geert Uytterhoeven
  2013-10-04  6:26     ` Ingo Molnar
  0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2013-10-03 18:09 UTC (permalink / raw)
  To: Ingo Molnar, H. Peter Anvin, Stephen Warren,
	linux-kernel@vger.kernel.org, Stephen Warren, Geert Uytterhoeven,
	Thomas Gleixner, Tom Gundersen, David Herrmann
  Cc: linux-tip-commits

On Thu, Oct 3, 2013 at 3:59 PM, tip-bot for Tom Gundersen
<tipbot@zytor.com> wrote:
> On my MacBook Air lfb_size is 4M, which makes the bitshit

bitshift?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back
  2013-10-03 18:09   ` Geert Uytterhoeven
@ 2013-10-04  6:26     ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2013-10-04  6:26 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: H. Peter Anvin, Stephen Warren, linux-kernel@vger.kernel.org,
	Stephen Warren, Thomas Gleixner, Tom Gundersen, David Herrmann,
	linux-tip-commits


* Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> On Thu, Oct 3, 2013 at 3:59 PM, tip-bot for Tom Gundersen
> <tipbot@zytor.com> wrote:
> > On my MacBook Air lfb_size is 4M, which makes the bitshit
> 
> bitshift?

LOL!

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-10-04  6:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-01 16:18 [PATCH v3] x86: simplefb: avoid overflow Tom Gundersen
2013-10-03 13:59 ` [tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back tip-bot for Tom Gundersen
2013-10-03 18:09   ` Geert Uytterhoeven
2013-10-04  6:26     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).