Blob Blame History Raw
From: Tony Luck <tony.luck@intel.com>
Date: Tue, 19 Apr 2022 14:19:21 -0700
Subject: ACPI, APEI, EINJ: Refuse to inject into the zero page
Patch-mainline: v5.19-rc1
Git-commit: ab59c89396c007c360b1a4d762732d1621ff5456
References: jsc#PED-1408

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.

Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Lee, Chun-Yi <jlee@suse.com>
---
 drivers/acpi/apei/einj.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/acpi/apei/einj.c
+++ b/drivers/acpi/apei/einj.c
@@ -548,6 +548,9 @@ static int einj_error_inject(u32 type, u
 				!= REGION_INTERSECTS)))
 		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);