[PATCH] x86/ioremap: Fix off-by-one in e820 check in memremap_should_map_decrypted()

From: Dmytro Maluka
Date: Fri Apr 18 2025 - 10:00:16 EST


The end address in e820__get_entry_type() is exclusive, not inclusive.

Note: untested, bug found by code inspection.

Signed-off-by: Dmytro Maluka <dmaluka@xxxxxxxxxxxx>
---
arch/x86/mm/ioremap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 331e101bf801..a44800a6196e 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -578,7 +578,7 @@ static bool memremap_should_map_decrypted(resource_size_t phys_addr,
}

/* Check if the address is outside kernel usable area */
- switch (e820__get_entry_type(phys_addr, phys_addr + size - 1)) {
+ switch (e820__get_entry_type(phys_addr, phys_addr + size)) {
case E820_TYPE_RESERVED:
case E820_TYPE_ACPI:
case E820_TYPE_NVS:
--
2.49.0.805.g082f7c87e0-goog