mei modalias files missing device name and newline

Daniel Lewart posted 1 patch 11 months ago
mei modalias files missing device name and newline
Posted by Daniel Lewart 11 months ago
mei modalias files are missing the following:
  * device name (cldev->name)
  * trailing newline

Original Debian bug:
  #1091997 - isenkram: Documentation for locating all modalias strings is incorrect
    https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1091997

I couldn't find any documentation that modalias files require a newline,
but all non-mei files do.

$ lspci -s 00:16.0 -v
00:16.0 Communication controller: Intel Corporation Alder Lake PCH HECI Controller (rev 01)
	DeviceName: Onboard - Other
	Subsystem: Micro-Star International Co., Ltd. [MSI] Alder Lake PCH HECI Controller
	Flags: bus master, fast devsel, latency 0, IRQ 138, IOMMU group 8
	Memory at 6001145000 (64-bit, non-prefetchable) [size=4K]
	Capabilities: <access denied>
	Kernel driver in use: mei_me
	Kernel modules: mei_me

$ find /sys/devices -name modalias -print0 | xargs -0 file | \
	sed -n 's/: *ASCII text, with no line terminators$//p' | \
	sort | xargs head

==> pci0000:00/0000:00:16.0/0000:00:16.0-082ee5a7-7c25-470a-9643-0c06f0466ea1/modalias <==
mei::082ee5a7-7c25-470a-9643-0c06f0466ea1:00:
==> pci0000:00/0000:00:16.0/0000:00:16.0-309dcde8-ccb1-4062-8f78-600115a34327/modalias <==
mei::309dcde8-ccb1-4062-8f78-600115a34327:01:
==> pci0000:00/0000:00:16.0/0000:00:16.0-3c4852d6-d47b-4f46-b05e-b5edc1aa440e/modalias <==
mei::3c4852d6-d47b-4f46-b05e-b5edc1aa440e:01:
==> pci0000:00/0000:00:16.0/0000:00:16.0-42b3ce2f-bd9f-485a-96ae-26406230b1ff/modalias <==
mei::42b3ce2f-bd9f-485a-96ae-26406230b1ff:01:
==> pci0000:00/0000:00:16.0/0000:00:16.0-55213584-9a29-4916-badf-0fb7ed682aeb/modalias <==
mei::55213584-9a29-4916-badf-0fb7ed682aeb:02:
==> pci0000:00/0000:00:16.0/0000:00:16.0-5565a099-7fe2-45c1-a22b-d7e9dfea9a2e/modalias <==
mei::5565a099-7fe2-45c1-a22b-d7e9dfea9a2e:01:
==> pci0000:00/0000:00:16.0/0000:00:16.0-6861ec7b-d07a-4673-856c-7f22b4d55769/modalias <==
mei::6861ec7b-d07a-4673-856c-7f22b4d55769:02:
==> pci0000:00/0000:00:16.0/0000:00:16.0-8c2f4425-77d6-4755-aca3-891fdbc66a58/modalias <==
mei::8c2f4425-77d6-4755-aca3-891fdbc66a58:01:
==> pci0000:00/0000:00:16.0/0000:00:16.0-8e6a6715-9abc-4043-88ef-9e39c6f63e0f/modalias <==
mei::8e6a6715-9abc-4043-88ef-9e39c6f63e0f:02:
==> pci0000:00/0000:00:16.0/0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04/modalias <==
mei::b638ab7e-94e2-4ea2-a552-d1c54b627f04:01:
==> pci0000:00/0000:00:16.0/0000:00:16.0-dba4d603-d7ed-4931-8823-17ad585705d5/modalias <==
mei::dba4d603-d7ed-4931-8823-17ad585705d5:01:
==> pci0000:00/0000:00:16.0/0000:00:16.0-dd17041c-09ea-4b17-a271-5b989867ec65/modalias <==
mei::dd17041c-09ea-4b17-a271-5b989867ec65:02:
==> pci0000:00/0000:00:16.0/0000:00:16.0-fbf6fcf1-96cf-4e2e-a6a6-1bab8cbe36b1/modalias <==
mei::fbf6fcf1-96cf-4e2e-a6a6-1bab8cbe36b1:01:

Below is a patch for Linux kernel 6.13 which provides the missing newline.
I don't know how to provide the missing device name.

This is my first Linux kernel bug report.
Please let me know what other information would be helpful.

Thank you!
Daniel Lewart
Urbana, Illinois
---
diff -ru a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
--- a/drivers/misc/mei/bus.c	2025-01-19 17:51:45.000000000 -0600
+++ b/drivers/misc/mei/bus.c	2025-01-20 00:00:00.000000000 -0600
@@ -1239,7 +1239,7 @@
 	const uuid_le *uuid = mei_me_cl_uuid(cldev->me_cl);
 	u8 version = mei_me_cl_ver(cldev->me_cl);
 
-	return scnprintf(buf, PAGE_SIZE, "mei:%s:%pUl:%02X:",
+	return scnprintf(buf, PAGE_SIZE, "mei:%s:%pUl:%02X:\n",
 			 cldev->name, uuid, version);
 }
 static DEVICE_ATTR_RO(modalias);
Re: mei modalias files missing device name and newline
Posted by Greg Kroah-Hartman 11 months ago
On Mon, Jan 20, 2025 at 05:30:04PM -0600, Daniel Lewart wrote:
> mei modalias files are missing the following:
>   * device name (cldev->name)

Where is the name required in the modalias file for mei?

>   * trailing newline

There's no "requirement" that modalias sysfs files have to have a
trailing newline, so why is this considered "missing"?

> Original Debian bug:
>   #1091997 - isenkram: Documentation for locating all modalias strings is incorrect
>     https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1091997
> 
> I couldn't find any documentation that modalias files require a newline,
> but all non-mei files do.

Not all, most.  If you want them all to, then we must sweep the whole
tree and fix them up.  And then deal with any fallout where that happens
to break things :)


> 
> $ lspci -s 00:16.0 -v
> 00:16.0 Communication controller: Intel Corporation Alder Lake PCH HECI Controller (rev 01)
> 	DeviceName: Onboard - Other
> 	Subsystem: Micro-Star International Co., Ltd. [MSI] Alder Lake PCH HECI Controller
> 	Flags: bus master, fast devsel, latency 0, IRQ 138, IOMMU group 8
> 	Memory at 6001145000 (64-bit, non-prefetchable) [size=4K]
> 	Capabilities: <access denied>
> 	Kernel driver in use: mei_me
> 	Kernel modules: mei_me
> 
> $ find /sys/devices -name modalias -print0 | xargs -0 file | \
> 	sed -n 's/: *ASCII text, with no line terminators$//p' | \
> 	sort | xargs head
> 
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-082ee5a7-7c25-470a-9643-0c06f0466ea1/modalias <==
> mei::082ee5a7-7c25-470a-9643-0c06f0466ea1:00:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-309dcde8-ccb1-4062-8f78-600115a34327/modalias <==
> mei::309dcde8-ccb1-4062-8f78-600115a34327:01:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-3c4852d6-d47b-4f46-b05e-b5edc1aa440e/modalias <==
> mei::3c4852d6-d47b-4f46-b05e-b5edc1aa440e:01:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-42b3ce2f-bd9f-485a-96ae-26406230b1ff/modalias <==
> mei::42b3ce2f-bd9f-485a-96ae-26406230b1ff:01:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-55213584-9a29-4916-badf-0fb7ed682aeb/modalias <==
> mei::55213584-9a29-4916-badf-0fb7ed682aeb:02:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-5565a099-7fe2-45c1-a22b-d7e9dfea9a2e/modalias <==
> mei::5565a099-7fe2-45c1-a22b-d7e9dfea9a2e:01:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-6861ec7b-d07a-4673-856c-7f22b4d55769/modalias <==
> mei::6861ec7b-d07a-4673-856c-7f22b4d55769:02:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-8c2f4425-77d6-4755-aca3-891fdbc66a58/modalias <==
> mei::8c2f4425-77d6-4755-aca3-891fdbc66a58:01:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-8e6a6715-9abc-4043-88ef-9e39c6f63e0f/modalias <==
> mei::8e6a6715-9abc-4043-88ef-9e39c6f63e0f:02:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-b638ab7e-94e2-4ea2-a552-d1c54b627f04/modalias <==
> mei::b638ab7e-94e2-4ea2-a552-d1c54b627f04:01:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-dba4d603-d7ed-4931-8823-17ad585705d5/modalias <==
> mei::dba4d603-d7ed-4931-8823-17ad585705d5:01:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-dd17041c-09ea-4b17-a271-5b989867ec65/modalias <==
> mei::dd17041c-09ea-4b17-a271-5b989867ec65:02:
> ==> pci0000:00/0000:00:16.0/0000:00:16.0-fbf6fcf1-96cf-4e2e-a6a6-1bab8cbe36b1/modalias <==
> mei::fbf6fcf1-96cf-4e2e-a6a6-1bab8cbe36b1:01:
> 
> Below is a patch for Linux kernel 6.13 which provides the missing newline.

Can you look at the documentation for how to submit patches and fix it
up to be in a format that we can apply it in?

> I don't know how to provide the missing device name.

Why do you feel it is missing and what requires it?  And wouldn't that
be breaking the user/kernel api if you add it?

thanks,

greg k-h
Re: mei modalias files missing device name and newline
Posted by Petter Reinholdtsen 11 months ago
[Greg Kroah-Hartman]
> There's no "requirement" that modalias sysfs files have to have a
> trailing newline, so why is this considered "missing"?

This all started when it was discovered that after more than 8 years,
this one liner no longer worked as well as it used to:

  cat $(find /sys/devices -name modalias) | sort -u

> Not all, most.  If you want them all to, then we must sweep the whole
> tree and fix them up.  And then deal with any fallout where that
> happens to break things :)

From my perspective, as the author of the isenkram package, it was the
introduction of entries without newlines that broke things, not the
other way around.

-- 
Happy hacking
Petter Reinholdtsen
Re: mei modalias files missing device name and newline
Posted by Greg Kroah-Hartman 11 months ago
On Tue, Jan 21, 2025 at 09:20:33AM +0100, Petter Reinholdtsen wrote:
> [Greg Kroah-Hartman]
> > There's no "requirement" that modalias sysfs files have to have a
> > trailing newline, so why is this considered "missing"?
> 
> This all started when it was discovered that after more than 8 years,
> this one liner no longer worked as well as it used to:
> 
>   cat $(find /sys/devices -name modalias) | sort -u
> 
> > Not all, most.  If you want them all to, then we must sweep the whole
> > tree and fix them up.  And then deal with any fallout where that
> > happens to break things :)
> 
> >From my perspective, as the author of the isenkram package, it was the
> introduction of entries without newlines that broke things, not the
> other way around.

So this file has always not had a newline on the end?

Anyway, I'm not objecting to the change, but it needs to be submitted in
a format we can apply it in, AND all other modalias files need to be
fixed up as well to provide a \n on the end.  The first one I found
turned out not to have that, so out of a "random sample" that was either
a lucky guess, or a sign that there is no consistancy here at all.

thanks,

greg k-h
Re: mei modalias files missing device name and newline
Posted by Petter Reinholdtsen 11 months ago
[Greg Kroah-Hartman]
> So this file has always not had a newline on the end?

No idea.  I do not believe I ever had access to hardware with a moi:
style modalias.  This issue was discovered and reported by Daniel.  The
pci, usb, scsi, dmi, wmi, platform, serio, cpu and acpi style modaliases
all have trailing newlines. :)

-- 
Happy hacking
Petter Reinholdtsen