Skip to content

Commit c93433f

Browse files
Wer-Wolfij-intel
authored andcommitted
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: 9c0beb6 ("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>
1 parent f945afe commit c93433f

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

drivers/platform/x86/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ config MSI_WMI
545545
config MSI_WMI_PLATFORM
546546
tristate "MSI WMI Platform features"
547547
depends on ACPI_WMI
548+
depends on DMI
548549
depends on HWMON
549550
help
550551
Say Y here if you want to have support for WMI-based platform features

drivers/platform/x86/msi-wmi-platform.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/debugfs.h>
1515
#include <linux/device.h>
1616
#include <linux/device/driver.h>
17+
#include <linux/dmi.h>
1718
#include <linux/errno.h>
1819
#include <linux/hwmon.h>
1920
#include <linux/kernel.h>
@@ -448,7 +449,45 @@ static struct wmi_driver msi_wmi_platform_driver = {
448449
.probe = msi_wmi_platform_probe,
449450
.no_singleton = true,
450451
};
451-
module_wmi_driver(msi_wmi_platform_driver);
452+
453+
/*
454+
* MSI reused the WMI GUID from the WMI-ACPI sample code provided by Microsoft,
455+
* so other manufacturers might use it as well for their WMI-ACPI implementations.
456+
*/
457+
static const struct dmi_system_id msi_wmi_platform_whitelist[] __initconst = {
458+
{
459+
.matches = {
460+
DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT"),
461+
},
462+
},
463+
{
464+
.matches = {
465+
DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
466+
},
467+
},
468+
{ }
469+
};
470+
471+
static int __init msi_wmi_platform_module_init(void)
472+
{
473+
if (!dmi_check_system(msi_wmi_platform_whitelist)) {
474+
if (!force)
475+
return -ENODEV;
476+
477+
pr_warn("Ignoring DMI whitelist\n");
478+
}
479+
480+
return wmi_driver_register(&msi_wmi_platform_driver);
481+
}
482+
483+
static void __exit msi_wmi_platform_module_exit(void)
484+
{
485+
wmi_driver_unregister(&msi_wmi_platform_driver);
486+
}
487+
488+
module_init(msi_wmi_platform_module_init);
489+
module_exit(msi_wmi_platform_module_exit);
490+
452491

453492
MODULE_AUTHOR("Armin Wolf <W_Armin@gmx.de>");
454493
MODULE_DESCRIPTION("MSI WMI platform features");

0 commit comments

Comments
 (0)