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

firmware: dmi_scan: Only honor end-of-table for 64-bit tables

A 32-bit entry point to a DMI table says how many structures the table
contains. The SMBIOS specification explicitly says that end-of-table
markers should be ignored if they are not actually at the end of the
DMI table. So only honor the end-of-table marker for tables accessed
through 64-bit entry points, as they do not specify a structure count.

Fixes: fc43026278 ("dmi: add support for SMBIOS 3.0 64-bit entry point")
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Matt Fleming <matt.fleming@intel.com>

+9 -4
+9 -4
drivers/firmware/dmi_scan.c
··· 89 89 90 90 /* 91 91 * Stop when we have seen all the items the table claimed to have 92 - * (SMBIOS < 3.0 only) OR we reach an end-of-table marker OR we run 93 - * off the end of the table (should never happen but sometimes does 94 - * on bogus implementations.) 92 + * (SMBIOS < 3.0 only) OR we reach an end-of-table marker (SMBIOS 93 + * >= 3.0 only) OR we run off the end of the table (should never 94 + * happen but sometimes does on bogus implementations.) 95 95 */ 96 96 while ((!dmi_num || i < dmi_num) && 97 97 (data - buf + sizeof(struct dmi_header)) <= dmi_len) { ··· 110 110 111 111 /* 112 112 * 7.45 End-of-Table (Type 127) [SMBIOS reference spec v3.0.0] 113 + * For tables behind a 64-bit entry point, we have no item 114 + * count and no exact table length, so stop on end-of-table 115 + * marker. For tables behind a 32-bit entry point, we have 116 + * seen OEM structures behind the end-of-table marker on 117 + * some systems, so don't trust it. 113 118 */ 114 - if (dm->type == DMI_ENTRY_END_OF_TABLE) 119 + if (!dmi_num && dm->type == DMI_ENTRY_END_OF_TABLE) 115 120 break; 116 121 117 122 data += 2;