kasan, arm64: untag address in _virt_addr_is_linear
authorAndrey Konovalov <[email protected]>
Fri, 28 Dec 2018 08:30:20 +0000 (00:30 -0800)
committerLinus Torvalds <[email protected]>
Fri, 28 Dec 2018 20:11:43 +0000 (12:11 -0800)
virt_addr_is_linear (which is used by virt_addr_valid) assumes that the
top byte of the address is 0xff, which isn't always the case with
tag-based KASAN.

This patch resets the tag in this macro.

Link: http://lkml.kernel.org/r/df73a37dd5ed37f4deaf77bc718e9f2e590e69b1.1544099024.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <[email protected]>
Reviewed-by: Andrey Ryabinin <[email protected]>
Reviewed-by: Dmitry Vyukov <[email protected]>
Acked-by: Will Deacon <[email protected]>
Cc: Christoph Lameter <[email protected]>
Cc: Mark Rutland <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
arch/arm64/include/asm/memory.h

index 25b46f88726c177d92ec7ab568d8a7eddc8d931f..907946cc767ceb065894f9cc16b83ca399bb1d4c 100644 (file)
@@ -329,9 +329,10 @@ static inline void *phys_to_virt(phys_addr_t x)
 #endif
 #endif
 
-#define _virt_addr_is_linear(kaddr)    (((u64)(kaddr)) >= PAGE_OFFSET)
-#define virt_addr_valid(kaddr)         (_virt_addr_is_linear(kaddr) && \
-                                        _virt_addr_valid(kaddr))
+#define _virt_addr_is_linear(kaddr)    \
+       (__tag_reset((u64)(kaddr)) >= PAGE_OFFSET)
+#define virt_addr_valid(kaddr)         \
+       (_virt_addr_is_linear(kaddr) && _virt_addr_valid(kaddr))
 
 #include <asm-generic/memory_model.h>