First batch of EFI fixes for v6.2:

- avoid a potential crash on the efi_subsys_init() error path
 - use more appropriate error code for runtime services calls issued
   after a crash in the firmware occurred
 - avoid READ_ONCE() for accessing firmware tables that may appear
   misaligned in memory
 -----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEE+9lifEBpyUIVN1cpw08iOZLZjyQFAmPBg68ACgkQw08iOZLZ
 jyQs5Qv+PVg06BhEqN+vwNQy6vd4ezTxmDAy7yx751mo3HIw0qT0ohsCIpRydq0c
 +qlCXa+Uu/yr/IQplfDT9vY+MEwD9iuwJha8ltGRWM3++yEF4uQXowHDoEKsO84l
 5PaC37EfOvHmV6UdFdIF0OYDOcRvX2FsIbmUKRyvIav1e+QRLvUWWKKEmAh04c7G
 yNc0837kmoOpjKrYPc8j2n3dVUbhrFUW5eLIFmd8yrR+GRu6Ae5RH3J7iF7Nqtrq
 oReYYq3XpmYg8c00WV0NKVuB0DK7fhGY7jcbDfLmTrPwqVzLjxQGecxsQPYnqrJd
 mZywkm2fM8KIJy2LQDJOVOZaDAzaC2SkrpELHX/MnPK1UrP561AIv/sXK+3+UBEm
 b6m5dHbJgaifKP3kkbc9Cy4f9avLJOdjdXH5f5zPe7it54yHLsacEvjT6M2oiunx
 zIvTd/MXi24J+tzgxr08KM5wHXgLGh+fUM7BfZTvEVQmUjY8TnIPjsaAJhTS3jzV
 TN3/XAWi
 =4LbF
 -----END PGP SIGNATURE-----

Merge tag 'efi-fixes-for-v6.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi

Pull EFI fixes from Ard Biesheuvel:

 - avoid a potential crash on the efi_subsys_init() error path

 - use more appropriate error code for runtime services calls issued
   after a crash in the firmware occurred

 - avoid READ_ONCE() for accessing firmware tables that may appear
   misaligned in memory

* tag 'efi-fixes-for-v6.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
  efi: tpm: Avoid READ_ONCE() for accessing the event log
  efi: rt-wrapper: Add missing include
  efi: fix userspace infinite retry read efivars after EFI runtime services page fault
  efi: fix NULL-deref in init error path
This commit is contained in:
Linus Torvalds 2023-01-13 10:37:10 -06:00
commit 0bf913e07b
4 changed files with 10 additions and 5 deletions

View File

@ -4,6 +4,7 @@
*/ */
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/assembler.h>
SYM_FUNC_START(__efi_rt_asm_wrapper) SYM_FUNC_START(__efi_rt_asm_wrapper)
stp x29, x30, [sp, #-112]! stp x29, x30, [sp, #-112]!

View File

@ -394,8 +394,8 @@ static int __init efisubsys_init(void)
efi_kobj = kobject_create_and_add("efi", firmware_kobj); efi_kobj = kobject_create_and_add("efi", firmware_kobj);
if (!efi_kobj) { if (!efi_kobj) {
pr_err("efi: Firmware registration failed.\n"); pr_err("efi: Firmware registration failed.\n");
destroy_workqueue(efi_rts_wq); error = -ENOMEM;
return -ENOMEM; goto err_destroy_wq;
} }
if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE | if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE |
@ -443,7 +443,10 @@ static int __init efisubsys_init(void)
err_put: err_put:
kobject_put(efi_kobj); kobject_put(efi_kobj);
efi_kobj = NULL; efi_kobj = NULL;
destroy_workqueue(efi_rts_wq); err_destroy_wq:
if (efi_rts_wq)
destroy_workqueue(efi_rts_wq);
return error; return error;
} }

View File

@ -62,6 +62,7 @@ struct efi_runtime_work efi_rts_work;
\ \
if (!efi_enabled(EFI_RUNTIME_SERVICES)) { \ if (!efi_enabled(EFI_RUNTIME_SERVICES)) { \
pr_warn_once("EFI Runtime Services are disabled!\n"); \ pr_warn_once("EFI Runtime Services are disabled!\n"); \
efi_rts_work.status = EFI_DEVICE_ERROR; \
goto exit; \ goto exit; \
} \ } \
\ \

View File

@ -198,8 +198,8 @@ static __always_inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *ev
* The loop below will unmap these fields if the log is larger than * The loop below will unmap these fields if the log is larger than
* one page, so save them here for reference: * one page, so save them here for reference:
*/ */
count = READ_ONCE(event->count); count = event->count;
event_type = READ_ONCE(event->event_type); event_type = event->event_type;
/* Verify that it's the log header */ /* Verify that it's the log header */
if (event_header->pcr_idx != 0 || if (event_header->pcr_idx != 0 ||