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


Groups > linux.kernel > #1530164

Re: [PATCH 5/7] efi: Get the secure boot status [ver #3]

From Ard Biesheuvel <ard.biesheuvel@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH 5/7] efi: Get the secure boot status [ver #3]
Date 2016-11-25 13:30 +0100
Message-ID <sHnND-wd-9@gated-at.bofh.it> (permalink)
References (1 earlier) <sGFjA-51L-33@gated-at.bofh.it> <sH8bT-76f-5@gated-at.bofh.it> <sHliN-7iy-11@gated-at.bofh.it> <sHlsu-7lD-25@gated-at.bofh.it> <sHnuh-m5-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 25 November 2016 at 12:03, David Howells <dhowells@redhat.com> wrote:
> How about the attached additional patch?  Should I be checking the UEFI
> version number if such is available?
>

Yes. In pre-2.6, DeployedMode is not a reserved name, and so it may be
possible for someone to slip in a DeployedMode=0 on a secure boot
enabled system to trick the kernel into thinking lockdown should be
disabled.


> David
> ---
> commit 981110f45ba73798875af7639d0328dc2d6f9919
> Author: David Howells <dhowells@redhat.com>
> Date:   Fri Nov 25 11:52:05 2016 +0000
>
>     efi: Handle secure boot from UEFI-2.6
>
>     UEFI-2.6 adds a new variable, DeployedMode.  If it exists, this must be 1
>     to engage lockdown mode.
>
>     Reported-by: James Bottomley <James.Bottomley@HansenPartnership.com>
>     Signed-off-by: David Howells <dhowells@redhat.com>
>
> diff --git a/drivers/firmware/efi/libstub/secureboot.c b/drivers/firmware/efi/libstub/secureboot.c
> index ca643eba5a4b..4c3bddef4fb3 100644
> --- a/drivers/firmware/efi/libstub/secureboot.c
> +++ b/drivers/firmware/efi/libstub/secureboot.c
> @@ -22,6 +22,9 @@ static const efi_char16_t const efi_SecureBoot_name[] = {
>  static const efi_char16_t const efi_SetupMode_name[] = {
>         'S', 'e', 't', 'u', 'p', 'M', 'o', 'd', 'e', 0
>  };
> +static const efi_char16_t const efi_DeployedMode_name[] = {
> +       'D', 'e', 'p', 'l', 'o', 'y', 'e', 'd', 'M', 'o', 'd', 'e', 0
> +};
>
>  /* SHIM variables */
>  static const efi_guid_t shim_guid = EFI_SHIM_LOCK_GUID;
> @@ -62,6 +65,16 @@ int efi_get_secureboot(efi_system_table_t *sys_table_arg)
>         if (val == 1)
>                 return 0;
>
> +       status = get_efi_var(efi_DeployedMode_name, &efi_variable_guid,
> +                            NULL, &size, &val);
> +       if (status != EFI_NOT_FOUND) {
> +               if (status != EFI_SUCCESS)
> +                       goto out_efi_err;
> +
> +               if (val == 1)
> +                       return 0;

I think the logic is the wrong way around here. Secure Boot is enabled
if SecureBoot=1 and SetupMode=0, unless DeployedMode=0. So you should
return 0 here if val == 0, but only when running on 2.6 or later.

-- 
Ard.

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


Thread

[PATCH 0/7] efi: Pass secure boot mode to kernel [ver #3] David Howells <dhowells@redhat.com> - 2016-11-23 14:00 +0100
  [PATCH 2/7] x86/efi: Allow invocation of arbitrary runtime services  [ver #3] David Howells <dhowells@redhat.com> - 2016-11-23 14:00 +0100
  [PATCH 4/7] efi: Add SHIM and image security database GUID  definitions [ver #3] David Howells <dhowells@redhat.com> - 2016-11-23 14:00 +0100
  [PATCH 7/7] efi: Add EFI_SECURE_BOOT bit [ver #3] David Howells <dhowells@redhat.com> - 2016-11-23 14:00 +0100
  [PATCH 1/7] efi: use typed function pointers for runtime services  table [ver #3] David Howells <dhowells@redhat.com> - 2016-11-23 14:00 +0100
  [PATCH 6/7] efi: Disable secure boot if shim is in insecure mode  [ver #3] David Howells <dhowells@redhat.com> - 2016-11-23 14:00 +0100
  [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-23 14:00 +0100
    Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] James Bottomley <James.Bottomley@HansenPartnership.com> - 2016-11-24 20:50 +0100
      Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-25 10:50 +0100
        Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-25 11:00 +0100
          Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-25 13:10 +0100
            Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-25 13:30 +0100
              Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-25 13:50 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-25 13:50 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-25 14:10 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-25 14:30 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-25 14:10 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-25 15:00 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-25 17:00 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-25 18:00 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] David Howells <dhowells@redhat.com> - 2016-11-25 18:00 +0100
                Re: [PATCH 5/7] efi: Get the secure boot status [ver #3] Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-11-25 18:00 +0100
  [PATCH 3/7] arm/efi: Allow invocation of arbitrary runtime services  [ver #3] David Howells <dhowells@redhat.com> - 2016-11-23 14:00 +0100

csiph-web