Skip to contentSkip to conversation

dmi_scan: Fix missing check for _DMI_ signature in smbios_present()

PATCH Zhenzhong Duan 2 participants 2 messages Feb 17, 2013

lore
Share & tools
lore

Zhenzhong Duan

author Acked-by
#0 lore raw

----- [email protected] wrote:

Quoted 7 lines

Commit 9f9c9cbb6057 ('drivers/firmware/dmi_scan.c: fetch dmi version from SMBIOS if it exists') hoisted the check for "_DMI_" into dmi_scan_machine(), which means that we don't bother to check for "_DMI_" at offset 16 in an SMBIOS entry. smbios_present() may also call dmi_present() for an address where we found "_SM_", if it failed further validation.

Quoted 8 lines

Check for "_DMI_" in smbios_present() before calling dmi_present().

---
This has a memcmp() that wasn't in the previous version, so I've not included the Acked-by or Tested-by for that.

Yes, the further "_DMI_" check is needed.

Quoted 33 lines

Ben.

 drivers/firmware/dmi_scan.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/firmware/dmi_scan.c +0 -1
index 982f1f5..a86ccff 100644
@@ -442,7 +442,6 @@ static int __init dmi_present(const char __iomem
 *p)
 static int __init smbios_present(const char __iomem *p)
 {
 	u8 buf[32];
-	int offset = 0;
 
 	memcpy_fromio(buf, p, 32);
drivers/firmware/dmi_scan.c +2 -2
 	if ((buf[5] < 32) && dmi_checksum(buf, buf[5])) {
@@ -461,9 +460,9 @@ static int __init smbios_present(const char
 __iomem *p)
 			dmi_ver = 0x0206;
 			break;
 		}
-		offset = 16;
+		return memcmp(q + 16, "_DMI_", 5) || dmi_present(p + 16);
 	}
-	return dmi_present(buf + offset);
+	return 1;
 }
 

void __init dmi_scan_machine(void)

#1 lore raw
Quoted 52 lines · Zhenzhong Duan

----- [email protected] wrote???

Quoted 7 lines

Commit 9f9c9cbb6057 ('drivers/firmware/dmi_scan.c: fetch dmi version from SMBIOS if it exists') hoisted the check for "_DMI_" into dmi_scan_machine(), which means that we don't bother to check for "_DMI_" at offset 16 in an SMBIOS entry. smbios_present() may also call dmi_present() for an address where we found "_SM_", if it failed further validation.

Quoted 8 lines

Check for "_DMI_" in smbios_present() before calling dmi_present().

---
This has a memcmp() that wasn't in the previous version, so I've not included the Acked-by or Tested-by for that.

Yes, the further "_DMI_" check is needed.

Quoted 32 lines

Ben.

 drivers/firmware/dmi_scan.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/firmware/dmi_scan.c +0 -1
index 982f1f5..a86ccff 100644
@@ -442,7 +442,6 @@ static int __init dmi_present(const char __iomem
 *p)
 static int __init smbios_present(const char __iomem *p)
 {
 	u8 buf[32];
-	int offset = 0;
 
 	memcpy_fromio(buf, p, 32);
drivers/firmware/dmi_scan.c +2 -2
 	if ((buf[5] < 32) && dmi_checksum(buf, buf[5])) {
@@ -461,9 +460,9 @@ static int __init smbios_present(const char
 __iomem *p)
 			dmi_ver = 0x0206;
 			break;
 		}
-		offset = 16;
+		return memcmp(q + 16, "_DMI_", 5) || dmi_present(p + 16);
 	}
-	return dmi_present(buf + offset);
+	return 1;
 }
 
Quoted 1 line
Quoted 1 line

void __init dmi_scan_machine(void)

I'm a little confused, do you need me to test something? Tim McGrath