Skip to contentSkip to conversation

ACPI: Prevent acpi_table_entries from falling into a infinite loop

PATCH Superseded Malcolm Crossley 3 participants 3 messages Jun 3, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI: Prevent acpi_table_entries from falling into a infinite loop

If a buggy BIOS programs an ACPI table with entry length 0 then acpi_table_entries gets stuck in an infinite loop.

To aid debugging, report the error and exit the loop.

xen/drivers/acpi/tables.c +6 -0
diff -r 4708591d8aa8 -r af3b2493951c xen/drivers/acpi/tables.c
@@ -238,6 +238,12 @@ acpi_table_parse_entries(char *id,
 			if (handler(entry, table_end))
 				return -EINVAL;
 
+		if (entry->length == 0) {
+			printk(KERN_ERR PREFIX "[%4.4s:0x%02x] Invalid zero length\n",
+			       id, entry_id);
+			return -EINVAL;
+		}
+
 		entry = (struct acpi_subtable_header *)
 		    ((unsigned long)entry + entry->length);
 	}
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Malcolm Crossley

If a buggy BIOS programs an ACPI table with entry length 0 then acpi_table_entries gets stuck in an infinite loop.

To aid debugging, report the error and exit the loop.

Could you put a reference to the Linux commit in the message?

Quoted 22 lines

diff -r 4708591d8aa8 -r af3b2493951c xen/drivers/acpi/tables.c

xen/drivers/acpi/tables.c +6 -0
@@ -238,6 +238,12 @@ acpi_table_parse_entries(char *id,
 			if (handler(entry, table_end))
 				return -EINVAL;
 
+		if (entry->length == 0) {
+			printk(KERN_ERR PREFIX "[%4.4s:0x%02x] Invalid zero length\n",
+			       id, entry_id);
+			return -EINVAL;
+		}
+
 		entry = (struct acpi_subtable_header *)
 		    ((unsigned long)entry + entry->length);
 	}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 03.06.14 at 16:54, <[email protected]> wrote:
Quoted 6 lines · Malcolm Crossley

If a buggy BIOS programs an ACPI table with entry length 0 then acpi_table_entries gets stuck in an infinite loop.

To aid debugging, report the error and exit the loop.

Could you put a reference to the Linux commit in the message?

I was about to ask the same.

Quoted 11 lines

xen/drivers/acpi/tables.c acpi_table_parse_entries(char *id, · line 241

Quoted 9 lines

diff -r 4708591d8aa8 -r af3b2493951c xen/drivers/acpi/tables.c

xen/drivers/acpi/tables.c +1 -0
@@ -238,6 +238,12 @@ acpi_table_parse_entries(char *id,
 			if (handler(entry, table_end))
 				return -EINVAL;
 
+		if (entry->length == 0) {

Furthermore I think this should be done more robustly by checking <= sizeof(*entry), and before actually doing anything else with it.

Jan

Quoted 13 lines
Quoted 13 lines
xen/drivers/acpi/tables.c +5 -0
+			printk(KERN_ERR PREFIX "[%4.4s:0x%02x] Invalid zero length\n",
+			       id, entry_id);
+			return -EINVAL;
+		}
+
 		entry = (struct acpi_subtable_header *)
 		    ((unsigned long)entry + entry->length);
 	}

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel