* [PATCH for-5.15.y+] kasan: disable kasan_non_canonical_hook() for HW tags
@ 2023-12-19 8:48 Amit Pundir
2023-12-20 16:07 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Amit Pundir @ 2023-12-19 8:48 UTC (permalink / raw)
To: Greg KH, Stable
Cc: Arnd Bergmann, Alexander Potapenko, Andrey Konovalov,
Andrey Ryabinin, Dmitry Vyukov, Haibo Li, Kees Cook,
Vincenzo Frascino, AngeloGioacchino Del Regno, Matthias Brugger,
Andrew Morton
From: Arnd Bergmann <arnd@arndb.de>
[ Upstream commit 17c17567fe510857b18fe01b7a88027600e76ac6 ]
On arm64, building with CONFIG_KASAN_HW_TAGS now causes a compile-time
error:
mm/kasan/report.c: In function 'kasan_non_canonical_hook':
mm/kasan/report.c:637:20: error: 'KASAN_SHADOW_OFFSET' undeclared (first use in this function)
637 | if (addr < KASAN_SHADOW_OFFSET)
| ^~~~~~~~~~~~~~~~~~~
mm/kasan/report.c:637:20: note: each undeclared identifier is reported only once for each function it appears in
mm/kasan/report.c:640:77: error: expected expression before ';' token
640 | orig_addr = (addr - KASAN_SHADOW_OFFSET) << KASAN_SHADOW_SCALE_SHIFT;
This was caused by removing the dependency on CONFIG_KASAN_INLINE that
used to prevent this from happening. Use the more specific dependency
on KASAN_SW_TAGS || KASAN_GENERIC to only ignore the function for hwasan
mode.
Link: https://lkml.kernel.org/r/20231016200925.984439-1-arnd@kernel.org
Fixes: 12ec6a919b0f ("kasan: print the original fault addr when access invalid shadow")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
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>
Cc: Haibo Li <haibo.li@mediatek.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
Needed on v6.1.y as well.
include/linux/kasan.h | 6 +++---
mm/kasan/report.c | 4 +++-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/include/linux/kasan.h b/include/linux/kasan.h
index 00cbe31c8748..056ca8e563aa 100644
--- a/include/linux/kasan.h
+++ b/include/linux/kasan.h
@@ -471,10 +471,10 @@ static inline void kasan_free_shadow(const struct vm_struct *vm) {}
#endif /* (CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS) && !CONFIG_KASAN_VMALLOC */
-#ifdef CONFIG_KASAN
+#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
void kasan_non_canonical_hook(unsigned long addr);
-#else /* CONFIG_KASAN */
+#else /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */
static inline void kasan_non_canonical_hook(unsigned long addr) { }
-#endif /* CONFIG_KASAN */
+#endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */
#endif /* LINUX_KASAN_H */
diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 1c929d964dde..8786cdfeaa91 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -457,8 +457,9 @@ bool kasan_report(unsigned long addr, size_t size, bool is_write,
return ret;
}
+#if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
/*
- * With CONFIG_KASAN, accesses to bogus pointers (outside the high
+ * With CONFIG_KASAN_INLINE, accesses to bogus pointers (outside the high
* canonical half of the address space) cause out-of-bounds shadow memory reads
* before the actual access. For addresses in the low canonical half of the
* address space, as well as most non-canonical addresses, that out-of-bounds
@@ -494,3 +495,4 @@ void kasan_non_canonical_hook(unsigned long addr)
pr_alert("KASAN: %s in range [0x%016lx-0x%016lx]\n", bug_type,
orig_addr, orig_addr + KASAN_GRANULE_SIZE - 1);
}
+#endif
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH for-5.15.y+] kasan: disable kasan_non_canonical_hook() for HW tags
2023-12-19 8:48 [PATCH for-5.15.y+] kasan: disable kasan_non_canonical_hook() for HW tags Amit Pundir
@ 2023-12-20 16:07 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2023-12-20 16:07 UTC (permalink / raw)
To: Amit Pundir
Cc: Stable, Arnd Bergmann, Alexander Potapenko, Andrey Konovalov,
Andrey Ryabinin, Dmitry Vyukov, Haibo Li, Kees Cook,
Vincenzo Frascino, AngeloGioacchino Del Regno, Matthias Brugger,
Andrew Morton
On Tue, Dec 19, 2023 at 02:18:07PM +0530, Amit Pundir wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> [ Upstream commit 17c17567fe510857b18fe01b7a88027600e76ac6 ]
>
> On arm64, building with CONFIG_KASAN_HW_TAGS now causes a compile-time
> error:
>
> mm/kasan/report.c: In function 'kasan_non_canonical_hook':
> mm/kasan/report.c:637:20: error: 'KASAN_SHADOW_OFFSET' undeclared (first use in this function)
> 637 | if (addr < KASAN_SHADOW_OFFSET)
> | ^~~~~~~~~~~~~~~~~~~
> mm/kasan/report.c:637:20: note: each undeclared identifier is reported only once for each function it appears in
> mm/kasan/report.c:640:77: error: expected expression before ';' token
> 640 | orig_addr = (addr - KASAN_SHADOW_OFFSET) << KASAN_SHADOW_SCALE_SHIFT;
>
> This was caused by removing the dependency on CONFIG_KASAN_INLINE that
> used to prevent this from happening. Use the more specific dependency
> on KASAN_SW_TAGS || KASAN_GENERIC to only ignore the function for hwasan
> mode.
>
> Link: https://lkml.kernel.org/r/20231016200925.984439-1-arnd@kernel.org
> Fixes: 12ec6a919b0f ("kasan: print the original fault addr when access invalid shadow")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 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>
> Cc: Haibo Li <haibo.li@mediatek.com>
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Cc: Matthias Brugger <matthias.bgg@gmail.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
> ---
> Needed on v6.1.y as well.
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-12-20 16:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 8:48 [PATCH for-5.15.y+] kasan: disable kasan_non_canonical_hook() for HW tags Amit Pundir
2023-12-20 16:07 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox