Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'efi-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull EFI fixes from Ingo Molnar:
"Misc EFI fixes all across the map: CPER error report fixes, fixes to
TPM event log parsing, fix for a kexec hang, a Sparse fix and other
fixes"

* 'efi-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
efi/tpm: Fix sanity check of unsigned tbl_size being less than zero
efi/x86: Do not clean dummy variable in kexec path
efi: Make unexported efi_rci2_sysfs_init() static
efi/tpm: Only set 'efi_tpm_final_log_size' after successful event log parsing
efi/tpm: Don't traverse an event log with no events
efi/tpm: Don't access event->count when it isn't mapped
efivar/ssdt: Don't iterate over EFI vars if no SSDT override was specified
efi/cper: Fix endianness of PCIe class code

+36 -16
-3
arch/x86/platform/efi/efi.c
··· 917 917 918 918 if (efi_enabled(EFI_OLD_MEMMAP) && (__supported_pte_mask & _PAGE_NX)) 919 919 runtime_code_page_mkexec(); 920 - 921 - /* clean DUMMY object */ 922 - efi_delete_dummy_variable(); 923 920 #endif 924 921 } 925 922
+1 -1
drivers/firmware/efi/cper.c
··· 381 381 printk("%s""vendor_id: 0x%04x, device_id: 0x%04x\n", pfx, 382 382 pcie->device_id.vendor_id, pcie->device_id.device_id); 383 383 p = pcie->device_id.class_code; 384 - printk("%s""class_code: %02x%02x%02x\n", pfx, p[0], p[1], p[2]); 384 + printk("%s""class_code: %02x%02x%02x\n", pfx, p[2], p[1], p[0]); 385 385 } 386 386 if (pcie->validation_bits & CPER_PCIE_VALID_SERIAL_NUMBER) 387 387 printk("%s""serial number: 0x%04x, 0x%04x\n", pfx,
+3
drivers/firmware/efi/efi.c
··· 267 267 void *data; 268 268 int ret; 269 269 270 + if (!efivar_ssdt[0]) 271 + return 0; 272 + 270 273 ret = efivar_init(efivar_ssdt_iter, &entries, true, &entries); 271 274 272 275 list_for_each_entry_safe(entry, aux, &entries, list) {
+1 -1
drivers/firmware/efi/rci2-table.c
··· 76 76 return chksum; 77 77 } 78 78 79 - int __init efi_rci2_sysfs_init(void) 79 + static int __init efi_rci2_sysfs_init(void) 80 80 { 81 81 struct kobject *tables_kobj; 82 82 int ret = -ENOMEM;
+19 -7
drivers/firmware/efi/tpm.c
··· 40 40 { 41 41 struct linux_efi_tpm_eventlog *log_tbl; 42 42 struct efi_tcg2_final_events_table *final_tbl; 43 - unsigned int tbl_size; 43 + int tbl_size; 44 44 int ret = 0; 45 45 46 46 if (efi.tpm_log == EFI_INVALID_TABLE_ADDR) { ··· 75 75 goto out; 76 76 } 77 77 78 - tbl_size = tpm2_calc_event_log_size((void *)efi.tpm_final_log 79 - + sizeof(final_tbl->version) 80 - + sizeof(final_tbl->nr_events), 81 - final_tbl->nr_events, 82 - log_tbl->log); 78 + tbl_size = 0; 79 + if (final_tbl->nr_events != 0) { 80 + void *events = (void *)efi.tpm_final_log 81 + + sizeof(final_tbl->version) 82 + + sizeof(final_tbl->nr_events); 83 + 84 + tbl_size = tpm2_calc_event_log_size(events, 85 + final_tbl->nr_events, 86 + log_tbl->log); 87 + } 88 + 89 + if (tbl_size < 0) { 90 + pr_err(FW_BUG "Failed to parse event in TPM Final Events Log\n"); 91 + goto out_calc; 92 + } 93 + 83 94 memblock_reserve((unsigned long)final_tbl, 84 95 tbl_size + sizeof(*final_tbl)); 85 - early_memunmap(final_tbl, sizeof(*final_tbl)); 86 96 efi_tpm_final_log_size = tbl_size; 87 97 98 + out_calc: 99 + early_memunmap(final_tbl, sizeof(*final_tbl)); 88 100 out: 89 101 early_memunmap(log_tbl, sizeof(*log_tbl)); 90 102 return ret;
+12 -4
include/linux/tpm_eventlog.h
··· 152 152 * total. Once we've done this we know the offset of the data length field, 153 153 * and can calculate the total size of the event. 154 154 * 155 - * Return: size of the event on success, <0 on failure 155 + * Return: size of the event on success, 0 on failure 156 156 */ 157 157 158 158 static inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event, ··· 170 170 u16 halg; 171 171 int i; 172 172 int j; 173 + u32 count, event_type; 173 174 174 175 marker = event; 175 176 marker_start = marker; ··· 191 190 } 192 191 193 192 event = (struct tcg_pcr_event2_head *)mapping; 193 + /* 194 + * The loop below will unmap these fields if the log is larger than 195 + * one page, so save them here for reference: 196 + */ 197 + count = READ_ONCE(event->count); 198 + event_type = READ_ONCE(event->event_type); 194 199 195 200 efispecid = (struct tcg_efi_specid_event_head *)event_header->event; 196 201 197 202 /* Check if event is malformed. */ 198 - if (event->count > efispecid->num_algs) { 203 + if (count > efispecid->num_algs) { 199 204 size = 0; 200 205 goto out; 201 206 } 202 207 203 - for (i = 0; i < event->count; i++) { 208 + for (i = 0; i < count; i++) { 204 209 halg_size = sizeof(event->digests[i].alg_id); 205 210 206 211 /* Map the digest's algorithm identifier */ ··· 263 256 + event_field->event_size; 264 257 size = marker - marker_start; 265 258 266 - if ((event->event_type == 0) && (event_field->event_size == 0)) 259 + if (event_type == 0 && event_field->event_size == 0) 267 260 size = 0; 261 + 268 262 out: 269 263 if (do_mapping) 270 264 TPM_MEMUNMAP(mapping, mapping_size);