[PATCH] asm/sections: fix memory object end check
Alexander Gordeev
agordeev at linux.ibm.com
Mon Dec 20 23:06:24 PST 2021
Function memory_contains() checks whether a memory object is
entirely contained within a memory region. The condition that
checks the upper bound of the object against the upper bound
of the region is inclusive. That does not correspond to the
similar checks in memory_intersects() friend function, nor
to the actual regions memory_contains() is called against.
In particular, __init_end address assumed do not belong to
the init section itself. Similarly, on ARM __idmap_text_end
and __entry_text_end are affected.
Fixes: 979559362516 ("asm/sections: add helpers to check for section data")
Cc: Thierry Reding <treding at nvidia.com>
Cc: Arnd Bergmann <arnd at arndb.de>
Cc: Russell King <linux at armlinux.org.uk>
Cc: linux-arm-kernel at lists.infradead.org
Signed-off-by: Alexander Gordeev <agordeev at linux.ibm.com>
---
include/asm-generic/sections.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
index 1dfadb2e878d..23f325cd2c66 100644
--- a/include/asm-generic/sections.h
+++ b/include/asm-generic/sections.h
@@ -78,7 +78,7 @@ extern __visible const void __nosave_begin, __nosave_end;
static inline bool memory_contains(void *begin, void *end, void *virt,
size_t size)
{
- return virt >= begin && virt + size <= end;
+ return virt >= begin && virt + size < end;
}
/**
--
2.32.0
More information about the linux-arm-kernel
mailing list