mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v1] platform/x86: wmi: Do not register driver with invalid GUID
@ 2023-07-15 21:24 Barnabás Pőcze
  2023-07-17  9:49 ` Andy Shevchenko
  2023-07-26  8:45 ` Hans de Goede
  0 siblings, 2 replies; 13+ messages in thread
From: Barnabás Pőcze @ 2023-07-15 21:24 UTC (permalink / raw)
  To: linux-kernel, platform-driver-x86, Mark Gross, Hans de Goede,
	Armin Wolf, Andy Shevchenko

Since a WMI driver's ID table contains strings it is relatively
easy to make mistakes. At the moment, there is no feedback
if any of the specified GUIDs are invalid (since
028e6e204ace1f080cfeacd72c50397eb8ae8883).

So check if the GUIDs in the driver's ID table are valid,
print all invalid ones, and refuse to register the driver
if any of the GUIDs are invalid.

Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
---
 drivers/platform/x86/wmi.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index a78ddd83cda0..bf0be40b418a 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -1513,6 +1513,19 @@ static int acpi_wmi_probe(struct platform_device *device)
 int __must_check __wmi_driver_register(struct wmi_driver *driver,
 				       struct module *owner)
 {
+	bool any_id_invalid = false;
+
+	for (const struct wmi_device_id *id = driver->id_table; *id->guid_string; id++) {
+		if (!uuid_is_valid(id->guid_string)) {
+			pr_err("driver '%s' has invalid GUID: %s",
+			       driver->driver.name, id->guid_string);
+			any_id_invalid = true;
+		}
+	}
+
+	if (any_id_invalid)
+		return -EINVAL;
+
 	driver->driver.owner = owner;
 	driver->driver.bus = &wmi_bus_type;
 
-- 
2.41.0



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-07-31 19:52 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-15 21:24 [RFC PATCH v1] platform/x86: wmi: Do not register driver with invalid GUID Barnabás Pőcze
2023-07-17  9:49 ` Andy Shevchenko
2023-07-17 11:23   ` Barnabás Pőcze
2023-07-17 11:31     ` Andy Shevchenko
2023-07-19 19:23       ` Barnabás Pőcze
2023-07-20  8:36         ` Andy Shevchenko
2023-07-20 10:42           ` Barnabás Pőcze
2023-07-21  9:17             ` Andy Shevchenko
2023-07-26  8:45 ` Hans de Goede
2023-07-27 22:54   ` Barnabás Pőcze
2023-07-28 10:02     ` Andy Shevchenko
2023-07-28 14:39       ` Barnabás Pőcze
2023-07-31 19:52         ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome