[PATCH] ACPI: PPTT: Fix table length check when parsing processor nodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Yicong Yang <yangyicong@xxxxxxxxxxxxx>

Below error is met on my board and QEMU VM on SMT or non-SMT machine:
  ACPI PPTT: PPTT table found, but unable to locate core 31 (31)

This is because the processor node is found by iterating the PPTT
table under condition (for both acpi_find_processor_node() and
acpi_pptt_leaf_node()):
  while (entry + proc_sz < table_end)
    [parse the processor node]

If the last processor node is happened to be the last node in the
PPTT table, above condition will always be false since
entry + proc_sz == table_end. Thus the last CPU is not parsed.
Fix the loop condition to resolve the issue.

This issue is exposed by [1] but the root cause is explained above.
Before [1] entry + proc_sz is always smaller than table_end.

[1] 7ab4f0e37a0f ("ACPI PPTT: Fix coding mistakes in a couple of sizeof() calls")
Fixes: 2bd00bcd73e5 ("ACPI/PPTT: Add Processor Properties Topology Table parsing")
Signed-off-by: Yicong Yang <yangyicong@xxxxxxxxxxxxx>
---
 drivers/acpi/pptt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/pptt.c b/drivers/acpi/pptt.c
index f73ce6e13065..4364da90902e 100644
--- a/drivers/acpi/pptt.c
+++ b/drivers/acpi/pptt.c
@@ -231,7 +231,7 @@ static int acpi_pptt_leaf_node(struct acpi_table_header *table_hdr,
 			     sizeof(struct acpi_table_pptt));
 	proc_sz = sizeof(struct acpi_pptt_processor);
 
-	while ((unsigned long)entry + proc_sz < table_end) {
+	while ((unsigned long)entry + proc_sz <= table_end) {
 		cpu_node = (struct acpi_pptt_processor *)entry;
 		if (entry->type == ACPI_PPTT_TYPE_PROCESSOR &&
 		    cpu_node->parent == node_entry)
@@ -273,7 +273,7 @@ static struct acpi_pptt_processor *acpi_find_processor_node(struct acpi_table_he
 	proc_sz = sizeof(struct acpi_pptt_processor);
 
 	/* find the processor structure associated with this cpuid */
-	while ((unsigned long)entry + proc_sz < table_end) {
+	while ((unsigned long)entry + proc_sz <= table_end) {
 		cpu_node = (struct acpi_pptt_processor *)entry;
 
 		if (entry->length == 0) {
-- 
2.24.0





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux