Skip to contentSkip to conversation

firmware: dmi_scan: Fix ordering of product_uuid

PATCH In review Jean Delvare 1 participant 2 messages Apr 17, 2015 Dmi/smbios support

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 firmware: dmi_scan: Fix ordering of product_uuid

In function dmi_present(), dmi_walk_early() calls dmi_table(), which calls dmi_decode(), which ultimately calls dmi_save_uuid(). This last function makes a decision based on the value of global variable dmi_ver. The problem is that this variable is set right _after_ dmi_walk_early() returns. So dmi_save_uuid() always sees dmi_ver == 0 regardless of the actual version implemented.

This causes /sys/class/dmi/id/product_uuid to always use the old ordering even on systems implementing DMI/SMBIOS 2.6 or later, which should use the new ordering.

This is broken since kernel v3.8 for legacy DMI implementations and since kernel v3.10 for SMBIOS 2 implementations. SMBIOS 3 implementations with the 64-bit entry point are not affected.

The first breakage does not matter much as in practice legacy DMI implementations are always for versions older than 2.6, which is when the UUID ordering changed. The second breakage is more problematic as it affects the vast majority of x86 systems manufactured since 2009.

Fixes 9f9c9cbb6057 ("drivers/firmware/dmi_scan.c: fetch dmi version from SMBIOS if it exists")
Fixes 79bae42d51a5 ("dmi_scan: refactor dmi_scan_machine(), {smbios,dmi}_present()")
Cc Ben Hutchings <[email protected]>
Cc Artem Savkov <[email protected]>
Cc Ivan Khoronzhuk <[email protected]>
Cc Matt Fleming <[email protected]>
Cc [email protected] [v3.10+]

---
Changes since v1:
* Rebased on torvalds/linux/master.

 drivers/firmware/dmi_scan.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/firmware/dmi_scan.c +4 -3
@@ -499,19 +499,20 @@ static int __init dmi_present(const u8 *
 	buf += 16;
 
 	if (memcmp(buf, "_DMI_", 5) == 0 && dmi_checksum(buf, 15)) {
+		if (smbios_ver)
+			dmi_ver = smbios_ver;
+		else
+			dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F);
 		dmi_num = get_unaligned_le16(buf + 12);
 		dmi_len = get_unaligned_le16(buf + 6);
 		dmi_base = get_unaligned_le32(buf + 8);
 
 		if (dmi_walk_early(dmi_decode) == 0) {
 			if (smbios_ver) {
-				dmi_ver = smbios_ver;
 				pr_info("SMBIOS %d.%d%s present.\n",
 				       dmi_ver >> 8, dmi_ver & 0xFF,
 				       (dmi_ver < 0x0300) ? "" : ".x");
 			} else {
-				dmi_ver = (buf[14] & 0xF0) << 4 |
-					   (buf[14] & 0x0F);
 				pr_info("Legacy DMI %d.%d present.\n",
 				       dmi_ver >> 8, dmi_ver & 0xFF);
 			}
Signature · 2 lines
Jean Delvare
SUSE L3 Support
#1 lore raw
Quoted 29 lines · Jean Delvare

In function dmi_present(), dmi_walk_early() calls dmi_table(), which calls dmi_decode(), which ultimately calls dmi_save_uuid(). This last function makes a decision based on the value of global variable dmi_ver. The problem is that this variable is set right _after_ dmi_walk_early() returns. So dmi_save_uuid() always sees dmi_ver == 0 regardless of the actual version implemented.

This causes /sys/class/dmi/id/product_uuid to always use the old ordering even on systems implementing DMI/SMBIOS 2.6 or later, which should use the new ordering.

This is broken since kernel v3.8 for legacy DMI implementations and since kernel v3.10 for SMBIOS 2 implementations. SMBIOS 3 implementations with the 64-bit entry point are not affected.

The first breakage does not matter much as in practice legacy DMI implementations are always for versions older than 2.6, which is when the UUID ordering changed. The second breakage is more problematic as it affects the vast majority of x86 systems manufactured since 2009.

Fixes 9f9c9cbb6057 ("drivers/firmware/dmi_scan.c: fetch dmi version from SMBIOS if it exists")
Fixes 79bae42d51a5 ("dmi_scan: refactor dmi_scan_machine(), {smbios,dmi}_present()")
Cc Ben Hutchings <[email protected]>
Cc Artem Savkov <[email protected]>
Cc Ivan Khoronzhuk <[email protected]>
Cc Matt Fleming <[email protected]>
Cc [email protected] [v3.10+]
Quoted 3 lines

---
Changes since v1:
* Rebased on torvalds/linux/master.

Bah, scratch that, I have come up with a different approach that will make backporting this fix easier. Sorry for the noise.

Signature · 2 lines
Jean Delvare
SUSE L3 Support