Skip to contentSkip to conversation

ACPI, APEI, EINJ: Refuse to inject into the zero page

PATCH Applied Tony Luck 2 participants 2 messages Apr 19, 2022 – Apr 22, 2022

Subsystems (2)
lore
Share & tools
lore

Tony Luck

author reviewer
#0 lore raw

PATCH 1/1 ACPI, APEI, EINJ: Refuse to inject into the zero page

Some validation tests dynamically inject errors into memory used by applications to check that the system can recover from a variety of poison consumption sceenarios.

But sometimes the virtual address picked by these tests is mapped to the zero page.

This causes additional unexpected machine checks as other processes that map the zero page also consume the poison.

Disallow injection to the zero page.

---
I picked -EADDRINUSE as a somewhat descriptive error code distinct fromm -EINVAL used elsewhere in EINJ, but I'm not strongly attached to it. Any other non -EINVAL value would be as good an indicator to the validation tests that they shouldn't inject to this address.

---
 drivers/acpi/apei/einj.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/apei/einj.c +3 -0
index 95cc2a9f3e05..d4326ec12d29 100644
@@ -549,6 +549,9 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
 	     !arch_is_platform_page(base_addr)))
 		return -EINVAL;
 
+	if (is_zero_pfn(base_addr >> PAGE_SHIFT))
+		return -EADDRINUSE;
+
 inject:
 	mutex_lock(&einj_mutex);
 	rc = __einj_error_inject(type, flags, param1, param2, param3, param4);
Signature · 1 line
2.35.1
maintainer Applied
#1 lore raw
Quoted 29 lines · Tony Luck

Some validation tests dynamically inject errors into memory used by applications to check that the system can recover from a variety of poison consumption sceenarios.

But sometimes the virtual address picked by these tests is mapped to the zero page.

This causes additional unexpected machine checks as other processes that map the zero page also consume the poison.

Disallow injection to the zero page.

---
I picked -EADDRINUSE as a somewhat descriptive error code distinct fromm -EINVAL used elsewhere in EINJ, but I'm not strongly attached to it. Any other non -EINVAL value would be as good an indicator to the validation tests that they shouldn't inject to this address.

---
 drivers/acpi/apei/einj.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/acpi/apei/einj.c +0 -0
index 95cc2a9f3e05..d4326ec12d29 100644

drivers/acpi/apei/einj.c static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,

Quoted 10 lines
drivers/acpi/apei/einj.c +3 -1
@@ -549,6 +549,9 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
             !arch_is_platform_page(base_addr)))
                return -EINVAL;
 
+       if (is_zero_pfn(base_addr >> PAGE_SHIFT))
+               return -EADDRINUSE;
+
 inject:
        mutex_lock(&einj_mutex);
        rc = __einj_error_inject(type, flags, param1, param2, param3, param4);
--

Applied as 5.19 material, thanks!