Skip to contentSkip to conversation

iommu/amd: bound early ACPI HID map entries

PATCH Superseded Pengpeng Hou 2 participants 2 messages Jul 4 – Jul 6

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd: bound early ACPI HID map entries

parse_ivrs_acpihid() appends command-line ACPI HID mappings to the fixed early_acpihid_map[] array, but unlike the neighbouring IOAPIC and HPET parsers it does not check early_acpihid_map_size before incrementing it and writing the next entry.

Reject additional ivrs_acpihid= entries once the fixed early map is full.

---
 drivers/iommu/amd/init.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/iommu/amd/init.c +5 -0
@@ -3888,6 +3888,11 @@
 		return 1;
 	}
 
+	if (early_acpihid_map_size == EARLY_MAP_SIZE) {
+		pr_err("Invalid command line: too many ivrs_acpihid entries\n");
+		return 1;
+	}
+
 	i = early_acpihid_map_size++;
 	memcpy(early_acpihid_map[i].hid, hid, strlen(hid));
 	memcpy(early_acpihid_map[i].uid, uid, strlen(uid));
#1 lore raw
Quoted 16 lines · Pengpeng Hou

parse_ivrs_acpihid() appends command-line ACPI HID mappings to the fixed early_acpihid_map[] array, but unlike the neighbouring IOAPIC and HPET parsers it does not check early_acpihid_map_size before incrementing it and writing the next entry.

Reject additional ivrs_acpihid= entries once the fixed early map is full.

---
 drivers/iommu/amd/init.c | 5 +++++
 1 file changed, 5 insertions(+)

drivers/iommu/amd/init.c line 3892

Quoted 5 lines
drivers/iommu/amd/init.c +2 -0
@@ -3888,6 +3888,11 @@
 		return 1;
 	}
 
+	if (early_acpihid_map_size == EARLY_MAP_SIZE) {
+		pr_err("Invalid command line: too many ivrs_acpihid entries\n");

Hi,
This is not invalid option, the entry may be valid but there is no room to add it. It should be something like

pr_err("Early IOAPIC map overflow - ignoring ivrs_ioapic%s\n", str);

and this check should be first thing under 'found' lable, before parsing hid and uid.

-Ankit

Quoted 7 lines
drivers/iommu/amd/init.c +3 -0
+		return 1;
+	}
+
 	i = early_acpihid_map_size++;
 	memcpy(early_acpihid_map[i].hid, hid, strlen(hid));
 	memcpy(early_acpihid_map[i].uid, uid, strlen(uid));