[RFC PATCH 5/5] efi/gop: Check that the framebuffer will be accessible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If phys_addr_t is only 32 bits, but we somehow have a framebuffer above
4G, we can't access it, and if we let it through, the address will get
silently truncated later. So check to make sure the framebuffer base
fits in phys_addr_t.

Also remove the unnecessary cast of fb_base to u64, as it is already a
64-bit type, and all the cast could have done was truncate it on a
32-bit system.

Signed-off-by: Arvind Sankar <nivedita@xxxxxxxxxxxx>
---
 drivers/firmware/efi/libstub/gop.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c
index 94045ab7dd3d..8cce20ff4437 100644
--- a/drivers/firmware/efi/libstub/gop.c
+++ b/drivers/firmware/efi/libstub/gop.c
@@ -7,6 +7,7 @@
 
 #include <linux/efi.h>
 #include <linux/screen_info.h>
+#include <linux/types.h>
 #include <asm/efi.h>
 #include <asm/setup.h>
 
@@ -132,7 +133,8 @@ setup_gop(efi_system_table_t *sys_table_arg, struct screen_info *si,
 		current_fb_base = efi_gop_attr(_mode, frame_buffer_base, mode);
 
 		if ((!first_gop || conout_found) &&
-		    info->pixel_format != PIXEL_BLT_ONLY) {
+		    info->pixel_format != PIXEL_BLT_ONLY &&
+		    (phys_addr_t)current_fb_base == current_fb_base) {
 			/*
 			 * Systems that use the UEFI Console Splitter may
 			 * provide multiple GOP devices, not all of which are
@@ -168,7 +170,7 @@ setup_gop(efi_system_table_t *sys_table_arg, struct screen_info *si,
 	si->lfb_height = height;
 	si->lfb_base = fb_base;
 
-	ext_lfb_base = (u64)(unsigned long)fb_base >> 32;
+	ext_lfb_base = fb_base >> 32;
 	if (ext_lfb_base) {
 		si->capabilities |= VIDEO_CAPABILITY_64BIT_BASE;
 		si->ext_lfb_base = ext_lfb_base;
-- 
2.23.0




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux