lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160918011443.GA4475@gmail.com>
Date:   Sun, 18 Sep 2016 04:14:45 +0300
From:   Mike Krinkin <krinkin.m.u@...il.com>
To:     mingo@...nel.org, tglx@...utronix.de, hpa@...or.com,
        ricardo.neri-calderon@...ux.intel.com, ard.biesheuvel@...aro.org,
        matt@...eblueprint.co.uk, pjones@...hat.com, scott.lawson@...el.com
Cc:     linux-kernel@...r.kernel.org, linux-efi@...r.kernel.org
Subject: Re: Cannot load linux after recent efi-related changes

On Sat, Sep 17, 2016 at 07:23:57PM +0300, Mike Krinkin wrote:
> Hello,
> 
> after commit 3dad6f7f6975 ("x86/efi: Defer efi_esrt_init until after
> memblock_x86_fill") kernel hits BUG_ON __efi_enter_virtual_mode because
> efi.systab is NULL. With older kernel versions i face the problem with
> efi_mem_reserve described in the commit.
> 
> AFAICS, get_systab_virt_addr called from efi_map_regions should set
> efi.systab, but i dumped memory desciptors in efi_map_regions and
> apparently none of them describes region that contains efi_phys.systab,
> so efi.systab remains unset.

I investigated it a bit further, and apparently problem occurs because
efi_esrt_init calls efi_mem_reserve with unaligned range boundaries, and
efi_memmap_insert doesn't handle unaligned ranges properly. The following
fix solves problem for me:

>From 23f7134a6dd3a3c47f875395933a68e1a83d0f0e Mon Sep 17 00:00:00 2001
From: Mike Krinkin <krinkin.m.u@...il.com>
Date: Sun, 18 Sep 2016 03:53:52 +0300
Subject: [PATCH] efi: force page alignment in efi_mem_insert

efi_mem_insert might be called with unaligned range boundaries,
for example, for me it happens because esrt size is not page
aligned, that, in turn, results in wrong memory map and triggers
BUG_ON in __efi_enter_virtual_mode.

Force page alignment on memory range boundaries in efi_mem_insert.

Signed-off-by: Mike Krinkin <krinkin.m.u@...il.com>
---
 drivers/firmware/efi/memmap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/memmap.c b/drivers/firmware/efi/memmap.c
index cd96086..34322d1 100644
--- a/drivers/firmware/efi/memmap.c
+++ b/drivers/firmware/efi/memmap.c
@@ -221,8 +221,8 @@ void __init efi_memmap_insert(struct efi_memory_map *old_memmap, void *buf,
 	void *old, *new;
 
 	/* modifying range */
-	m_start = mem->range.start;
-	m_end = mem->range.end;
+	m_start = mem->range.start & ~(u64)EFI_PAGE_SIZE;
+	m_end = ALIGN(mem->range.end, EFI_PAGE_SIZE) - 1;
 	m_attr = mem->attribute;
 
 	for (old = old_memmap->map, new = buf;
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ