mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [STABLE PATCH .26 .27] ACPI: avoid empty file name in sysfs
@ 2008-11-13  5:17 Len Brown
  2008-11-15 17:17 ` Pavel Machek
  0 siblings, 1 reply; 3+ messages in thread
From: Len Brown @ 2008-11-13  5:17 UTC (permalink / raw)
  To: stable; +Cc: linux-acpi, Linux Kernel Mailing List

From: Peter Gruber <nokos@gmx.net>

upstream 4feba70a2c1a1a0c96909f657f48b2e11e682370

Since commit bc45b1d39a925b56796bebf8a397a0491489d85c acpi tables are
allowed to have an empty signature and /sys/firmware/acpi/tables uses the
signature as filename.  Applications using naive recursion through /sys
loop forever.  A possible solution would be: (replacing the zero length
filename with the string "NULL")

http://bugzilla.kernel.org/show_bug.cgi?id=11539

Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/acpi/system.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 1d74171..62ec75e 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -78,9 +78,15 @@ static ssize_t acpi_table_show(struct kobject *kobj,
 	    container_of(bin_attr, struct acpi_table_attr, attr);
 	struct acpi_table_header *table_header = NULL;
 	acpi_status status;
+	char name[ACPI_NAME_SIZE];
+
+	if (strncmp(table_attr->name, "NULL", 4))
+		memcpy(name, table_attr->name, ACPI_NAME_SIZE);
+	else
+		memcpy(name, "\0\0\0\0", 4);
 
 	status =
-	    acpi_get_table(table_attr->name, table_attr->instance,
+	    acpi_get_table(name, table_attr->instance,
 			   &table_header);
 	if (ACPI_FAILURE(status))
 		return -ENODEV;
@@ -95,21 +101,24 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
 	struct acpi_table_header *header = NULL;
 	struct acpi_table_attr *attr = NULL;
 
-	memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE);
+	if (table_header->signature[0] != '\0')
+		memcpy(table_attr->name, table_header->signature,
+			ACPI_NAME_SIZE);
+	else
+		memcpy(table_attr->name, "NULL", 4);
 
 	list_for_each_entry(attr, &acpi_table_attr_list, node) {
-		if (!memcmp(table_header->signature, attr->name,
-			    ACPI_NAME_SIZE))
+		if (!memcmp(table_attr->name, attr->name, ACPI_NAME_SIZE))
 			if (table_attr->instance < attr->instance)
 				table_attr->instance = attr->instance;
 	}
 	table_attr->instance++;
 
 	if (table_attr->instance > 1 || (table_attr->instance == 1 &&
-					 !acpi_get_table(table_header->
-							 signature, 2,
-							 &header)))
-		sprintf(table_attr->name + 4, "%d", table_attr->instance);
+					!acpi_get_table
+					(table_header->signature, 2, &header)))
+		sprintf(table_attr->name + ACPI_NAME_SIZE, "%d",
+			table_attr->instance);
 
 	table_attr->attr.size = 0;
 	table_attr->attr.read = acpi_table_show;
-- 
1.6.0.4.617.g2baf


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

* Re: [STABLE PATCH .26 .27] ACPI: avoid empty file name in sysfs
  2008-11-13  5:17 [STABLE PATCH .26 .27] ACPI: avoid empty file name in sysfs Len Brown
@ 2008-11-15 17:17 ` Pavel Machek
  2008-11-17  1:40   ` Zhang Rui
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Machek @ 2008-11-15 17:17 UTC (permalink / raw)
  To: Len Brown; +Cc: stable, linux-acpi, Linux Kernel Mailing List

Hi!

> upstream 4feba70a2c1a1a0c96909f657f48b2e11e682370
> 
> Since commit bc45b1d39a925b56796bebf8a397a0491489d85c acpi tables are
> allowed to have an empty signature and /sys/firmware/acpi/tables uses the
> signature as filename.  Applications using naive recursion through /sys
> loop forever.  A possible solution would be: (replacing the zero length
> filename with the string "NULL")

What about using some string that is not a valid table name? Shorter
than 4 characters? AFAICT,
'NULL' table could be added to acpi in future...?

What if *two* tales have empty signature?
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [STABLE PATCH .26 .27] ACPI: avoid empty file name in sysfs
  2008-11-15 17:17 ` Pavel Machek
@ 2008-11-17  1:40   ` Zhang Rui
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang Rui @ 2008-11-17  1:40 UTC (permalink / raw)
  To: Pavel Machek; +Cc: Len Brown, stable, linux-acpi, Linux Kernel Mailing List

On Sun, 2008-11-16 at 01:17 +0800, Pavel Machek wrote:
> Hi!
> 
> > upstream 4feba70a2c1a1a0c96909f657f48b2e11e682370
> > 
> > Since commit bc45b1d39a925b56796bebf8a397a0491489d85c acpi tables are
> > allowed to have an empty signature and /sys/firmware/acpi/tables uses the
> > signature as filename.  Applications using naive recursion through /sys
> > loop forever.  A possible solution would be: (replacing the zero length
> > filename with the string "NULL")
> 
> What about using some string that is not a valid table name? Shorter
> than 4 characters? AFAICT,
> 'NULL' table could be added to acpi in future...?
> 
> What if *two* tales have empty signature?
there are "NULL1" and "NULL2" in this case.

thanks,
rui


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

end of thread, other threads:[~2008-11-17  1:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-13  5:17 [STABLE PATCH .26 .27] ACPI: avoid empty file name in sysfs Len Brown
2008-11-15 17:17 ` Pavel Machek
2008-11-17  1:40   ` Zhang Rui

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

all inboxes | Powered by JetHome®