Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1527495

Re: [PATCH 5/6] efi: Disable secure boot if shim is in insecure mode

From Lukas Wunner <lukas@wunner.de>
Newsgroups linux.kernel
Subject Re: [PATCH 5/6] efi: Disable secure boot if shim is in insecure mode
Date 2016-11-22 14:10 +0100
Message-ID <sGiZI-7z8-3@gated-at.bofh.it> (permalink)
References <sEw14-1T0-39@gated-at.bofh.it> <sG7hT-8nV-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Nov 22, 2016 at 12:32:08AM +0000, David Howells wrote:
> From: Josh Boyer <jwboyer@fedoraproject.org>
> 
> A user can manually tell the shim boot loader to disable validation of
> images it loads.  When a user does this, it creates a UEFI variable called
> MokSBState that does not have the runtime attribute set.  Given that the
> user explicitly disabled validation, we can honor that and not enable
> secure boot mode if that variable is set.
> 
> Signed-off-by: Josh Boyer <jwboyer@fedoraproject.org>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
> 
>  drivers/firmware/efi/libstub/secureboot.c |   22 +++++++++++++++++++++-
>  1 file changed, 21 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/efi/libstub/secureboot.c b/drivers/firmware/efi/libstub/secureboot.c
> index e44d8c9ee150..d928398a3a52 100644
> --- a/drivers/firmware/efi/libstub/secureboot.c
> +++ b/drivers/firmware/efi/libstub/secureboot.c
> @@ -23,10 +23,14 @@ int efi_get_secureboot(void)
>  		'S', 'e', 'c', 'u', 'r', 'e', 'B', 'o', 'o', 't', 0 };
>  	static const efi_char16_t const sm_var_name[] = {
>  		'S', 'e', 't', 'u', 'p', 'M', 'o', 'd', 'e', 0 };
> +	static efi_char16_t const MokSBState_var_name[] = {
> +		'M', 'o', 'k', 'S', 'B', 'S', 't', 'a', 't', 'e', 0 };
>  
>  	static const efi_guid_t var_guid = EFI_GLOBAL_VARIABLE_GUID;
> +	static const efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID;
>  
> -	u8 val;
> +	u32 attr;
> +	u8 val, moksbstate;
>  	unsigned long size = sizeof(val);
>  	efi_status_t status;
>  
> @@ -50,6 +54,22 @@ int efi_get_secureboot(void)
>  	if (val == 1)
>  		return 0;
>  
> +	/* See if a user has put shim into insecure mode.  If so, and if the
> +	 * variable doesn't have the runtime attribute set, we might as well
> +	 * honor that.
> +	 */
> +	size = sizeof(moksbstate);
> +	status = f_getvar((efi_char16_t *)MokSBState_var_name, &shim_guid,
> +			  &attr, &size, &moksbstate);

Please use efi_call_runtime() instead of f_getvar().

> +
> +	/* If it fails, we don't care why.  Default to secure */
> +	if (status != EFI_SUCCESS)
> +		return 1;
> +
> +	if (!(attr & EFI_VARIABLE_RUNTIME_ACCESS) &&
> +	    moksbstate == 1)

This would fit on a single line.

Thanks,

Lukas

> +		return 0;
> +
>  	return 1;
>  
>  out_efi_err:
> 

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 02/16] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-16 22:50 +0100
  Re: [PATCH 02/16] efi: Get the secure boot status Lukas Wunner <lukas@wunner.de> - 2016-11-17 15:40 +0100
    Re: [PATCH 02/16] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-21 12:50 +0100
      Re: [PATCH 02/16] efi: Get the secure boot status Lukas Wunner <lukas@wunner.de> - 2016-11-21 21:00 +0100
    Re: [PATCH 02/16] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-21 12:50 +0100
      Re: [PATCH 02/16] efi: Get the secure boot status Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-21 13:00 +0100
        Re: [PATCH 02/16] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-21 13:50 +0100
          Re: [PATCH 02/16] efi: Get the secure boot status Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-21 14:20 +0100
            Re: [PATCH 02/16] efi: Get the secure boot status Lukas Wunner <lukas@wunner.de> - 2016-11-21 16:20 +0100
              Re: [PATCH 02/16] efi: Get the secure boot status Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-21 16:30 +0100
    [PATCH 6/6] efi: Add EFI_SECURE_BOOT bit David Howells <dhowells@redhat.com> - 2016-11-22 01:40 +0100
      Re: [PATCH 6/6] efi: Add EFI_SECURE_BOOT bit Lukas Wunner <lukas@wunner.de> - 2016-11-22 14:10 +0100
    [PATCH 5/6] efi: Disable secure boot if shim is in insecure mode David Howells <dhowells@redhat.com> - 2016-11-22 01:40 +0100
      Re: [PATCH 5/6] efi: Disable secure boot if shim is in insecure mode Lukas Wunner <lukas@wunner.de> - 2016-11-22 14:10 +0100
    [PATCH 2/6] arm/efi: Allow invocation of arbitrary runtime services David Howells <dhowells@redhat.com> - 2016-11-22 01:40 +0100
    [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services David Howells <dhowells@redhat.com> - 2016-11-22 01:40 +0100
      Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime  services Lukas Wunner <lukas@wunner.de> - 2016-11-22 11:20 +0100
        Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services David Howells <dhowells@redhat.com> - 2016-11-22 15:20 +0100
          Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime  services Joe Perches <joe@perches.com> - 2016-11-22 16:00 +0100
            Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services David Howells <dhowells@redhat.com> - 2016-11-22 17:00 +0100
              Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime  services Joe Perches <joe@perches.com> - 2016-11-22 17:30 +0100
                Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime services David Howells <dhowells@redhat.com> - 2016-11-22 17:50 +0100
                Re: [PATCH 1/6] x86/efi: Allow invocation of arbitrary runtime  services Joe Perches <joe@perches.com> - 2016-11-22 18:00 +0100
    [PATCH 3/6] efi: Add SHIM and image security database GUID  definitions David Howells <dhowells@redhat.com> - 2016-11-22 01:40 +0100
    [PATCH 4/6] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-22 01:40 +0100
      Re: [PATCH 4/6] efi: Get the secure boot status Lukas Wunner <lukas@wunner.de> - 2016-11-22 11:50 +0100
        Re: [PATCH 4/6] efi: Get the secure boot status Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-22 11:50 +0100
        Re: [PATCH 4/6] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-22 15:50 +0100
          Re: [PATCH 4/6] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-22 16:00 +0100
          Re: [PATCH 4/6] efi: Get the secure boot status Lukas Wunner <lukas@wunner.de> - 2016-11-22 21:30 +0100
            Re: [PATCH 4/6] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-23 01:10 +0100
        Re: [PATCH 4/6] efi: Get the secure boot status David Howells <dhowells@redhat.com> - 2016-11-22 16:10 +0100
          Re: [PATCH 4/6] efi: Get the secure boot status Lukas Wunner <lukas@wunner.de> - 2016-11-22 21:40 +0100

csiph-web