@@ -56,6 +56,12 @@ static inline void *kasan_mem_to_shadow(const void *addr)
+ KASAN_SHADOW_OFFSET;
}
+static inline const void *kasan_shadow_to_mem(const void *shadow_addr)
+{
+ return (void *)(((unsigned long)shadow_addr - KASAN_SHADOW_OFFSET)
+ << KASAN_SHADOW_SCALE_SHIFT);
+}
+
int kasan_add_zero_shadow(void *start, unsigned long size);
void kasan_remove_zero_shadow(void *start, unsigned long size);
@@ -213,12 +213,6 @@ struct kasan_free_meta *kasan_get_free_meta(struct kmem_cache *cache,
#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
-static inline const void *kasan_shadow_to_mem(const void *shadow_addr)
-{
- return (void *)(((unsigned long)shadow_addr - KASAN_SHADOW_OFFSET)
- << KASAN_SHADOW_SCALE_SHIFT);
-}
-
static inline bool addr_has_metadata(const void *addr)
{
return (addr >= kasan_shadow_to_mem((void *)KASAN_SHADOW_START));
Some arch code would like to convert a shadow address to a corresponding memory address, e.g. for better reporting when a fault is taken on a shadow access. We already provide architectures with kasan_mem_to_shadow() and all the underlying constants, so we may as well allow them to use kasan_shadow_to_mem() rather than having to open-code this. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Konovalov <andreyknvl@gmail.com> Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> --- include/linux/kasan.h | 6 ++++++ mm/kasan/kasan.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-)