Thread (4 messages) flat view 4 messages, 1 author, 2019-02-19
STALE2728d REVIEWED: 6 (5M)

2 review trailers (1 from subsystem maintainers).

[RFC WIP PATCH 1/3] kasan: do not open-code addr_has_shadow

From: Christophe Leroy <hidden>
Date: 2019-02-19 17:37:33
Subsystem: kasan, memory management, the rest · Maintainers: Andrey Ryabinin, Andrew Morton, Linus Torvalds

From: Daniel Axtens <redacted>

We have a couple of places checking for the existence of a shadow
mapping for an address by open-coding the inverse of the check in
addr_has_shadow.

Replace the open-coded versions with the helper. This will be
needed in future to allow architectures to override the layout
of the shadow mapping.

Signed-off-by: Daniel Axtens <redacted>
Reviewed-by: Andrew Donnellan <redacted>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
---
 mm/kasan/generic.c | 3 +--
 mm/kasan/tags.c    | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
index 696c2f5b902b..08cbc7ed8953 100644
--- a/mm/kasan/generic.c
+++ b/mm/kasan/generic.c
@@ -176,8 +176,7 @@ static __always_inline void check_memory_region_inline(unsigned long addr,
 	if (unlikely(size == 0))
 		return;
 
-	if (unlikely((void *)addr <
-		kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) {
+	if (unlikely(!addr_has_shadow((void *)addr))) {
 		kasan_report(addr, size, write, ret_ip);
 		return;
 	}
diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c
index 0777649e07c4..bc759f8f1c67 100644
--- a/mm/kasan/tags.c
+++ b/mm/kasan/tags.c
@@ -109,8 +109,7 @@ void check_memory_region(unsigned long addr, size_t size, bool write,
 		return;
 
 	untagged_addr = reset_tag((const void *)addr);
-	if (unlikely(untagged_addr <
-			kasan_shadow_to_mem((void *)KASAN_SHADOW_START))) {
+	if (unlikely(!addr_has_shadow(untagged_addr))) {
 		kasan_report(addr, size, write, ret_ip);
 		return;
 	}
-- 
2.13.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help