xen/efi: Do not check kernel signature if it was embedded
PATCH 1/1 xen/efi: Do not check kernel signature if it was embedded
Using UKI it's possible to embed Linux kernel into xen.efi file. In this case the signature for Secure Boot is applied to the whole xen.efi, including the kernel.
So checking for specific signature for the kernel is not needed.
In case Secure Boot is not enabled there's no reason to check kernel signature.
--- xen/common/efi/boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
xen/common/efi/boot.c +10 -0
@@ -1291,6 +1291,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,bool base_video = false;const char *option_str;bool use_cfg_file; +bool kernel_was_verified = false;int dt_modules_found;__set_bit (EFI_BOOT , &efi_flags);
@@ -1461,6 +1462,14 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,read_file (dir_handle,s2w (&name), &kernel, option_str); efi_bs->FreePool (name.w); } +else + { +/* +* As kernel was embedded it was either verified for Secure Boot +* or Secure Boot is not enabled. +*/ + kernel_was_verified = true; + }if ( !read_section (loaded_image,L"ramdisk" , &ramdisk,NULL ) ) {
@@ -1534,6 +1543,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,* verify it. */ if ( kernel.ptr && + !kernel_was_verified && !EFI_ERROR (efi_bs->LocateProtocol (&shim_lock_guid,NULL , (void **)&shim_lock)) && (status = shim_lock->Verify (kernel.ptr, kernel.size)) !=EFI_SUCCESS )
Signature · 1 line
2.43.0
Quoted 7 lines · Frediano Ziglio
Using UKI it's possible to embed Linux kernel into xen.efi file. In this case the signature for Secure Boot is applied to the whole xen.efi, including the kernel.
So checking for specific signature for the kernel is not needed.
In case Secure Boot is not enabled there's no reason to check kernel signature.
The last sentence (here and in the comment below) seem to be unrelated to this change - it's more about shim lock protocol being available, which this patch doesn't change.
Quoted 43 lines
Signed-off-by Frediano Ziglio <[email protected]>--- xen/common/efi/boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+)xen/common/efi/boot.c +10
-0@@ -1291,6 +1291,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,bool base_video = false;const char *option_str;bool use_cfg_file; +bool kernel_was_verified = false;int dt_modules_found;__set_bit (EFI_BOOT , &efi_flags);@@ -1461,6 +1462,14 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,read_file (dir_handle,s2w (&name), &kernel, option_str); efi_bs->FreePool (name.w); } +else + { +/* +* As kernel was embedded it was either verified for Secure Boot +* or Secure Boot is not enabled. +*/ + kernel_was_verified = true; + }if ( !read_section (loaded_image,L"ramdisk" , &ramdisk,NULL ) ) {@@ -1534,6 +1543,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,* verify it. */ if ( kernel.ptr && + !kernel_was_verified && !EFI_ERROR (efi_bs->LocateProtocol (&shim_lock_guid,NULL , (void **)&shim_lock)) && (status = shim_lock->Verify (kernel.ptr, kernel.size)) !=EFI_SUCCESS )Signature · 1 line
2.43.0
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Quoted 10 lines · Marek Marczykowski-Górecki
Quoted 7 lines · Frediano Ziglio
Using UKI it's possible to embed Linux kernel into xen.efi file. In this case the signature for Secure Boot is applied to the whole xen.efi, including the kernel.
So checking for specific signature for the kernel is not needed.
In case Secure Boot is not enabled there's no reason to check kernel signature.
Quoted 4 lines
The last sentence (here and in the comment below) seem to be unrelated to this change - it's more about shim lock protocol being available, which this patch doesn't change.
Should I just remove the sentence?
Beside that sentence, any issue with this change?
Quoted 48 lines
Quoted 41 lines
Signed-off-by Frediano Ziglio <[email protected]>--- xen/common/efi/boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+)xen/common/efi/boot.c +10
-1@@ -1291,6 +1291,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,bool base_video = false;const char *option_str;bool use_cfg_file; +bool kernel_was_verified = false;int dt_modules_found;__set_bit (EFI_BOOT , &efi_flags);@@ -1461,6 +1462,14 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,read_file (dir_handle,s2w (&name), &kernel, option_str); efi_bs->FreePool (name.w); } +else + { +/* +* As kernel was embedded it was either verified for Secure Boot +* or Secure Boot is not enabled. +*/ + kernel_was_verified = true; + }if ( !read_section (loaded_image,L"ramdisk" , &ramdisk,NULL ) ) {@@ -1534,6 +1543,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,* verify it. */ if ( kernel.ptr && + !kernel_was_verified && !EFI_ERROR (efi_bs->LocateProtocol (&shim_lock_guid,NULL , (void **)&shim_lock)) && (status = shim_lock->Verify (kernel.ptr, kernel.size)) !=EFI_SUCCESS ) --Quoted 2 lines
2.43.0
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
Quoted 12 lines · Frediano Ziglio
Quoted 10 lines · Marek Marczykowski-Górecki
Quoted 7 lines · Frediano Ziglio
Using UKI it's possible to embed Linux kernel into xen.efi file. In this case the signature for Secure Boot is applied to the whole xen.efi, including the kernel.
So checking for specific signature for the kernel is not needed.
In case Secure Boot is not enabled there's no reason to check kernel signature.
Quoted 6 lines
Quoted 4 lines
The last sentence (here and in the comment below) seem to be unrelated to this change - it's more about shim lock protocol being available, which this patch doesn't change.
Should I just remove the sentence?
Yes, and reword the code comment a bit.
Quoted 1 line
Beside that sentence, any issue with this change?
Other than that it looks fine for me.
Quoted 48 lines
Quoted 48 lines
Quoted 41 lines
Signed-off-by Frediano Ziglio <[email protected]>--- xen/common/efi/boot.c | 10 ++++++++++ 1 file changed, 10 insertions(+)xen/common/efi/boot.c +10
-1@@ -1291,6 +1291,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,bool base_video = false;const char *option_str;bool use_cfg_file; +bool kernel_was_verified = false;int dt_modules_found;__set_bit (EFI_BOOT , &efi_flags);@@ -1461,6 +1462,14 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,read_file (dir_handle,s2w (&name), &kernel, option_str); efi_bs->FreePool (name.w); } +else + { +/* +* As kernel was embedded it was either verified for Secure Boot +* or Secure Boot is not enabled. +*/ + kernel_was_verified = true; + }if ( !read_section (loaded_image,L"ramdisk" , &ramdisk,NULL ) ) {@@ -1534,6 +1543,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,* verify it. */ if ( kernel.ptr && + !kernel_was_verified && !EFI_ERROR (efi_bs->LocateProtocol (&shim_lock_guid,NULL , (void **)&shim_lock)) && (status = shim_lock->Verify (kernel.ptr, kernel.size)) !=EFI_SUCCESS ) --Quoted 2 lines
2.43.0
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
xen/common/efi/boot.c void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle, · line 1294
Quoted 7 lines · Frediano Ziglio
xen/common/efi/boot.c +1
-0@@ -1291,6 +1291,7 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,bool base_video = false;const char *option_str;bool use_cfg_file; +bool kernel_was_verified = false;
May I suggest to drop the "was" infix from the variable name? The name is imo as clear without it.
Jan