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>] [day] [month] [year] [list]
Message-Id: <20191113205630.28434-1-msys.mizuma@gmail.com>
Date:   Wed, 13 Nov 2019 15:56:30 -0500
From:   Masayoshi Mizuma <msys.mizuma@...il.com>
To:     Ard Biesheuvel <ard.biesheuvel@...aro.org>,
        linux-efi@...r.kernel.org
Cc:     Masayoshi Mizuma <msys.mizuma@...il.com>,
        Masayoshi Mizuma <m.mizuma@...fujitsu.com>,
        linux-kernel@...r.kernel.org,
        HATAYAMA Daisuke <d.hatayama@...fujitsu.com>
Subject: [PATCH] efi: sanity check in case memermap() at efi_mem_reserve_persistent() returns NULL

From: Masayoshi Mizuma <m.mizuma@...fujitsu.com>

System may crash as NULL pointer dereference in case memremap()
at efi_mem_reserve_persistent() returns NULL.

Add a sanity check to avoid that.

Signed-off-by: Masayoshi Mizuma <m.mizuma@...fujitsu.com>
Reported-by: HATAYAMA Daisuke <d.hatayama@...fujitsu.com>
---
 drivers/firmware/efi/efi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 07812d697..1d5ae7b95 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -1036,6 +1036,8 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size)
 	/* first try to find a slot in an existing linked list entry */
 	for (prsv = efi_memreserve_root->next; prsv; prsv = rsv->next) {
 		rsv = memremap(prsv, sizeof(*rsv), MEMREMAP_WB);
+		if (!rsv)
+			return -ENOMEM;
 		index = atomic_fetch_add_unless(&rsv->count, 1, rsv->size);
 		if (index < rsv->size) {
 			rsv->entry[index].base = addr;
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ