Skip to contentSkip to conversation

x86: simplefb: avoid overflow

PATCH In review Tom Gundersen 4 participants 4 messages Oct 1, 2013 – Oct 4, 2013 x86

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 x86: simplefb: avoid overflow

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.

Cc Geert Uytterhoeven <[email protected]>
Cc H. Peter Anvin <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Stephen Warren <[email protected]>,
Cc Stephen Warren <[email protected]>
Cc Thomas Gleixner <[email protected]>

---
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(-)
arch/x86/kernel/sysfb_simplefb.c +1 -1
index 22513e9..4ebd636 100644
@@ -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;
 	}
Signature · 1 line
1.8.4
#1 lore raw

[tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back

x86/simplefb: Fix overflow causing bogus fall-back
Commit-ID:  e33a29a5ae711162c6b6fefc0a2ef18f4a4254bf
Gitweb:     http://git.kernel.org/tip/e33a29a5ae711162c6b6fefc0a2ef18f4a4254bf
Author:     Tom Gundersen <[email protected]>
AuthorDate: Tue, 1 Oct 2013 18:18:40 +0200
Committer:  Ingo Molnar <[email protected]>
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.

---
 arch/x86/kernel/sysfb_simplefb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/sysfb_simplefb.c +1 -1
index 22513e9..4ebd636 100644
@@ -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;
 	}
#2 lore raw

Re: [tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back

Quoted 1 line · tip-bot for Tom Gundersen

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 -- [email protected]

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

#3 lore raw

Re: [tip:x86/urgent] x86/simplefb: Fix overflow causing bogus fall-back

Quoted 5 lines · Geert Uytterhoeven
Quoted 1 line · tip-bot for Tom Gundersen

On my MacBook Air lfb_size is 4M, which makes the bitshit

bitshift?

LOL!

Thanks,

Ingo