Skip to contentSkip to conversation

iommu/amd: bound the early ACPI HID map

PATCH Applied Pengpeng Hou 3 participants 3 messages Jul 20 – Jul 21

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iommu/amd: bound the early ACPI HID map

The ivrs_acpihid command-line parser appends entries to a fixed four-element early_acpihid_map array. Unlike the sibling IOAPIC and HPET parsers, it does not reject a fifth entry before incrementing the map size.

Check the capacity at the common found label before parsing the HID and UID or writing the entry.

Fixes ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter")

---
Changes since v1: https://lore.kernel.org/all/[email protected]/
- move the capacity check to the start of the found path
- describe the condition as a full map rather than an invalid option
- rebase onto v7.2-rc4

 drivers/iommu/amd/init.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/iommu/amd/init.c +6 -0
index e93bcb5eef70..e7d7b4cb9337 100644
@@ -3864,6 +3864,12 @@ static int __init parse_ivrs_acpihid(char *str)
 	return 1;
 
 found:
+	if (early_acpihid_map_size == EARLY_MAP_SIZE) {
+		pr_err("Early ACPI HID map overflow - ignoring ivrs_acpihid%s\n",
+		       str);
+		return 1;
+	}
+
 	p = acpiid;
 	hid = strsep(&p, ":");
 	uid = p;
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Pengpeng Hou

The ivrs_acpihid command-line parser appends entries to a fixed four-element early_acpihid_map array. Unlike the sibling IOAPIC and HPET parsers, it does not reject a fifth entry before incrementing the map size.

Check the capacity at the common found label before parsing the HID and UID or writing the entry.

Fixes ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter")
Quoted 27 lines

---
Changes since v1: https://lore.kernel.org/all/[email protected]/
- move the capacity check to the start of the found path
- describe the condition as a full map rather than an invalid option
- rebase onto v7.2-rc4

 drivers/iommu/amd/init.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/iommu/amd/init.c +6 -0
index e93bcb5eef70..e7d7b4cb9337 100644
@@ -3864,6 +3864,12 @@ static int __init parse_ivrs_acpihid(char *str)
 	return 1;
 
 found:
+	if (early_acpihid_map_size == EARLY_MAP_SIZE) {
+		pr_err("Early ACPI HID map overflow - ignoring ivrs_acpihid%s\n",
+		       str);
+		return 1;
+	}
+
 	p = acpiid;
 	hid = strsep(&p, ":");
 	uid = p;
maintainer Applied
#2 lore raw
In reply to Pengpeng Hou
Quoted 8 lines · Pengpeng Hou

The ivrs_acpihid command-line parser appends entries to a fixed four-element early_acpihid_map array. Unlike the sibling IOAPIC and HPET parsers, it does not reject a fifth entry before incrementing the map size.

Check the capacity at the common found label before parsing the HID and UID or writing the entry.

[...]

Applied to iommu (fixes), thanks!

[1/1] iommu/amd: bound the early ACPI HID map

      https://git.kernel.org/iommu/c/fb80117fddb5

Cheers,

Signature · 5 lines
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev