Skip to contentSkip to conversation

platform/x86: peaq-wmi: Add DMI check before binding to the WMI interface

PATCH RESEND In review Hans de Goede 4 participants 7 messages Oct 5, 2017 – Oct 8, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 platform/x86: peaq-wmi: Add DMI check before binding to the WMI interface

Hi All,

This is a resend with Kai Heng Feng added to the Cc. Kai can you please test this patch. This patch replaces yours, as many devices seem to be affected so a whitelist is the better approach here.

Regards,

Hans

#1 lore raw

PATCH 1/1 platform/x86: peaq-wmi: Add DMI check before binding to the WMI interface

It seems that the WMI GUID used by the PEAQ 2-in-1 WMI hotkeys is not as unique as a GUID should be and is used on some other devices too.

This is causing spurious key-press reports on these other devices.

This commits adds a DMI check to the PEAQ 2-in-1 WMI hotkeys driver to ensure that it is actually running on a PEAQ 2-in-1, fixing the spurious key-presses on these other devices.

---
 drivers/platform/x86/peaq-wmi.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/platform/x86/peaq-wmi.c +18 -0
index bc98ef95514a..67fa3fa32011 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/dmi.h>
 #include <linux/input-polldev.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -64,8 +65,22 @@ static void peaq_wmi_poll(struct input_polled_dev *dev)
 	}
 }
 
+/* Some other devices (Shuttle XS35) use the same WMI GUID for other purposes */
+static const struct dmi_system_id peaq_dmi_table[] = {
+	{
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "PEAQ"),
+			DMI_MATCH(DMI_PRODUCT_NAME, "PEAQ PMM C1010 MD99187"),
+		},
+	},
+};
+
 static int __init peaq_wmi_init(void)
 {
+	/* WMI GUID is not unique, also check for a DMI match */
+	if (!dmi_check_system(peaq_dmi_table))
+		return -ENODEV;
+
 	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
 		return -ENODEV;
 
@@ -86,6 +101,9 @@ static int __init peaq_wmi_init(void)
 
 static void __exit peaq_wmi_exit(void)
 {
+	if (!dmi_check_system(peaq_dmi_table))
+		return;
+
 	if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
 		return;
 
Signature · 1 line
2.14.2
#2 lore raw
Quoted 8 lines · Hans de Goede

It seems that the WMI GUID used by the PEAQ 2-in-1 WMI hotkeys is not as unique as a GUID should be and is used on some other devices too.

This is causing spurious key-press reports on these other devices.

This commits adds a DMI check to the PEAQ 2-in-1 WMI hotkeys driver to ensure that it is actually running on a PEAQ 2-in-1, fixing the spurious key-presses on these other devices.

Thanks!

One comment though.

drivers/platform/x86/peaq-wmi.c static int __init peaq_wmi_init(void) · line 108

Quoted 7 lines

static void __exit peaq_wmi_exit(void)
{

drivers/platform/x86/peaq-wmi.c +3 -0
+       if (!dmi_check_system(peaq_dmi_table))
+               return;
+
        if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
                return;

I was thinking, after got kbuid bot complains on Kai's patch on sections mismatch, do we need these checks at all?
How would be possible to get a module loaded in the first place if system is not in whitelist?

If I'm right, please, drop the check and move table to __initconst.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 22 lines · Andy Shevchenko
Quoted 8 lines · Hans de Goede

It seems that the WMI GUID used by the PEAQ 2-in-1 WMI hotkeys is not as unique as a GUID should be and is used on some other devices too.

This is causing spurious key-press reports on these other devices.

This commits adds a DMI check to the PEAQ 2-in-1 WMI hotkeys driver to ensure that it is actually running on a PEAQ 2-in-1, fixing the spurious key-presses on these other devices.

Thanks!

One comment though.

drivers/platform/x86/peaq-wmi.c static int __init peaq_wmi_init(void) · line 108

Quoted 7 lines

static void __exit peaq_wmi_exit(void)
{

drivers/platform/x86/peaq-wmi.c +3 -0
+       if (!dmi_check_system(peaq_dmi_table))
+               return;
+
        if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
                return;
Quoted 5 lines

I was thinking, after got kbuid bot complains on Kai's patch on sections mismatch, do we need these checks at all?
How would be possible to get a module loaded in the first place if system is not in whitelist?

I was wondering this myself.

Signature · 2 lines
Darren Hart
VMware Open Source Technology Center
#4 lore raw
In reply to Hans de Goede
Quoted 5 lines · Hans de Goede

It seems that the WMI GUID used by the PEAQ 2-in-1 WMI hotkeys is not as unique as a GUID should be and is used on some other devices too.

This is causing spurious key-press reports on these other devices.

Quoted 7 lines

This commits adds a DMI check to the PEAQ 2-in-1 WMI hotkeys driver to ensure that it is actually running on a PEAQ 2-in-1, fixing the spurious key-presses on these other devices.

So, I have pushed to my review queue as is, though please consider my comments in perhaps a separate patch.
Thanks!

Quoted 53 lines
---
 drivers/platform/x86/peaq-wmi.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/platform/x86/peaq-wmi.c +18 -1
index bc98ef95514a..67fa3fa32011 100644
@@ -8,6 +8,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/dmi.h>
 #include <linux/input-polldev.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -64,8 +65,22 @@ static void peaq_wmi_poll(struct input_polled_dev *dev)
        }
 }
 
+/* Some other devices (Shuttle XS35) use the same WMI GUID for other purposes */
+static const struct dmi_system_id peaq_dmi_table[] = {
+       {
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "PEAQ"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "PEAQ PMM C1010 MD99187"),
+               },
+       },
+};
+
 static int __init peaq_wmi_init(void)
 {
+       /* WMI GUID is not unique, also check for a DMI match */
+       if (!dmi_check_system(peaq_dmi_table))
+               return -ENODEV;
+
        if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
                return -ENODEV;
 
@@ -86,6 +101,9 @@ static int __init peaq_wmi_init(void)
 
 static void __exit peaq_wmi_exit(void)
 {
+       if (!dmi_check_system(peaq_dmi_table))
+               return;
+
        if (!wmi_has_guid(PEAQ_DOLBY_BUTTON_GUID))
                return;
 
--

2.14.2

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
In reply to Hans de Goede

Hi Hans,

Quoted 5 lines · Hans de Goede

Hi All,

This is a resend with Kai Heng Feng added to the Cc. Kai can you please test this patch. This patch replaces yours, as many devices seem to be affected so a whitelist is the better approach here.

I'll let the affected user to test the patch.

Thanks!

Quoted 4 lines

Regards,

Hans

#6 lore raw

Hi,

Quoted 10 lines · Kai-Heng Feng

Hi Hans,

Quoted 5 lines · Hans de Goede

Hi All,

This is a resend with Kai Heng Feng added to the Cc. Kai can you please test this patch. This patch replaces yours, as many devices seem to be affected so a whitelist is the better approach here.

I'll let the affected user to test the patch.

The user reports the new patch works.

Thanks.

Quoted 7 lines

Thanks!

Quoted 4 lines

Regards,

Hans