From 90fe6f8ff00a07641ca893d64f75ca22ce77cca2 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 13 Apr 2018 15:37:59 +0200 Subject: firmware: dmi_scan: Fix UUID length safety check The test which ensures that the DMI type 1 structure is long enough to hold the UUID is off by one. It would fail if the structure is exactly 24 bytes long, while that's sufficient to hold the UUID. I don't expect this bug to cause problem in practice because all implementations I have seen had length 8, 25 or 27 bytes, in line with the SMBIOS specifications. But let's fix it still. Signed-off-by: Jean Delvare Fixes: a814c3597a6b ("firmware: dmi_scan: Check DMI structure length") Reviewed-by: Mika Westerberg --- drivers/firmware/dmi_scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/firmware/dmi_scan.c') diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index e763e1484331..c3be8ef9243f 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -186,7 +186,7 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, char *s; int is_ff = 1, is_00 = 1, i; - if (dmi_ident[slot] || dm->length <= index + 16) + if (dmi_ident[slot] || dm->length < index + 16) return; d = (u8 *) dm + index; -- cgit v1.2.3 From de40614de997a388499f9a01d5eeb7cd8d3c34d1 Mon Sep 17 00:00:00 2001 From: Alex Hung Date: Fri, 13 Apr 2018 15:37:59 +0200 Subject: firmware: dmi_scan: Add DMI_OEM_STRING support to dmi_matches OEM strings are defined by each OEM and they contain customized and useful OEM information. Supporting it provides more flexible uses of the dmi_matches function. Signed-off-by: Alex Hung Signed-off-by: Jean Delvare --- drivers/firmware/dmi_scan.c | 10 +++++++++- include/linux/mod_devicetable.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/firmware/dmi_scan.c') diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index c3be8ef9243f..2c915a847158 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -775,7 +775,15 @@ static bool dmi_matches(const struct dmi_system_id *dmi) int s = dmi->matches[i].slot; if (s == DMI_NONE) break; - if (dmi_ident[s]) { + if (s == DMI_OEM_STRING) { + /* DMI_OEM_STRING must be exact match */ + const struct dmi_device *valid; + + valid = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, + dmi->matches[i].substr, NULL); + if (valid) + continue; + } else if (dmi_ident[s]) { if (dmi->matches[i].exact_match) { if (!strcmp(dmi_ident[s], dmi->matches[i].substr)) diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 48fb2b43c35a..7d361be2e24f 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -502,6 +502,7 @@ enum dmi_field { DMI_CHASSIS_SERIAL, DMI_CHASSIS_ASSET_TAG, DMI_STRING_MAX, + DMI_OEM_STRING, /* special case - will not be in dmi_ident */ }; struct dmi_strmatch { -- cgit v1.2.3 From 712ff25450bd01366301eef81c33e865d901e7b7 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 13 Apr 2018 15:37:59 +0200 Subject: firmware: dmi_scan: Use lowercase letters for UUID RFC 4122 asks for letters a-f in UUID to be lowercase. Follow this recommendation. Suggested by Paul Dagnelie at: https://savannah.nongnu.org/bugs/index.php?53569 Signed-off-by: Jean Delvare --- drivers/firmware/dmi_scan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/firmware/dmi_scan.c') diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 2c915a847158..16dd5ca212c6 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -210,9 +210,9 @@ static void __init dmi_save_uuid(const struct dmi_header *dm, int slot, * says that this is the defacto standard. */ if (dmi_ver >= 0x020600) - sprintf(s, "%pUL", d); + sprintf(s, "%pUl", d); else - sprintf(s, "%pUB", d); + sprintf(s, "%pUb", d); dmi_ident[slot] = s; } -- cgit v1.2.3