From: Lukas Wunner <lukas@wunner.de>
To: David Howells <dhowells@redhat.com>
Cc: keyrings@vger.kernel.org, matthew.garrett@nebula.com,
linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 02/16] efi: Get the secure boot status
Date: Thu, 17 Nov 2016 13:37:31 +0100 [thread overview]
Message-ID: <20161117123731.GA11573@wunner.de> (raw)
In-Reply-To: <147933285147.19316.11046583275861569558.stgit@warthog.procyon.org.uk>
On Wed, Nov 16, 2016 at 09:47:31PM +0000, David Howells wrote:
> Get the firmware's secure-boot status in the kernel boot wrapper and stash
> it somewhere that the main kernel image can find.
>
> Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
>
> Documentation/x86/zero-page.txt | 2 ++
> arch/x86/boot/compressed/eboot.c | 35 +++++++++++++++++++++++++++++++++
> arch/x86/include/uapi/asm/bootparam.h | 3 ++-
> 3 files changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/x86/zero-page.txt b/Documentation/x86/zero-page.txt
> index 95a4d34af3fd..b8527c6b7646 100644
> --- a/Documentation/x86/zero-page.txt
> +++ b/Documentation/x86/zero-page.txt
> @@ -31,6 +31,8 @@ Offset Proto Name Meaning
> 1E9/001 ALL eddbuf_entries Number of entries in eddbuf (below)
> 1EA/001 ALL edd_mbr_sig_buf_entries Number of entries in edd_mbr_sig_buffer
> (below)
> +1EB/001 ALL kbd_status Numlock is enabled
> +1EC/001 ALL secure_boot Secure boot is enabled in the firmware
> 1EF/001 ALL sentinel Used to detect broken bootloaders
> 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures
> 2D0/A00 ALL e820_map E820 memory map table
> diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
> index cc69e37548db..17b376596c96 100644
> --- a/arch/x86/boot/compressed/eboot.c
> +++ b/arch/x86/boot/compressed/eboot.c
> @@ -12,6 +12,7 @@
> #include <asm/efi.h>
> #include <asm/setup.h>
> #include <asm/desc.h>
> +#include <asm/bootparam_utils.h>
>
> #include "../string.h"
> #include "eboot.h"
> @@ -537,6 +538,36 @@ static void setup_efi_pci(struct boot_params *params)
> efi_call_early(free_pool, pci_handle);
> }
>
> +static int get_secure_boot(void)
> +{
This function is very similar to the existing efi_get_secureboot() in
drivers/firmware/efi/libstub/arm-stub.c.
Please avoid adding more duplicate code to the EFI stub and try to
reuse the existing code.
I suggest moving the existing efi_get_secureboot() to a new file
drivers/firmware/efi/libstub/secureboot.c which gets linked into
libstub, perhaps dependent on a new config option.
> + u8 sb, setup;
> + unsigned long datasize = sizeof(sb);
> + efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;
> + efi_status_t status;
> +
> + status = efi_early->call((unsigned long)sys_table->runtime->get_variable,
> + L"SecureBoot", &var_guid, NULL, &datasize, &sb);
This doesn't work in mixed mode.
We already have the efi_call_early() macro to call boot services
in a manner that works across all arches and bitness variants.
In 4.10 there will be an efi_call_proto() macro to allow the same
for protocol calls:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?h=efi/core&id=3552fdf29f01
I suggest adding an efi_call_runtime() macro for arch- and bitness-
agnostic runtime services calls, like this:
#define efi_call_runtime(f, ...) \
__efi_early()->call(efi_table_attr(efi_runtime_services, f, \
__efi_early()->runtime_services), __VA_ARGS__)
For this to work you need to add a runtime_services attribute to struct
efi_config, this requires modifying head_32.S and head_64.S, use commit
0a637ee61247 ("x86/efi: Allow invocation of arbitrary boot services")
as a template.
If you define corresponding efi_call_runtime() macros for ARM, you
should indeed be able to share this function across arches.
Thanks,
Lukas
> +
> + if (status != EFI_SUCCESS)
> + return 0;
> +
> + if (sb == 0)
> + return 0;
> +
> +
> + status = efi_early->call((unsigned long)sys_table->runtime->get_variable,
> + L"SetupMode", &var_guid, NULL, &datasize,
> + &setup);
> +
> + if (status != EFI_SUCCESS)
> + return 0;
> +
> + if (setup == 1)
> + return 0;
> +
> + return 1;
> +}
> +
> static efi_status_t
> setup_uga32(void **uga_handle, unsigned long size, u32 *width, u32 *height)
> {
> @@ -1094,6 +1125,10 @@ struct boot_params *efi_main(struct efi_config *c,
> else
> setup_boot_services32(efi_early);
>
> + sanitize_boot_params(boot_params);
> +
> + boot_params->secure_boot = get_secure_boot();
> +
> setup_graphics(boot_params);
>
> setup_efi_pci(boot_params);
> diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h
> index c18ce67495fa..2b3e5427097b 100644
> --- a/arch/x86/include/uapi/asm/bootparam.h
> +++ b/arch/x86/include/uapi/asm/bootparam.h
> @@ -134,7 +134,8 @@ struct boot_params {
> __u8 eddbuf_entries; /* 0x1e9 */
> __u8 edd_mbr_sig_buf_entries; /* 0x1ea */
> __u8 kbd_status; /* 0x1eb */
> - __u8 _pad5[3]; /* 0x1ec */
> + __u8 secure_boot; /* 0x1ec */
> + __u8 _pad5[2]; /* 0x1ed */
> /*
> * The sentinel is set to a nonzero value (0xff) in header.S.
> *
>
next prev parent reply other threads:[~2016-11-17 12:37 UTC|newest]
Thread overview: 101+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 21:47 [PATCH 00/16] Kernel lockdown David Howells
2016-11-16 21:47 ` David Howells
2016-11-16 21:47 ` [PATCH 01/16] Add the ability to lock down access to the running kernel image David Howells
[not found] ` <147933284407.19316.17886320817060158597.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-16 22:20 ` Borislav Petkov
2016-11-16 22:20 ` Borislav Petkov
2016-11-16 22:40 ` David Howells
2016-12-25 21:20 ` Pavel Machek
2016-12-25 21:44 ` David Howells
2016-11-16 21:47 ` [PATCH 02/16] efi: Get the secure boot status David Howells
2016-11-17 12:37 ` Lukas Wunner [this message]
2016-11-21 11:46 ` David Howells
2016-11-21 19:58 ` Lukas Wunner
2016-11-22 0:31 ` [PATCH 2/6] arm/efi: Allow invocation of arbitrary runtime services David Howells
2016-11-22 0:31 ` [PATCH 3/6] efi: Add SHIM and image security database GUID definitions David Howells
2016-11-22 0:32 ` [PATCH 4/6] efi: Get the secure boot status David Howells
2016-11-22 10:44 ` Lukas Wunner
2016-11-22 14:47 ` David Howells
2016-11-22 20:30 ` Lukas Wunner
2016-11-23 0:02 ` David Howells
[not found] ` <20161122104401.GC1552-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-11-22 10:49 ` Ard Biesheuvel
2016-11-22 10:49 ` Ard Biesheuvel
2016-11-22 14:52 ` David Howells
2016-11-22 14:52 ` David Howells
[not found] ` <25371.1479826321-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-22 20:36 ` Lukas Wunner
2016-11-22 20:36 ` Lukas Wunner
[not found] ` <7199.1479826047-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-22 14:57 ` David Howells
2016-11-22 14:57 ` David Howells
2016-11-22 0:32 ` [PATCH 5/6] efi: Disable secure boot if shim is in insecure mode David Howells
2016-11-22 13:03 ` Lukas Wunner
2016-11-22 0:32 ` [PATCH 6/6] efi: Add EFI_SECURE_BOOT bit David Howells
2016-11-22 13:04 ` Lukas Wunner
[not found] ` <20161117123731.GA11573-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-11-21 11:42 ` [PATCH 02/16] efi: Get the secure boot status David Howells
2016-11-21 11:42 ` David Howells
[not found] ` <29779.1479728545-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-21 11:52 ` Ard Biesheuvel
2016-11-21 11:52 ` Ard Biesheuvel
[not found] ` <CAKv+Gu-frVDhzORDRZ6XT+FxewsTgrxhXmM=DqaS6Ns4mJhQ9g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-21 12:41 ` David Howells
2016-11-21 12:41 ` David Howells
2016-11-21 13:14 ` Ard Biesheuvel
[not found] ` <CAKv+Gu8Lhm=u97hY1y+Y+Ladk=y7pSVNrow8ML1hQUJ9+74B-w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-21 15:17 ` Lukas Wunner
2016-11-21 15:17 ` Lukas Wunner
2016-11-21 15:25 ` Ard Biesheuvel
2016-11-22 0:31 ` [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services David Howells
2016-11-22 0:31 ` David Howells
[not found] ` <147977469914.6360.17194649697208113702.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-22 10:20 ` Lukas Wunner
2016-11-22 10:20 ` Lukas Wunner
2016-11-22 14:17 ` David Howells
2016-11-22 14:58 ` Joe Perches
[not found] ` <1479826691.1942.11.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2016-11-22 15:52 ` David Howells
2016-11-22 15:52 ` David Howells
[not found] ` <24973.1479829961-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-22 16:25 ` Joe Perches
2016-11-22 16:25 ` Joe Perches
2016-11-22 16:40 ` David Howells
2016-11-22 16:51 ` Joe Perches
2016-11-16 21:47 ` [PATCH 03/16] efi: Disable secure boot if shim is in insecure mode David Howells
2016-11-16 21:47 ` [PATCH 04/16] efi: Lock down the kernel if booted in secure boot mode David Howells
2016-11-16 21:47 ` [PATCH 05/16] efi: Add EFI_SECURE_BOOT bit David Howells
2016-11-17 21:58 ` Ard Biesheuvel
2016-11-18 11:58 ` Josh Boyer
[not found] ` <CA+5PVA6F5qEnuL2UaXS9_fJ217J93cEZDDsz9Y2BPwHXcMdX-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-18 12:10 ` Ard Biesheuvel
2016-11-18 12:10 ` Ard Biesheuvel
[not found] ` <CAKv+Gu_8r3oM-jvvuSiXTzxp0YMEVgc5KkScJ2UhGTaXm28L6w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-11-18 17:28 ` David Howells
2016-11-18 17:28 ` David Howells
2016-11-16 21:48 ` [PATCH 06/16] Add a sysrq option to exit secure boot mode David Howells
2016-11-16 21:48 ` [PATCH 07/16] kexec: Disable at runtime if the kernel is locked down David Howells
2016-11-16 21:48 ` [PATCH 08/16] Copy secure_boot flag in boot params across kexec reboot David Howells
2016-11-16 21:48 ` [PATCH 09/16] hibernate: Disable when the kernel is locked down David Howells
2016-11-16 21:48 ` [PATCH 10/16] PCI: Lock down BAR access " David Howells
2016-11-16 21:48 ` [PATCH 12/16] ACPI: Limit access to custom_method " David Howells
2016-11-16 21:48 ` [PATCH 13/16] asus-wmi: Restrict debugfs interface " David Howells
2016-11-16 21:48 ` [PATCH 14/16] Restrict /dev/mem and /dev/kmem " David Howells
2016-11-16 21:49 ` [PATCH 15/16] acpi: Ignore acpi_rsdp kernel param when the kernel has been " David Howells
[not found] ` <147933283664.19316.12454053022687659937.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-16 21:48 ` [PATCH 11/16] x86: Lock down IO port access when the kernel is " David Howells
2016-11-16 21:48 ` David Howells
2016-11-16 21:49 ` [PATCH 16/16] x86: Restrict MSR " David Howells
2016-11-16 21:49 ` David Howells
2016-11-16 22:27 ` [PATCH 00/16] Kernel lockdown One Thousand Gnomes
2016-11-16 22:27 ` One Thousand Gnomes
2016-11-21 19:53 ` Ard Biesheuvel
2016-11-30 14:27 ` One Thousand Gnomes
2016-11-21 23:10 ` [PATCH] Lock down drivers that can have io ports, io mem, irqs and dma changed David Howells
2016-11-22 6:12 ` Dominik Brodowski
2016-11-22 6:12 ` Dominik Brodowski
2016-11-23 12:58 ` David Howells
2016-11-23 19:21 ` Dominik Brodowski
[not found] ` <20161123192143.GA482-SGhQLRGLuNwb6pqDj42GsMgv3T4z79SOrE5yTffgRl4@public.gmane.org>
2016-11-24 17:34 ` David Howells
2016-11-24 17:34 ` David Howells
2016-11-24 20:19 ` Dominik Brodowski
2016-11-25 14:49 ` David Howells
[not found] ` <26173.1479769852-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-28 22:32 ` Corey Minyard
2016-11-28 22:32 ` Corey Minyard
2016-11-29 0:11 ` David Howells
2016-11-29 0:23 ` Corey Minyard
2016-11-29 14:03 ` David Howells
[not found] ` <6973.1480428211-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2016-11-29 14:35 ` Corey Minyard
2016-11-29 14:35 ` Corey Minyard
2016-11-30 14:41 ` One Thousand Gnomes
2016-11-30 14:41 ` One Thousand Gnomes
[not found] ` <20161130144105.2b6be4fe-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2016-11-30 16:25 ` David Howells
2016-11-30 16:25 ` David Howells
2016-11-29 10:40 ` David Howells
2016-11-16 22:28 ` [PATCH 00/16] Kernel lockdown Justin Forbes
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=20161117123731.GA11573@wunner.de \
--to=lukas@wunner.de \
--cc=dhowells@redhat.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=matthew.garrett@nebula.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.