diff options
author | Ingo Molnar <mingo@kernel.org> | 2015-03-31 04:45:47 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-03-31 04:45:47 -0400 |
commit | 36cbf25dc79cc33d623889cafba2c672b161c1ad (patch) | |
tree | 6a48140e49a19ee33d35b8e1d8bf13253aa92442 /drivers/firmware | |
parent | ca68a525ff6b62e77dc8a8c3020a63321bfb864f (diff) | |
parent | bfbaafae8519d82d10da6abe75f5766dd5b20475 (diff) |
Merge tag 'efi-urgent' of git://git.kernel.org/pub/scm/linux/kernel/git/mfleming/efi into x86/urgent
Pull EFI fix from Matt Fleming:
- Fix integer overflow issue in the DMI SMBIOS 3.0 code when
calculating the number of DMI table entries. (Jean Delvare)
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/dmi_scan.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 69fac068669f..2eebd28b4c40 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c | |||
@@ -86,10 +86,13 @@ static void dmi_table(u8 *buf, u32 len, int num, | |||
86 | int i = 0; | 86 | int i = 0; |
87 | 87 | ||
88 | /* | 88 | /* |
89 | * Stop when we see all the items the table claimed to have | 89 | * Stop when we have seen all the items the table claimed to have |
90 | * OR we run off the end of the table (also happens) | 90 | * (SMBIOS < 3.0 only) OR we reach an end-of-table marker OR we run |
91 | * off the end of the table (should never happen but sometimes does | ||
92 | * on bogus implementations.) | ||
91 | */ | 93 | */ |
92 | while ((i < num) && (data - buf + sizeof(struct dmi_header)) <= len) { | 94 | while ((!num || i < num) && |
95 | (data - buf + sizeof(struct dmi_header)) <= len) { | ||
93 | const struct dmi_header *dm = (const struct dmi_header *)data; | 96 | const struct dmi_header *dm = (const struct dmi_header *)data; |
94 | 97 | ||
95 | /* | 98 | /* |
@@ -529,21 +532,10 @@ static int __init dmi_smbios3_present(const u8 *buf) | |||
529 | if (memcmp(buf, "_SM3_", 5) == 0 && | 532 | if (memcmp(buf, "_SM3_", 5) == 0 && |
530 | buf[6] < 32 && dmi_checksum(buf, buf[6])) { | 533 | buf[6] < 32 && dmi_checksum(buf, buf[6])) { |
531 | dmi_ver = get_unaligned_be16(buf + 7); | 534 | dmi_ver = get_unaligned_be16(buf + 7); |
535 | dmi_num = 0; /* No longer specified */ | ||
532 | dmi_len = get_unaligned_le32(buf + 12); | 536 | dmi_len = get_unaligned_le32(buf + 12); |
533 | dmi_base = get_unaligned_le64(buf + 16); | 537 | dmi_base = get_unaligned_le64(buf + 16); |
534 | 538 | ||
535 | /* | ||
536 | * The 64-bit SMBIOS 3.0 entry point no longer has a field | ||
537 | * containing the number of structures present in the table. | ||
538 | * Instead, it defines the table size as a maximum size, and | ||
539 | * relies on the end-of-table structure type (#127) to be used | ||
540 | * to signal the end of the table. | ||
541 | * So let's define dmi_num as an upper bound as well: each | ||
542 | * structure has a 4 byte header, so dmi_len / 4 is an upper | ||
543 | * bound for the number of structures in the table. | ||
544 | */ | ||
545 | dmi_num = dmi_len / 4; | ||
546 | |||
547 | if (dmi_walk_early(dmi_decode) == 0) { | 539 | if (dmi_walk_early(dmi_decode) == 0) { |
548 | pr_info("SMBIOS %d.%d present.\n", | 540 | pr_info("SMBIOS %d.%d present.\n", |
549 | dmi_ver >> 8, dmi_ver & 0xFF); | 541 | dmi_ver >> 8, dmi_ver & 0xFF); |