Skip to content

Commit 500b717

Browse files
committed
Merge branch 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging
Pull dmi updates from Jean Delvare. * 'dmi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging: firmware: dmi: Fortify entry point length checks
2 parents 8de1037 + 13a0ac8 commit 500b717

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/firmware/dmi_scan.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,8 +567,13 @@ static int __init dmi_present(const u8 *buf)
567567
{
568568
u32 smbios_ver;
569569

570+
/*
571+
* The size of this structure is 31 bytes, but we also accept value
572+
* 30 due to a mistake in SMBIOS specification version 2.1.
573+
*/
570574
if (memcmp(buf, "_SM_", 4) == 0 &&
571-
buf[5] < 32 && dmi_checksum(buf, buf[5])) {
575+
buf[5] >= 30 && buf[5] <= 32 &&
576+
dmi_checksum(buf, buf[5])) {
572577
smbios_ver = get_unaligned_be16(buf + 6);
573578
smbios_entry_point_size = buf[5];
574579
memcpy(smbios_entry_point, buf, smbios_entry_point_size);
@@ -629,7 +634,8 @@ static int __init dmi_present(const u8 *buf)
629634
static int __init dmi_smbios3_present(const u8 *buf)
630635
{
631636
if (memcmp(buf, "_SM3_", 5) == 0 &&
632-
buf[6] < 32 && dmi_checksum(buf, buf[6])) {
637+
buf[6] >= 24 && buf[6] <= 32 &&
638+
dmi_checksum(buf, buf[6])) {
633639
dmi_ver = get_unaligned_be24(buf + 7);
634640
dmi_num = 0; /* No longer specified */
635641
dmi_len = get_unaligned_le32(buf + 12);

0 commit comments

Comments
 (0)