[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190517094336.GA4728@zhanggen-UX430UQ>
Date: Fri, 17 May 2019 17:43:36 +0800
From: Gen Zhang <blackgod016574@...il.com>
To: Ard Biesheuvel <ard.biesheuvel@...aro.org>,
linux-efi@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] efi_64: Fix a missing-check bug in
arch/x86/platform/efi/efi_64.c of Linux 5.1
On Fri, May 17, 2019 at 11:24:27AM +0200, Ard Biesheuvel wrote:
> If efi_call_phys_prolog() returns NULL, the calling function should
> abort and never call efi_call_phys_epilog().
Hi Ard,
I edit the patch and it is as following. Returning EFI_ABORTED would
be proper, because the return value (status) is checked in
__efi_enter_virtual_mode(). And returning EFI_ABORTED can abort the
process.
Thanks
Gen
save_pgd is allocated by kmalloc_array. And it is dereferenced in the
following codes. However, memory allocation functions such as
kmalloc_array may fail. Dereferencing this save_pgd null pointer may
cause the kernel go wrong. Thus we should check this allocation.
Signed-off-by: Gen Zhang <blackgod016574@...il.com>
---
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index e1cb01a..a7189a3 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -85,6 +85,8 @@ static efi_status_t __init phys_efi_set_virtual_address_map(
pgd_t *save_pgd;
save_pgd = efi_call_phys_prolog();
+ if (!save_pgd)
+ return EFI_ABORTED;
/* Disable interrupts around EFI calls: */
local_irq_save(flags);
diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
index cf0347f..828460a 100644
--- a/arch/x86/platform/efi/efi_64.c
+++ b/arch/x86/platform/efi/efi_64.c
@@ -91,6 +91,8 @@ pgd_t * __init efi_call_phys_prolog(void)
n_pgds = DIV_ROUND_UP((max_pfn << PAGE_SHIFT), PGDIR_SIZE);
save_pgd = kmalloc_array(n_pgds, sizeof(*save_pgd), GFP_KERNEL);
+ if (!save_pgd)
+ return NULL;
/*
* Build 1:1 identity mapping for efi=old_map usage. Note that
---
Powered by blists - more mailing lists