x86/xen/efi: Initialize UEFI secure boot state during dom0 boot
Subsystems (3)
PATCH v2 1/1 x86/xen/efi: Initialize UEFI secure boot state during dom0 boot
Initialize UEFI secure boot state during dom0 boot. Otherwise the kernel may not even know that it runs on secure boot enabled platform.
--- arch/x86/xen/efi.c | 57 +++++++++++++++++++++++++++++ drivers/firmware/efi/libstub/secureboot.c | 3 ++ 2 files changed, 60 insertions(+)
arch/x86/xen/efi.c +57 -0
@@ -115,6 +115,61 @@ static efi_system_table_t __init *xen_efi_probe(void)return &efi_systab_xen; } +/* +* Determine whether we're in secure boot mode. +* +* Please keep the logic in sync with +* drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot(). +*/ +static enum efi_secureboot_mode xen_efi_get_secureboot (void ) +{ +static efi_guid_t efi_variable_guid =EFI_GLOBAL_VARIABLE_GUID ; +static efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; +efi_status_t status; +u8 moksbstate, secboot, setupmode; +unsigned long size; + + size =sizeof (secboot); + status = efi.get_variable (L"SecureBoot" , &efi_variable_guid, +NULL , &size, &secboot); + +if (status ==EFI_NOT_FOUND ) +return efi_secureboot_mode_disabled; + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + + size =sizeof (setupmode); + status = efi.get_variable (L"SetupMode" , &efi_variable_guid, +NULL , &size, &setupmode); + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (secboot ==0 || setupmode ==1 ) +return efi_secureboot_mode_disabled; + +/* See if a user has put the shim into insecure mode. */ + size =sizeof (moksbstate); + status = efi.get_variable (L"MokSBStateRT" , &shim_guid, +NULL , &size, &moksbstate); + +/* If it fails, we don't care why. Default to secure. */ +if (status !=EFI_SUCCESS ) + goto secure_boot_enabled; + +if (moksbstate ==1 ) +return efi_secureboot_mode_disabled; + + secure_boot_enabled: +pr_info ("UEFI Secure Boot is enabled.\n" ); +return efi_secureboot_mode_enabled; + + out_efi_err: +pr_err ("Could not determine UEFI Secure Boot status.\n" ); +return efi_secureboot_mode_unknown; +} +void __init xen_efi_init (void ) {efi_system_table_t *efi_systab_xen;
@@ -129,6 +184,8 @@ void __init xen_efi_init(void) boot_params.efi_info.efi_systab = (__u32 )__pa (efi_systab_xen); boot_params.efi_info.efi_systab_hi = (__u32)(__pa (efi_systab_xen) >>32 ); + boot_params.secure_boot =xen_efi_get_secureboot (); +set_bit (EFI_BOOT , &efi.flags);set_bit (EFI_PARAVIRT , &efi.flags);set_bit (EFI_64BIT , &efi.flags);
drivers/firmware/efi/libstub/secureboot.c +3 -0
@@ -30,6 +30,9 @@/* * Determine whether we're in secure boot mode. +* +* Please keep the logic in sync with +* arch/x86/xen/efi.c:xen_efi_get_secureboot(). */ enum efi_secureboot_mode efi_get_secureboot (efi_system_table_t *sys_table_arg) {
Signature · 1 line
1.7.10.4
Quoted 66 lines · Daniel Kiper
Initialize UEFI secure boot state during dom0 boot. Otherwise the kernel
may not even know that it runs on secure boot enabled platform.Signed-off-by Daniel Kiper <[email protected]>---
arch/x86/xen/efi.c | 57
+++++++++++++++++++++++++++++
drivers/firmware/efi/libstub/secureboot.c | 3 ++2 files changed, 60 insertions(+)arch/x86/xen/efi.c +0
-0@@ -115,6 +115,61 @@ static efi_system_table_t __init *xen_efi_probe (void) return &efi_systab_xen; }arch/x86/xen/efi.c +9
-0+/* +* Determine whether we're in secure boot mode. +* +* Please keep the logic in sync with +* drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot(). +*/ +static enum efi_secureboot_mode xen_efi_get_secureboot (void ) +{ + static efi_guid_t efi_variable_guid =
EFI_GLOBAL_VARIABLE_GUID;arch/x86/xen/efi.c +36
-0+static efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; +efi_status_t status; +u8 moksbstate, secboot, setupmode; +unsigned long size; + + size =sizeof (secboot); + status = efi.get_variable (L"SecureBoot" , &efi_variable_guid, + NULL, &size, &secboot); + +if (status ==EFI_NOT_FOUND ) +return efi_secureboot_mode_disabled; + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + + size =sizeof (setupmode); + status = efi.get_variable (L"SetupMode" , &efi_variable_guid, + NULL, &size, &setupmode); + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (secboot ==0 || setupmode ==1 ) +return efi_secureboot_mode_disabled; + +/* See if a user has put the shim into insecure mode. */ + size =sizeof (moksbstate); + status = efi.get_variable (L"MokSBStateRT" , &shim_guid, + NULL, &size, &moksbstate); + +/* If it fails, we don't care why. Default to secure. */ +if (status !=EFI_SUCCESS ) + goto secure_boot_enabled; + +if (moksbstate ==1 ) +return efi_secureboot_mode_disabled;
arch/x86/xen/efi.c static efi_system_table_t __init *xen_efi_probe(void) · line 172
Quoted 10 lines
arch/x86/xen/efi.c +10
-0+ + secure_boot_enabled: +pr_info ("UEFI Secure Boot is enabled.\n" ); +return efi_secureboot_mode_enabled; + + out_efi_err: +pr_err ("Could not determine UEFI Secure Boot status.\n" ); +return efi_secureboot_mode_unknown; +} +
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.c
Which is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub efi_get_secureboot() so we're not duplicating the implementation of policy?
James
Quoted 80 lines · James Bottomley
Quoted 66 lines · Daniel Kiper
Initialize UEFI secure boot state during dom0 boot. Otherwise the kernel
may not even know that it runs on secure boot enabled platform.Signed-off-by Daniel Kiper <[email protected]>---
arch/x86/xen/efi.c | 57
+++++++++++++++++++++++++++++
drivers/firmware/efi/libstub/secureboot.c | 3 ++2 files changed, 60 insertions(+)arch/x86/xen/efi.c +0
-0@@ -115,6 +115,61 @@ static efi_system_table_t __init *xen_efi_probe (void) return &efi_systab_xen; }arch/x86/xen/efi.c +9
-0+/* +* Determine whether we're in secure boot mode. +* +* Please keep the logic in sync with +* drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot(). +*/ +static enum efi_secureboot_mode xen_efi_get_secureboot (void ) +{ + static efi_guid_t efi_variable_guid =
EFI_GLOBAL_VARIABLE_GUID;arch/x86/xen/efi.c +36
-0+static efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; +efi_status_t status; +u8 moksbstate, secboot, setupmode; +unsigned long size; + + size =sizeof (secboot); + status = efi.get_variable (L"SecureBoot" , &efi_variable_guid, + NULL, &size, &secboot); + +if (status ==EFI_NOT_FOUND ) +return efi_secureboot_mode_disabled; + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + + size =sizeof (setupmode); + status = efi.get_variable (L"SetupMode" , &efi_variable_guid, + NULL, &size, &setupmode); + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (secboot ==0 || setupmode ==1 ) +return efi_secureboot_mode_disabled; + +/* See if a user has put the shim into insecure mode. */ + size =sizeof (moksbstate); + status = efi.get_variable (L"MokSBStateRT" , &shim_guid, + NULL, &size, &moksbstate); + +/* If it fails, we don't care why. Default to secure. */ +if (status !=EFI_SUCCESS ) + goto secure_boot_enabled; + +if (moksbstate ==1 ) +return efi_secureboot_mode_disabled;arch/x86/xen/efi.c static efi_system_table_t __init *xen_efi_probe(void) · line 172
Quoted 10 lines
arch/x86/xen/efi.c +10
-0+ + secure_boot_enabled: +pr_info ("UEFI Secure Boot is enabled.\n" ); +return efi_secureboot_mode_enabled; + + out_efi_err: +pr_err ("Could not determine UEFI Secure Boot status.\n" ); +return efi_secureboot_mode_unknown; +} +This looks like a bad idea: you're duplicating the secure boot check in
Quoted 6 lines
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?
Well, here is the first version of this patch: https://lkml.org/lkml/2018/1/9/496
Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.
Daniel
Quoted 95 lines · Daniel Kiper
Quoted 87 lines · James Bottomley
Quoted 78 lines · Daniel Kiper
Initialize UEFI secure boot state during dom0 boot. Otherwise the kernel may not even know that it runs on secure boot enabled platform.
Signed-off-by Daniel Kiper <[email protected]>---
arch/x86/xen/efi.c | 57
+++++++++++++++++++++++++++++
drivers/firmware/efi/libstub/secureboot.c | 3 ++2 files changed, 60 insertions(+)arch/x86/xen/efi.c +0
-0@@ -115,6 +115,61 @@ static efi_system_table_t __init *xen_efi_probe (void) return &efi_systab_xen; }
+/*
+ * Determine whether we're in secure boot mode.
+ *
+ * Please keep the logic in sync with
+ * drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot().
+ */arch/x86/xen/efi.c +3
-0+static enum efi_secureboot_mode xen_efi_get_secureboot (void ) +{ + static efi_guid_t efi_variable_guid =
EFI_GLOBAL_VARIABLE_GUID;arch/x86/xen/efi.c +7
-0+static efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; +efi_status_t status; +u8 moksbstate, secboot, setupmode; +unsigned long size; + + size =sizeof (secboot); + status = efi.get_variable(L"SecureBoot",
&efi_variable_guid,arch/x86/xen/efi.c +10
-0+ NULL, &size, &secboot); + +if (status ==EFI_NOT_FOUND ) +return efi_secureboot_mode_disabled; + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + + size =sizeof (setupmode); + status = efi.get_variable(L"SetupMode",
&efi_variable_guid,arch/x86/xen/efi.c +26
-0+ NULL, &size, &setupmode); + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (secboot ==0 || setupmode ==1 ) +return efi_secureboot_mode_disabled; + +/* See if a user has put the shim into insecure mode. */ + size =sizeof (moksbstate); + status = efi.get_variable (L"MokSBStateRT" , &shim_guid, + NULL, &size, &moksbstate); + +/* If it fails, we don't care why. Default to secure. */ +if (status !=EFI_SUCCESS ) + goto secure_boot_enabled; + +if (moksbstate ==1 ) +return efi_secureboot_mode_disabled; + + secure_boot_enabled: +pr_info ("UEFI Secure Boot is enabled.\n" ); +return efi_secureboot_mode_enabled; + + out_efi_err: + pr_err("Could not determine UEFI Secure Bootstatus.\n");
arch/x86/xen/efi.c static efi_system_table_t __init *xen_efi_probe(void) · line 172
Quoted 3 lines
arch/x86/xen/efi.c +3
-0+return efi_secureboot_mode_unknown; +} +This looks like a bad idea: you're duplicating the secure boot check in
Quoted 6 lines
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.
One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you calling efi code separately and trying to use the insecure RT variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
James
Quoted 2 lines · James Bottomley
Quoted 1 line · Daniel Kiper
On Tue, Apr 03, 2018 at 08:44:41AM -0700, James Bottomley wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?
Quoted 8 lines
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you
Do you mean variable in kernel proper or something like that? If yes this is not possible. EFI Linux stub is not executed in Xen dom0. All UEFI infrastructure is owned and operated by Xen. Dom0 kernel can access some stuff in UEFI, including variables, via hypercall. However, when dom0 runs only UEFI runtime services are available.
Quoted 1 line
calling efi code separately and trying to use the insecure RT
I am not sure why they are insecure.
Quoted 2 lines
variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
That would be perfect but I have a feeling that in form proposed above it is not possible.
Daniel
Quoted 33 lines · Daniel Kiper
Quoted 2 lines · James Bottomley
Quoted 1 line · Daniel Kiper
On Tue, Apr 03, 2018 at 08:44:41AM -0700, James Bottomley wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?Quoted 8 lines
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you
Do you mean variable in kernel proper or something like that? If yes this is not possible. EFI Linux stub is not executed in Xen dom0. All UEFI infrastructure is owned and operated by Xen. Dom0 kernel can access some stuff in UEFI, including variables, via hypercall. However, when dom0 runs only UEFI runtime services are available.
Quoted 1 line
calling efi code separately and trying to use the insecure RT
Quoted 7 lines
I am not sure why they are insecure.
Quoted 2 lines
variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
That would be perfect but I have a feeling that in form proposed above it is not possible.
Ping?
Daniel
Ard Biesheuvel
AppliedQuoted 36 lines · Daniel Kiper
Quoted 35 lines · Daniel Kiper
Quoted 2 lines · James Bottomley
Quoted 1 line · Daniel Kiper
On Tue, Apr 03, 2018 at 08:44:41AM -0700, James Bottomley wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?Quoted 8 lines
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you
Do you mean variable in kernel proper or something like that? If yes this is not possible. EFI Linux stub is not executed in Xen dom0. All UEFI infrastructure is owned and operated by Xen. Dom0 kernel can access some stuff in UEFI, including variables, via hypercall. However, when dom0 runs only UEFI runtime services are available.
Quoted 1 line
calling efi code separately and trying to use the insecure RT
I am not sure why they are insecure.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
That would be perfect but I have a feeling that in form proposed above it is not possible.
Ping?
(apologies if this is a duplicate email - I thought I had replied already but I don't see it in my sent folder)
Queued in efi/next - thanks.
Quoted 43 lines · Ard Biesheuvel
Quoted 42 lines · Daniel Kiper
Quoted 40 lines · Daniel Kiper
Quoted 2 lines · James Bottomley
Quoted 1 line · Daniel Kiper
On Tue, Apr 03, 2018 at 08:44:41AM -0700, James Bottomley wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?Quoted 8 lines
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you
Do you mean variable in kernel proper or something like that? If yes this is not possible. EFI Linux stub is not executed in Xen dom0. All UEFI infrastructure is owned and operated by Xen. Dom0 kernel can access some stuff in UEFI, including variables, via hypercall. However, when dom0 runs only UEFI runtime services are available.
Quoted 1 line
calling efi code separately and trying to use the insecure RT
I am not sure why they are insecure.
Quoted 2 lines
variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
That would be perfect but I have a feeling that in form proposed above it is not possible.
Quoted 7 lines
Quoted 2 lines
Ping?
(apologies if this is a duplicate email - I thought I had replied already but I don't see it in my sent folder)
Queued in efi/next - thanks.
Thanks a lot!
Daniel
Quoted 43 lines · Ard Biesheuvel
Quoted 42 lines · Daniel Kiper
Quoted 40 lines · Daniel Kiper
Quoted 2 lines · James Bottomley
Quoted 1 line · Daniel Kiper
On Tue, Apr 03, 2018 at 08:44:41AM -0700, James Bottomley wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?Quoted 8 lines
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you
Do you mean variable in kernel proper or something like that? If yes this is not possible. EFI Linux stub is not executed in Xen dom0. All UEFI infrastructure is owned and operated by Xen. Dom0 kernel can access some stuff in UEFI, including variables, via hypercall. However, when dom0 runs only UEFI runtime services are available.
Quoted 1 line
calling efi code separately and trying to use the insecure RT
I am not sure why they are insecure.
Quoted 2 lines
variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
That would be perfect but I have a feeling that in form proposed above it is not possible.
Quoted 7 lines
Quoted 2 lines
Ping?
(apologies if this is a duplicate email - I thought I had replied already but I don't see it in my sent folder)
Queued in efi/next - thanks.
Thanks a lot!
Daniel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Ard Biesheuvel
AppliedQuoted 36 lines · Daniel Kiper
Quoted 35 lines · Daniel Kiper
Quoted 2 lines · James Bottomley
Quoted 1 line · Daniel Kiper
On Tue, Apr 03, 2018 at 08:44:41AM -0700, James Bottomley wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?Quoted 8 lines
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you
Do you mean variable in kernel proper or something like that? If yes this is not possible. EFI Linux stub is not executed in Xen dom0. All UEFI infrastructure is owned and operated by Xen. Dom0 kernel can access some stuff in UEFI, including variables, via hypercall. However, when dom0 runs only UEFI runtime services are available.
Quoted 1 line
calling efi code separately and trying to use the insecure RT
I am not sure why they are insecure.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
That would be perfect but I have a feeling that in form proposed above it is not possible.
Ping?
(apologies if this is a duplicate email - I thought I had replied already but I don't see it in my sent folder)
Queued in efi/next - thanks.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 33 lines · Daniel Kiper
Quoted 2 lines · James Bottomley
Quoted 1 line · Daniel Kiper
On Tue, Apr 03, 2018 at 08:44:41AM -0700, James Bottomley wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?Quoted 8 lines
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you
Do you mean variable in kernel proper or something like that? If yes this is not possible. EFI Linux stub is not executed in Xen dom0. All UEFI infrastructure is owned and operated by Xen. Dom0 kernel can access some stuff in UEFI, including variables, via hypercall. However, when dom0 runs only UEFI runtime services are available.
Quoted 1 line
calling efi code separately and trying to use the insecure RT
Quoted 7 lines
I am not sure why they are insecure.
Quoted 2 lines
variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
That would be perfect but I have a feeling that in form proposed above it is not possible.
Ping?
Daniel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 2 lines · James Bottomley
Quoted 1 line · Daniel Kiper
On Tue, Apr 03, 2018 at 08:44:41AM -0700, James Bottomley wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?
Quoted 8 lines
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you
Do you mean variable in kernel proper or something like that? If yes this is not possible. EFI Linux stub is not executed in Xen dom0. All UEFI infrastructure is owned and operated by Xen. Dom0 kernel can access some stuff in UEFI, including variables, via hypercall. However, when dom0 runs only UEFI runtime services are available.
Quoted 1 line
calling efi code separately and trying to use the insecure RT
I am not sure why they are insecure.
Quoted 2 lines
variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
That would be perfect but I have a feeling that in form proposed above it is not possible.
Daniel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 95 lines · Daniel Kiper
Quoted 87 lines · James Bottomley
Quoted 78 lines · Daniel Kiper
Initialize UEFI secure boot state during dom0 boot. Otherwise the kernel may not even know that it runs on secure boot enabled platform.
Signed-off-by Daniel Kiper <[email protected]>---
arch/x86/xen/efi.c | 57
+++++++++++++++++++++++++++++
drivers/firmware/efi/libstub/secureboot.c | 3 ++2 files changed, 60 insertions(+)arch/x86/xen/efi.c +0
-0@@ -115,6 +115,61 @@ static efi_system_table_t __init *xen_efi_probe (void) return &efi_systab_xen; }
+/*
+ * Determine whether we're in secure boot mode.
+ *
+ * Please keep the logic in sync with
+ * drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot().
+ */arch/x86/xen/efi.c +3
-0+static enum efi_secureboot_mode xen_efi_get_secureboot (void ) +{ + static efi_guid_t efi_variable_guid =
EFI_GLOBAL_VARIABLE_GUID;arch/x86/xen/efi.c +7
-0+static efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; +efi_status_t status; +u8 moksbstate, secboot, setupmode; +unsigned long size; + + size =sizeof (secboot); + status = efi.get_variable(L"SecureBoot",
&efi_variable_guid,arch/x86/xen/efi.c +10
-0+ NULL, &size, &secboot); + +if (status ==EFI_NOT_FOUND ) +return efi_secureboot_mode_disabled; + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + + size =sizeof (setupmode); + status = efi.get_variable(L"SetupMode",
&efi_variable_guid,arch/x86/xen/efi.c +26
-0+ NULL, &size, &setupmode); + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (secboot ==0 || setupmode ==1 ) +return efi_secureboot_mode_disabled; + +/* See if a user has put the shim into insecure mode. */ + size =sizeof (moksbstate); + status = efi.get_variable (L"MokSBStateRT" , &shim_guid, + NULL, &size, &moksbstate); + +/* If it fails, we don't care why. Default to secure. */ +if (status !=EFI_SUCCESS ) + goto secure_boot_enabled; + +if (moksbstate ==1 ) +return efi_secureboot_mode_disabled; + + secure_boot_enabled: +pr_info ("UEFI Secure Boot is enabled.\n" ); +return efi_secureboot_mode_enabled; + + out_efi_err: + pr_err("Could not determine UEFI Secure Bootstatus.\n");
arch/x86/xen/efi.c static efi_system_table_t __init *xen_efi_probe(void) · line 172
Quoted 3 lines
arch/x86/xen/efi.c +3
-0+return efi_secureboot_mode_unknown; +} +This looks like a bad idea: you're duplicating the secure boot check in
Quoted 6 lines
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?
Quoted 5 lines
Well, here is the first version of this patch:
https://lkml.org/lkml/2018/1/9/496 Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.
One way might be simply to have the pre exit-boot-services code lay down a variable containing the state which you pick up, rather than you calling efi code separately and trying to use the insecure RT variables. That way there's a uniform view of the internal kernel secure boot state that everyone can use.
James
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 80 lines · James Bottomley
Quoted 66 lines · Daniel Kiper
Initialize UEFI secure boot state during dom0 boot. Otherwise the kernel
may not even know that it runs on secure boot enabled platform.Signed-off-by Daniel Kiper <[email protected]>---
arch/x86/xen/efi.c | 57
+++++++++++++++++++++++++++++
drivers/firmware/efi/libstub/secureboot.c | 3 ++2 files changed, 60 insertions(+)arch/x86/xen/efi.c +0
-0@@ -115,6 +115,61 @@ static efi_system_table_t __init *xen_efi_probe (void) return &efi_systab_xen; }arch/x86/xen/efi.c +9
-0+/* +* Determine whether we're in secure boot mode. +* +* Please keep the logic in sync with +* drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot(). +*/ +static enum efi_secureboot_mode xen_efi_get_secureboot (void ) +{ + static efi_guid_t efi_variable_guid =
EFI_GLOBAL_VARIABLE_GUID;arch/x86/xen/efi.c +36
-0+static efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; +efi_status_t status; +u8 moksbstate, secboot, setupmode; +unsigned long size; + + size =sizeof (secboot); + status = efi.get_variable (L"SecureBoot" , &efi_variable_guid, + NULL, &size, &secboot); + +if (status ==EFI_NOT_FOUND ) +return efi_secureboot_mode_disabled; + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + + size =sizeof (setupmode); + status = efi.get_variable (L"SetupMode" , &efi_variable_guid, + NULL, &size, &setupmode); + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (secboot ==0 || setupmode ==1 ) +return efi_secureboot_mode_disabled; + +/* See if a user has put the shim into insecure mode. */ + size =sizeof (moksbstate); + status = efi.get_variable (L"MokSBStateRT" , &shim_guid, + NULL, &size, &moksbstate); + +/* If it fails, we don't care why. Default to secure. */ +if (status !=EFI_SUCCESS ) + goto secure_boot_enabled; + +if (moksbstate ==1 ) +return efi_secureboot_mode_disabled;arch/x86/xen/efi.c static efi_system_table_t __init *xen_efi_probe(void) · line 172
Quoted 10 lines
arch/x86/xen/efi.c +10
-0+ + secure_boot_enabled: +pr_info ("UEFI Secure Boot is enabled.\n" ); +return efi_secureboot_mode_enabled; + + out_efi_err: +pr_err ("Could not determine UEFI Secure Boot status.\n" ); +return efi_secureboot_mode_unknown; +} +This looks like a bad idea: you're duplicating the secure boot check in
Quoted 6 lines
drivers/firmware/efi/libstub/secureboot.cWhich is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub
efi_get_secureboot()so we're not duplicating the implementation of policy?
Well, here is the first version of this patch: https://lkml.org/lkml/2018/1/9/496
Ard did not like it. I was not happy too. In general both approaches are not perfect. More you can find in the discussion around this patchset. If you have better idea how to do that I am happy to implement it.
Daniel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 66 lines · Daniel Kiper
Initialize UEFI secure boot state during dom0 boot. Otherwise the kernel
may not even know that it runs on secure boot enabled platform.Signed-off-by Daniel Kiper <[email protected]>---
arch/x86/xen/efi.c | 57
+++++++++++++++++++++++++++++
drivers/firmware/efi/libstub/secureboot.c | 3 ++2 files changed, 60 insertions(+)arch/x86/xen/efi.c +0
-0@@ -115,6 +115,61 @@ static efi_system_table_t __init *xen_efi_probe (void) return &efi_systab_xen; }arch/x86/xen/efi.c +9
-0+/* +* Determine whether we're in secure boot mode. +* +* Please keep the logic in sync with +* drivers/firmware/efi/libstub/secureboot.c:efi_get_secureboot(). +*/ +static enum efi_secureboot_mode xen_efi_get_secureboot (void ) +{ + static efi_guid_t efi_variable_guid =
EFI_GLOBAL_VARIABLE_GUID;arch/x86/xen/efi.c +36
-0+static efi_guid_t shim_guid =EFI_SHIM_LOCK_GUID ; +efi_status_t status; +u8 moksbstate, secboot, setupmode; +unsigned long size; + + size =sizeof (secboot); + status = efi.get_variable (L"SecureBoot" , &efi_variable_guid, + NULL, &size, &secboot); + +if (status ==EFI_NOT_FOUND ) +return efi_secureboot_mode_disabled; + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + + size =sizeof (setupmode); + status = efi.get_variable (L"SetupMode" , &efi_variable_guid, + NULL, &size, &setupmode); + +if (status !=EFI_SUCCESS ) + goto out_efi_err; + +if (secboot ==0 || setupmode ==1 ) +return efi_secureboot_mode_disabled; + +/* See if a user has put the shim into insecure mode. */ + size =sizeof (moksbstate); + status = efi.get_variable (L"MokSBStateRT" , &shim_guid, + NULL, &size, &moksbstate); + +/* If it fails, we don't care why. Default to secure. */ +if (status !=EFI_SUCCESS ) + goto secure_boot_enabled; + +if (moksbstate ==1 ) +return efi_secureboot_mode_disabled;
arch/x86/xen/efi.c static efi_system_table_t __init *xen_efi_probe(void) · line 172
Quoted 10 lines
arch/x86/xen/efi.c +10
-0+ + secure_boot_enabled: +pr_info ("UEFI Secure Boot is enabled.\n" ); +return efi_secureboot_mode_enabled; + + out_efi_err: +pr_err ("Could not determine UEFI Secure Boot status.\n" ); +return efi_secureboot_mode_unknown; +} +
This looks like a bad idea: you're duplicating the secure boot check in
drivers/firmware/efi/libstub/secureboot.c
Which is an implementation of policy. If we have to have policy in the kernel, it should really only be in one place to prevent drift; why can't you simply use the libstub efi_get_secureboot() so we're not duplicating the implementation of policy?
James
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel