From patchwork Thu May 14 12:38:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 245816 List-Id: U-Boot discussion From: michael at walle.cc (Michael Walle) Date: Thu, 14 May 2020 14:38:29 +0200 Subject: [PATCH 2/4] efi_loader: check alignment in efi_add_memory_map() In-Reply-To: <20200514123831.30157-1-michael@walle.cc> References: <20200514123831.30157-1-michael@walle.cc> Message-ID: <20200514123831.30157-3-michael@walle.cc> The first argument has to be aligned with EFI_PAGE_SIZE. This alignment is already checked for external callers but it is not checked for internal callers. Unfortunately, most of the time the return value is not checked, so scream loud and clear. Signed-off-by: Michael Walle --- lib/efi_loader/efi_memory.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c index fd79178da9..b56e19cb30 100644 --- a/lib/efi_loader/efi_memory.c +++ b/lib/efi_loader/efi_memory.c @@ -248,6 +248,9 @@ efi_status_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type, EFI_PRINT("%s: 0x%llx 0x%llx %d %s\n", __func__, start, pages, memory_type, overlap_only_ram ? "yes" : "no"); + if (start & EFI_PAGE_MASK) + panic("%s: start not aligned\n", __func__); + if (memory_type >= EFI_MAX_MEMORY_TYPE) return EFI_INVALID_PARAMETER;