]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
platform/x86: msi-wmi-platform: Only load on MSI devices
authorArmin Wolf <W_Armin@gmx.de>
Mon, 10 Nov 2025 11:12:52 +0000 (12:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Dec 2025 10:43:30 +0000 (11:43 +0100)
[ Upstream commit c93433fd4e2bbbe7caa67b53d808b4a084852ff3 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/x86/Kconfig
drivers/platform/x86/msi-wmi-platform.c

index 3875abba5a7903c2ee9420b9e969a8f30df9324d..902b50510d8d6facde17c902831c3d7b67d0ccc5 100644 (file)
@@ -726,6 +726,7 @@ config MSI_WMI
 config MSI_WMI_PLATFORM
        tristate "MSI WMI Platform features"
        depends on ACPI_WMI
+       depends on DMI
        depends on HWMON
        help
          Say Y here if you want to have support for WMI-based platform features
index dc5e9878cb68228f22aa2d78867ad934331c00a7..bd2687828a2e6fab15d02fe05dcdc305ec094ab4 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/debugfs.h>
 #include <linux/device.h>
 #include <linux/device/driver.h>
+#include <linux/dmi.h>
 #include <linux/errno.h>
 #include <linux/hwmon.h>
 #include <linux/kernel.h>
@@ -448,7 +449,45 @@ static struct wmi_driver msi_wmi_platform_driver = {
        .probe = msi_wmi_platform_probe,
        .no_singleton = true,
 };
-module_wmi_driver(msi_wmi_platform_driver);
+
+/*
+ * MSI reused the WMI GUID from the WMI-ACPI sample code provided by Microsoft,
+ * so other manufacturers might use it as well for their WMI-ACPI implementations.
+ */
+static const struct dmi_system_id msi_wmi_platform_whitelist[] __initconst = {
+       {
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "MICRO-STAR INT"),
+               },
+       },
+       {
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Micro-Star International"),
+               },
+       },
+       { }
+};
+
+static int __init msi_wmi_platform_module_init(void)
+{
+       if (!dmi_check_system(msi_wmi_platform_whitelist)) {
+               if (!force)
+                       return -ENODEV;
+
+               pr_warn("Ignoring DMI whitelist\n");
+       }
+
+       return wmi_driver_register(&msi_wmi_platform_driver);
+}
+
+static void __exit msi_wmi_platform_module_exit(void)
+{
+       wmi_driver_unregister(&msi_wmi_platform_driver);
+}
+
+module_init(msi_wmi_platform_module_init);
+module_exit(msi_wmi_platform_module_exit);
+
 
 MODULE_AUTHOR("Armin Wolf <W_Armin@gmx.de>");
 MODULE_DESCRIPTION("MSI WMI platform features");