From: Matthew Garrett <mjg@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, Matthew Garrett <mjg@redhat.com> Subject: [PATCH 09/11] efi: Enable secure boot lockdown automatically when enabled in firmware Date: Tue, 4 Sep 2012 11:55:15 -0400 [thread overview] Message-ID: <1346774117-2277-10-git-send-email-mjg@redhat.com> (raw) In-Reply-To: <1346774117-2277-1-git-send-email-mjg@redhat.com> The firmware has a set of flags that indicate whether secure boot is enabled and enforcing. Use them to indicate whether the kernel should lock itself down. Signed-off-by: Matthew Garrett <mjg@redhat.com> --- Documentation/x86/zero-page.txt | 2 ++ arch/x86/boot/compressed/eboot.c | 32 ++++++++++++++++++++++++++++++++ arch/x86/include/asm/bootparam.h | 3 ++- arch/x86/kernel/setup.c | 3 +++ include/linux/cred.h | 2 ++ 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/Documentation/x86/zero-page.txt b/Documentation/x86/zero-page.txt index cf5437d..7f9ed48 100644 --- a/Documentation/x86/zero-page.txt +++ b/Documentation/x86/zero-page.txt @@ -27,6 +27,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 Kernel should enable secure boot lockdowns 290/040 ALL edd_mbr_sig_buffer EDD MBR signatures 2D0/A00 ALL e820_map E820 memory map table (array of struct e820entry) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index b3e0227..3789356 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -724,6 +724,36 @@ fail: return status; } +static int get_secure_boot(efi_system_table_t *_table) +{ + u8 sb, setup; + unsigned long datasize = sizeof(sb); + efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID; + efi_status_t status; + + status = efi_call_phys5(sys_table->runtime->get_variable, + L"SecureBoot", &var_guid, NULL, &datasize, &sb); + + if (status != EFI_SUCCESS) + return 0; + + if (sb == 0) + return 0; + + + status = efi_call_phys5(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; +} + /* * Because the x86 boot code expects to be passed a boot_params we * need to create one ourselves (usually the bootloader would create @@ -1018,6 +1048,8 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table, if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) goto fail; + boot_params->secure_boot = get_secure_boot(sys_table); + setup_graphics(boot_params); status = efi_call_phys3(sys_table->boottime->allocate_pool, diff --git a/arch/x86/include/asm/bootparam.h b/arch/x86/include/asm/bootparam.h index 2ad874c..c7338e0 100644 --- a/arch/x86/include/asm/bootparam.h +++ b/arch/x86/include/asm/bootparam.h @@ -114,7 +114,8 @@ struct boot_params { __u8 eddbuf_entries; /* 0x1e9 */ __u8 edd_mbr_sig_buf_entries; /* 0x1ea */ __u8 kbd_status; /* 0x1eb */ - __u8 _pad6[5]; /* 0x1ec */ + __u8 secure_boot; /* 0x1ec */ + __u8 _pad6[4]; /* 0x1ed */ struct setup_header hdr; /* setup header */ /* 0x1f1 */ __u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)]; __u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */ diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index f4b9b80..239bf2a 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -947,6 +947,9 @@ void __init setup_arch(char **cmdline_p) io_delay_init(); + if (boot_params.secure_boot) + secureboot_enable(); + /* * Parse the ACPI tables for possible boot-time SMP configuration. */ diff --git a/include/linux/cred.h b/include/linux/cred.h index ebbed2c..a24faf1 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -170,6 +170,8 @@ extern int set_security_override_from_ctx(struct cred *, const char *); extern int set_create_files_as(struct cred *, struct inode *); extern void __init cred_init(void); +extern void secureboot_enable(void); + /* * check for validity of credentials */ -- 1.7.11.4
next prev parent reply other threads:[~2012-09-04 15:56 UTC|newest] Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-09-04 15:55 [RFC] First attempt at kernel secure boot support Matthew Garrett 2012-09-04 15:55 ` [PATCH 01/11] Secure boot: Add new capability Matthew Garrett 2012-09-04 15:55 ` [PATCH 02/11] PCI: Lock down BAR access in secure boot environments Matthew Garrett 2012-10-01 21:00 ` Pavel Machek 2012-09-04 15:55 ` [PATCH 03/11] x86: Lock down IO port " Matthew Garrett 2012-09-04 16:16 ` Alan Cox 2012-09-04 16:16 ` Matthew Garrett 2012-09-04 15:55 ` [PATCH 04/11] ACPI: Limit access to custom_method Matthew Garrett 2012-09-04 15:55 ` [PATCH 05/11] asus-wmi: Restrict debugfs interface Matthew Garrett 2012-09-04 16:12 ` Alan Cox 2012-09-04 16:13 ` Matthew Garrett 2012-09-04 15:55 ` [PATCH 06/11] Restrict /dev/mem and /dev/kmem in secure boot setups Matthew Garrett 2012-09-04 15:55 ` [PATCH 07/11] kexec: Disable in a secure boot environment Matthew Garrett 2012-09-04 20:13 ` Eric W. Biederman 2012-09-04 20:22 ` Matthew Garrett 2012-09-04 21:13 ` Eric W. Biederman 2012-09-04 21:27 ` Matthew Garrett 2012-09-04 22:12 ` Eric W. Biederman 2012-09-04 23:25 ` Matthew Garrett 2012-09-05 4:33 ` Eric W. Biederman 2012-09-05 5:16 ` Matthew Garrett 2012-09-05 7:00 ` Eric W. Biederman 2012-09-05 7:03 ` Matthew Garrett 2012-09-04 21:39 ` Alan Cox 2012-09-04 21:40 ` Matthew Garrett 2012-09-05 15:43 ` Roland Eggner 2012-09-05 15:46 ` Matthew Garrett 2012-09-05 21:13 ` Mimi Zohar 2012-09-05 21:41 ` Matthew Garrett 2012-09-05 21:49 ` Eric Paris 2012-09-04 15:55 ` [PATCH 08/11] Secure boot: Add a dummy kernel parameter that will switch on Secure Boot mode Matthew Garrett 2012-09-04 15:55 ` Matthew Garrett [this message] 2012-09-04 15:55 ` [PATCH 10/11] acpi: Ignore acpi_rsdp kernel parameter in a secure boot environment Matthew Garrett 2012-09-04 16:30 ` Shuah Khan 2012-09-04 16:38 ` Matthew Garrett 2012-09-04 16:44 ` Shuah Khan 2012-09-04 20:37 ` Alan Cox 2012-09-04 20:37 ` Matthew Garrett 2012-09-04 20:50 ` Josh Boyer 2012-09-04 15:55 ` [PATCH 11/11] SELinux: define mapping for new Secure Boot capability Matthew Garrett 2012-09-04 16:08 ` [RFC] First attempt at kernel secure boot support Alan Cox 2012-09-04 16:12 ` Matthew Garrett 2012-10-01 21:07 ` Pavel Machek
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=1346774117-2277-10-git-send-email-mjg@redhat.com \ --to=mjg@redhat.com \ --cc=linux-efi@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-security-module@vger.kernel.org \ --subject='Re: [PATCH 09/11] efi: Enable secure boot lockdown automatically when enabled in firmware' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).