From: tip-bot for Ard Biesheuvel <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
tbaicar@codeaurora.org, peterz@infradead.org, mingo@kernel.org,
matt@codeblueprint.co.uk, ard.biesheuvel@linaro.org,
pjones@redhat.com, hpa@zytor.com, tglx@linutronix.de
Subject: [tip:efi/core] efi/esrt: Fix handling of early ESRT table mapping
Date: Mon, 12 Mar 2018 02:31:30 -0700 [thread overview]
Message-ID: <tip-136d5d57e35cc6985c57d23d0c823133e3508bed@git.kernel.org> (raw)
In-Reply-To: <20180312084500.10764-5-ard.biesheuvel@linaro.org>
Commit-ID: 136d5d57e35cc6985c57d23d0c823133e3508bed
Gitweb: https://git.kernel.org/tip/136d5d57e35cc6985c57d23d0c823133e3508bed
Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
AuthorDate: Mon, 12 Mar 2018 08:44:59 +0000
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 12 Mar 2018 10:05:01 +0100
efi/esrt: Fix handling of early ESRT table mapping
As reported by Tyler, efi_esrt_init() will return without releasing the
ESRT table header mapping if it encounters a table with an unexpected
version. Replacing the 'return' with 'goto err_memunmap' would fix this
particular occurrence, but, as it turns out, the code is rather peculiar
to begin with:
- it never uses the header mapping after memcpy()'ing out its contents,
- it maps and unmaps the entire table without ever looking at the
contents.
So let's refactor this code to unmap the table header right after the
memcpy() so we can get rid of the error handling path altogether, and
drop the second mapping entirely.
Reported-by: Tyler Baicar <tbaicar@codeaurora.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Jones <pjones@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20180312084500.10764-5-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
drivers/firmware/efi/esrt.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/firmware/efi/esrt.c b/drivers/firmware/efi/esrt.c
index c47e0c6ec00f..1ab80e06e7c5 100644
--- a/drivers/firmware/efi/esrt.c
+++ b/drivers/firmware/efi/esrt.c
@@ -279,6 +279,7 @@ void __init efi_esrt_init(void)
}
memcpy(&tmpesrt, va, sizeof(tmpesrt));
+ early_memunmap(va, size);
if (tmpesrt.fw_resource_version == 1) {
entry_size = sizeof (*v1_entries);
@@ -291,7 +292,7 @@ void __init efi_esrt_init(void)
if (tmpesrt.fw_resource_count > 0 && max - size < entry_size) {
pr_err("ESRT memory map entry can only hold the header. (max: %zu size: %zu)\n",
max - size, entry_size);
- goto err_memunmap;
+ return;
}
/*
@@ -304,7 +305,7 @@ void __init efi_esrt_init(void)
if (tmpesrt.fw_resource_count > 128) {
pr_err("ESRT says fw_resource_count has very large value %d.\n",
tmpesrt.fw_resource_count);
- goto err_memunmap;
+ return;
}
/*
@@ -315,18 +316,10 @@ void __init efi_esrt_init(void)
if (max < size + entries_size) {
pr_err("ESRT does not fit on single memory map entry (size: %zu max: %zu)\n",
size, max);
- goto err_memunmap;
+ return;
}
- /* remap it with our (plausible) new pages */
- early_memunmap(va, size);
size += entries_size;
- va = early_memremap(efi.esrt, size);
- if (!va) {
- pr_err("early_memremap(%p, %zu) failed.\n", (void *)efi.esrt,
- size);
- return;
- }
esrt_data = (phys_addr_t)efi.esrt;
esrt_data_size = size;
@@ -336,8 +329,6 @@ void __init efi_esrt_init(void)
efi_mem_reserve(esrt_data, esrt_data_size);
pr_debug("esrt-init: loaded.\n");
-err_memunmap:
- early_memunmap(va, size);
}
static int __init register_entries(void)
next prev parent reply other threads:[~2018-03-12 9:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 8:44 [GIT PULL 0/5] more EFI changes for v4.17 Ard Biesheuvel
2018-03-12 8:44 ` [PATCH 1/5] efi: Use efi_mm in x86 as well as ARM Ard Biesheuvel
2018-03-12 9:31 ` [tip:efi/core] " tip-bot for Sai Praneeth
2018-03-12 8:44 ` [PATCH 2/5] x86/efi: Replace efi_pgd with efi_mm.pgd Ard Biesheuvel
2018-03-12 9:02 ` Ingo Molnar
2018-03-12 9:26 ` Ingo Molnar
2018-03-12 9:28 ` Ard Biesheuvel
2018-03-12 9:48 ` Ingo Molnar
2018-03-12 8:44 ` [PATCH 3/5] x86/efi: Use efi_switch_mm() rather than manually twiddling with %cr3 Ard Biesheuvel
2018-03-12 8:44 ` [PATCH 4/5] efi/esrt: fix handling of early ESRT table mapping Ard Biesheuvel
2018-03-12 9:31 ` tip-bot for Ard Biesheuvel [this message]
2018-03-12 8:45 ` [PATCH 5/5] efi: use string literals for efi_char16_t variable initializers Ard Biesheuvel
2018-03-12 9:31 ` [tip:efi/core] efi: Use " tip-bot for Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-136d5d57e35cc6985c57d23d0c823133e3508bed@git.kernel.org \
--to=tipbot@zytor.com \
--cc=ard.biesheuvel@linaro.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=pjones@redhat.com \
--cc=tbaicar@codeaurora.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome