Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1624618 > unrolled thread
| Started by | Ard Biesheuvel <ard.biesheuvel@linaro.org> |
|---|---|
| First post | 2017-04-17 11:40 +0200 |
| Last post | 2017-04-18 09:40 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[GIT PULL] EFI fixup for v4.12 queue Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-04-17 11:40 +0200
[PATCH] efi/libstub/arm: Don't use TASK_SIZE when randomising the RT space Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2017-04-17 11:40 +0200
[tip:efi/core] efi/libstub/arm: Don't use TASK_SIZE when randomizing the RT space tip-bot for Ard Biesheuvel <tipbot@zytor.com> - 2017-04-18 09:40 +0200
| From | Ard Biesheuvel <ard.biesheuvel@linaro.org> |
|---|---|
| Date | 2017-04-17 11:40 +0200 |
| Subject | [GIT PULL] EFI fixup for v4.12 queue |
| Message-ID | <txbix-7rC-11@gated-at.bofh.it> |
Hi all,
Please merge this onto the v4.12 EFI queue: it fixes an issue reported with
-next where arm64 machines fail to boot due to a premature dereference of the
'current' pointer.
The following changes since commit efc491b0f06f65ea588f6591f0bc31db779e0594:
ef/libstub: arm/arm64: Randomize the base of the UEFI rt services region (2017-04-02 16:36:29 +0100)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git tags/efi-next
for you to fetch changes up to d3e759649e1b057da72a8981aaafcd2f34f10681:
efi/libstub/arm: Don't use TASK_SIZE when randomising the RT space (2017-04-17 08:16:25 +0100)
----------------------------------------------------------------
A single fix for a regression caused by changes that are queued for v4.12:
- don't use TASK_SIZE in the stub on arm64, as it depends on thread flags
----------------------------------------------------------------
Ard Biesheuvel (1):
efi/libstub/arm: Don't use TASK_SIZE when randomising the RT space
drivers/firmware/efi/libstub/arm-stub.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
[toc] | [next] | [standalone]
| From | Ard Biesheuvel <ard.biesheuvel@linaro.org> |
|---|---|
| Date | 2017-04-17 11:40 +0200 |
| Subject | [PATCH] efi/libstub/arm: Don't use TASK_SIZE when randomising the RT space |
| Message-ID | <txbix-7rC-9@gated-at.bofh.it> |
| In reply to | #1624618 |
As reported by James, Catalin and Mark, commit e69176d68d26
("ef/libstub/arm/arm64: Randomize the base of the UEFI rt services
region") results in a crash in the firmware regardless of whether KASLR
is in effect or not, and whether the firmware implements EFI_RNG_PROTOCOL
or not.
Mark has identified the root cause to be the inappropriate use of
TASK_SIZE in the stub, which arm64 defines as
#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
TASK_SIZE_32 : TASK_SIZE_64)
and testing thread flags at this point results in the dereference of
pointers in uninitialized structures.
So instead, introduce a preprocessor symbol EFI_RT_VIRTUAL_LIMIT and
define it to TASK_SIZE_64 on arm64 and TASK_SIZE on ARM, both of which
are compile time constants. Also, change the 'headroom' variable to
static const to force an error if this might change in the future.
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: James Morse <james.morse@arm.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
drivers/firmware/efi/libstub/arm-stub.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 1e45ec51b094..34010ff3b77e 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -32,6 +32,12 @@
#define EFI_RT_VIRTUAL_BASE SZ_512M
#define EFI_RT_VIRTUAL_SIZE SZ_512M
+#ifdef CONFIG_ARM64
+#define EFI_RT_VIRTUAL_LIMIT TASK_SIZE_64
+#else
+#define EFI_RT_VIRTUAL_LIMIT TASK_SIZE
+#endif
+
static u64 virtmap_base = EFI_RT_VIRTUAL_BASE;
efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg,
@@ -236,8 +242,9 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table,
* shift of 21 bit positions into account when scaling
* the headroom value using a 32-bit random value.
*/
- u64 headroom = TASK_SIZE - EFI_RT_VIRTUAL_BASE -
- EFI_RT_VIRTUAL_SIZE;
+ static const u64 headroom = EFI_RT_VIRTUAL_LIMIT -
+ EFI_RT_VIRTUAL_BASE -
+ EFI_RT_VIRTUAL_SIZE;
u32 rnd;
status = efi_get_random_bytes(sys_table, sizeof(rnd),
--
2.9.3
[toc] | [prev] | [next] | [standalone]
| From | tip-bot for Ard Biesheuvel <tipbot@zytor.com> |
|---|---|
| Date | 2017-04-18 09:40 +0200 |
| Subject | [tip:efi/core] efi/libstub/arm: Don't use TASK_SIZE when randomizing the RT space |
| Message-ID | <txvTX-3om-11@gated-at.bofh.it> |
| In reply to | #1624619 |
Commit-ID: 197decefdb79d6f1350ba0316ce26ba737372d0c
Gitweb: http://git.kernel.org/tip/197decefdb79d6f1350ba0316ce26ba737372d0c
Author: Ard Biesheuvel <ard.biesheuvel@linaro.org>
AuthorDate: Mon, 17 Apr 2017 10:32:01 +0100
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Mon, 17 Apr 2017 12:35:33 +0200
efi/libstub/arm: Don't use TASK_SIZE when randomizing the RT space
As reported by James, Catalin and Mark, commit:
e69176d68d26 ("ef/libstub/arm/arm64: Randomize the base of the UEFI rt services region")
... results in a crash in the firmware, regardless of whether KASLR
is in effect or not and whether the firmware implements EFI_RNG_PROTOCOL
or not.
Mark has identified the root cause to be the inappropriate use of
TASK_SIZE in the stub, which arm64 defines as:
#define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \
TASK_SIZE_32 : TASK_SIZE_64)
and testing thread flags at this point results in the dereference of
pointers in uninitialized structures.
So instead, introduce a preprocessor symbol EFI_RT_VIRTUAL_LIMIT and
define it to TASK_SIZE_64 on arm64 and TASK_SIZE on ARM, both of which
are compile time constants. Also, change the 'headroom' variable to
static const to force an error if this might change in the future.
Tested-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: James Morse <james.morse@arm.com>
Tested-by: Catalin Marinas <catalin.marinas@arm.com>
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 Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20170417093201.10181-2-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
drivers/firmware/efi/libstub/arm-stub.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c
index 1e45ec5..8181ac1 100644
--- a/drivers/firmware/efi/libstub/arm-stub.c
+++ b/drivers/firmware/efi/libstub/arm-stub.c
@@ -32,6 +32,12 @@
#define EFI_RT_VIRTUAL_BASE SZ_512M
#define EFI_RT_VIRTUAL_SIZE SZ_512M
+#ifdef CONFIG_ARM64
+# define EFI_RT_VIRTUAL_LIMIT TASK_SIZE_64
+#else
+# define EFI_RT_VIRTUAL_LIMIT TASK_SIZE
+#endif
+
static u64 virtmap_base = EFI_RT_VIRTUAL_BASE;
efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg,
@@ -236,8 +242,9 @@ unsigned long efi_entry(void *handle, efi_system_table_t *sys_table,
* shift of 21 bit positions into account when scaling
* the headroom value using a 32-bit random value.
*/
- u64 headroom = TASK_SIZE - EFI_RT_VIRTUAL_BASE -
- EFI_RT_VIRTUAL_SIZE;
+ static const u64 headroom = EFI_RT_VIRTUAL_LIMIT -
+ EFI_RT_VIRTUAL_BASE -
+ EFI_RT_VIRTUAL_SIZE;
u32 rnd;
status = efi_get_random_bytes(sys_table, sizeof(rnd),
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web