Re: [PATCH v6 9/9] modpost: Handle malformed WMI GUID strings
From: Armin Wolf
Date: Wed Jun 10 2026 - 17:31:59 EST
Am 10.06.26 um 23:05 schrieb Pali Rohár:
On Wednesday 10 June 2026 22:34:53 Armin Wolf wrote:
Some WMI GUIDs found inside binary MOF files contain bothHello! Maybe different idea: Would not it be better to check in
uppercase and lowercase characters. Blindly copying such
GUIDs will prevent the associated WMI driver from loading
automatically because the WMI GUID found inside WMI device ids
always contains uppercase characters.
Avoid this issue by always converting WMI GUID strings to
uppercase. Also verify that the WMI GUID string actually looks
like a valid GUID.
do_wmi_entry() if all letters are really upper case?
Mixing lowercase and uppercase is a mess. And if somebody blindly copy
lowercase from MOF files to some kernel wmi driver, we can check for
this mistake in file2alias.c and throw an error.
guid_parse() handles mixed-case GUIDs just fine, so i prefer to accept them as well.
In the long term i am trying to move the whole WMI subsystem to guid_t or even class names
from the BMOF data.
Thanks,
Armin Wolf
Signed-off-by: Armin Wolf <W_Armin@xxxxxx>
---
.../wmi/driver-development-guide.rst | 2 +-
scripts/mod/file2alias.c | 28 ++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/Documentation/wmi/driver-development-guide.rst b/Documentation/wmi/driver-development-guide.rst
index 387f508d57ad..6290c448f5e7 100644
--- a/Documentation/wmi/driver-development-guide.rst
+++ b/Documentation/wmi/driver-development-guide.rst
@@ -54,7 +54,7 @@ to matching WMI devices using a struct wmi_device_id table:
::
static const struct wmi_device_id foo_id_table[] = {
- /* Only use uppercase letters! */
+ /* Using only uppercase letters is recommended */
{ "936DA01F-9ABD-4D9D-80C7-02AF85C822A8", NULL },
{ }
};
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 4e99393a35f1..20e542a888c4 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1253,6 +1253,8 @@ static void do_tee_entry(struct module *mod, void *symval)
static void do_wmi_entry(struct module *mod, void *symval)
{
DEF_FIELD_ADDR(symval, wmi_device_id, guid_string);
+ char result[sizeof(*guid_string)];
+ int i;
if (strlen(*guid_string) != UUID_STRING_LEN) {
warn("Invalid WMI device id 'wmi:%s' in '%s'\n",
@@ -1260,7 +1262,31 @@ static void do_wmi_entry(struct module *mod, void *symval)
return;
}
- module_alias_printf(mod, false, WMI_MODULE_PREFIX "%s", *guid_string);
+ for (i = 0; i < UUID_STRING_LEN; i++) {
+ char value = (*guid_string)[i];
+ bool valid = false;
+
+ if (i == 8 || i == 13 || i == 18 || i == 23) {
+ if (value == '-')
+ valid = true;
+ } else {
+ if (isxdigit(value))
+ valid = true;
+ }
+
+ if (!valid) {
+ warn("Invalid character %c inside WMI GUID string '%s' in '%s'\n",
+ value, *guid_string, mod->name);
+ return;
+ }
+
+ /* Some GUIDs from BMOF definitions contain lowercase characters */
+ result[i] = toupper(value);
+ }
+
+ result[i] = '\0';
+
+ module_alias_printf(mod, false, WMI_MODULE_PREFIX "%s", result);
}
/* Looks like: mhi:S */
--
2.39.5