Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/x86: msi-wmi-platform: Only load on MSI devices

It turns out that the GUID used by the msi-wmi-platform driver
(ABBC0F60-8EA1-11D1-00A0-C90629100000) is not unique, but was instead
copied from the WIndows Driver Samples. This means that this driver
could load on devices from other manufacturers that also copied this
GUID, potentially causing hardware errors.

Prevent this by only loading on devices whitelisted via DMI. The DMI
matches where taken from the msi-ec driver.

Reported-by: Antheas Kapenekakis <lkml@antheas.dev>
Fixes: 9c0beb6b29e7 ("platform/x86: wmi: Add MSI WMI Platform driver")
Tested-by: Antheas Kapenekakis <lkml@antheas.dev>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://patch.msgid.link/20251110111253.16204-2-W_Armin@gmx.de
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Armin Wolf and committed by
Ilpo Järvinen
c93433fd f945afe0

+41 -1
+1
drivers/platform/x86/Kconfig
··· 545 545 config MSI_WMI_PLATFORM 546 546 tristate "MSI WMI Platform features" 547 547 depends on ACPI_WMI 548 + depends on DMI 548 549 depends on HWMON 549 550 help 550 551 Say Y here if you want to have support for WMI-based platform features
+40 -1
drivers/platform/x86/msi-wmi-platform.c
··· 14 14 #include <linux/debugfs.h> 15 15 #include <linux/device.h> 16 16 #include <linux/device/driver.h> 17 + #include <linux/dmi.h> 17 18 #include <linux/errno.h> 18 19 #include <linux/hwmon.h> 19 20 #include <linux/kernel.h> ··· 449 448 .probe = msi_wmi_platform_probe, 450 449 .no_singleton = true, 451 450 }; 452 - module_wmi_driver(msi_wmi_platform_driver); 451 + 452 + /* 453 + * MSI reused the WMI GUID from the WMI-ACPI sample code provided by Microsoft, 454 + * so other manufacturers might use it as well for their WMI-ACPI implementations. 455 + */ 456 + static const struct dmi_system_id msi_wmi_platform_whitelist[] __initconst = { 457 + { 458 + .matches = { 459 + DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT"), 460 + }, 461 + }, 462 + { 463 + .matches = { 464 + DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"), 465 + }, 466 + }, 467 + { } 468 + }; 469 + 470 + static int __init msi_wmi_platform_module_init(void) 471 + { 472 + if (!dmi_check_system(msi_wmi_platform_whitelist)) { 473 + if (!force) 474 + return -ENODEV; 475 + 476 + pr_warn("Ignoring DMI whitelist\n"); 477 + } 478 + 479 + return wmi_driver_register(&msi_wmi_platform_driver); 480 + } 481 + 482 + static void __exit msi_wmi_platform_module_exit(void) 483 + { 484 + wmi_driver_unregister(&msi_wmi_platform_driver); 485 + } 486 + 487 + module_init(msi_wmi_platform_module_init); 488 + module_exit(msi_wmi_platform_module_exit); 489 + 453 490 454 491 MODULE_AUTHOR("Armin Wolf <W_Armin@gmx.de>"); 455 492 MODULE_DESCRIPTION("MSI WMI platform features");