Skip to content

Commit 86c8336

Browse files
xairywilldeacon
authored andcommitted
arm64: kasan: fix page_alloc tagging with DEBUG_VIRTUAL
When CONFIG_DEBUG_VIRTUAL is enabled, the default page_to_virt() macro implementation from include/linux/mm.h is used. That definition doesn't account for KASAN tags, which leads to no tags on page_alloc allocations. Provide an arm64-specific definition for page_to_virt() when CONFIG_DEBUG_VIRTUAL is enabled that takes care of KASAN tags. Fixes: 2813b9c ("kasan, mm, arm64: tag non slab memory allocated via pagealloc") Cc: <stable@vger.kernel.org> Signed-off-by: Andrey Konovalov <andreyknvl@google.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Link: https://lore.kernel.org/r/4b55b35202706223d3118230701c6a59749d9b72.1615219501.git.andreyknvl@google.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 093bbe2 commit 86c8336

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎arch/arm64/include/asm/memory.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ static inline void *phys_to_virt(phys_addr_t x)
328328
#define ARCH_PFN_OFFSET ((unsigned long)PHYS_PFN_OFFSET)
329329

330330
#if !defined(CONFIG_SPARSEMEM_VMEMMAP) || defined(CONFIG_DEBUG_VIRTUAL)
331+
#define page_to_virt(x) ({ \
332+
__typeof__(x) __page = x; \
333+
void *__addr = __va(page_to_phys(__page)); \
334+
(void *)__tag_set((const void *)__addr, page_kasan_tag(__page));\
335+
})
331336
#define virt_to_page(x) pfn_to_page(virt_to_pfn(x))
332337
#else
333338
#define page_to_virt(x) ({ \

0 commit comments

Comments
 (0)