* [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC
@ 2024-10-21 12:00 Marco Elver
2024-10-21 12:00 ` [PATCH 2/2] Revert "kasan: Disable Software Tag-Based KASAN with GCC" Marco Elver
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Marco Elver @ 2024-10-21 12:00 UTC (permalink / raw)
To: elver, Will Deacon
Cc: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
Dmitry Vyukov, Vincenzo Frascino, Mark Rutland, linux-kernel,
kasan-dev, llvm, syzbot+908886656a02769af987, Andrew Pinski
Per [1], -fsanitize=kernel-hwaddress with GCC currently does not disable
instrumentation in functions with __attribute__((no_sanitize_address)).
However, __attribute__((no_sanitize("hwaddress"))) does correctly
disable instrumentation. Use it instead.
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117196 [1]
Link: https://lore.kernel.org/r/000000000000f362e80620e27859@google.com
Link: https://lore.kernel.org/r/ZvFGwKfoC4yVjN_X@J2N7QTR9R3
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218854
Reported-by: syzbot+908886656a02769af987@syzkaller.appspotmail.com
Tested-by: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrew Pinski <pinskia@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Marco Elver <elver@google.com>
---
include/linux/compiler-gcc.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index f805adaa316e..cd6f9aae311f 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -80,7 +80,11 @@
#define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))
#endif
+#ifdef __SANITIZE_HWADDRESS__
+#define __no_sanitize_address __attribute__((__no_sanitize__("hwaddress")))
+#else
#define __no_sanitize_address __attribute__((__no_sanitize_address__))
+#endif
#if defined(__SANITIZE_THREAD__)
#define __no_sanitize_thread __attribute__((__no_sanitize_thread__))
--
2.47.0.rc1.288.g06298d1525-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] Revert "kasan: Disable Software Tag-Based KASAN with GCC"
2024-10-21 12:00 [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC Marco Elver
@ 2024-10-21 12:00 ` Marco Elver
2024-10-21 17:13 ` Andrey Konovalov
2024-10-21 17:12 ` [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC Andrey Konovalov
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Marco Elver @ 2024-10-21 12:00 UTC (permalink / raw)
To: elver, Will Deacon
Cc: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
Dmitry Vyukov, Vincenzo Frascino, Mark Rutland, linux-kernel,
kasan-dev, llvm, Andrew Pinski
This reverts commit 7aed6a2c51ffc97a126e0ea0c270fab7af97ae18.
Now that __no_sanitize_address attribute is fixed for KASAN_SW_TAGS with
GCC, allow re-enabling KASAN_SW_TAGS with GCC.
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrew Pinski <pinskia@gmail.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Marco Elver <elver@google.com>
---
lib/Kconfig.kasan | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
index 233ab2096924..98016e137b7f 100644
--- a/lib/Kconfig.kasan
+++ b/lib/Kconfig.kasan
@@ -22,11 +22,8 @@ config ARCH_DISABLE_KASAN_INLINE
config CC_HAS_KASAN_GENERIC
def_bool $(cc-option, -fsanitize=kernel-address)
-# GCC appears to ignore no_sanitize_address when -fsanitize=kernel-hwaddress
-# is passed. See https://bugzilla.kernel.org/show_bug.cgi?id=218854 (and
-# the linked LKML thread) for more details.
config CC_HAS_KASAN_SW_TAGS
- def_bool !CC_IS_GCC && $(cc-option, -fsanitize=kernel-hwaddress)
+ def_bool $(cc-option, -fsanitize=kernel-hwaddress)
# This option is only required for software KASAN modes.
# Old GCC versions do not have proper support for no_sanitize_address.
@@ -101,7 +98,7 @@ config KASAN_SW_TAGS
help
Enables Software Tag-Based KASAN.
- Requires Clang.
+ Requires GCC 11+ or Clang.
Supported only on arm64 CPUs and relies on Top Byte Ignore.
--
2.47.0.rc1.288.g06298d1525-goog
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC
2024-10-21 12:00 [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC Marco Elver
2024-10-21 12:00 ` [PATCH 2/2] Revert "kasan: Disable Software Tag-Based KASAN with GCC" Marco Elver
@ 2024-10-21 17:12 ` Andrey Konovalov
2024-10-21 17:20 ` Will Deacon
2024-10-23 16:21 ` Will Deacon
3 siblings, 0 replies; 9+ messages in thread
From: Andrey Konovalov @ 2024-10-21 17:12 UTC (permalink / raw)
To: Marco Elver
Cc: Will Deacon, Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Vincenzo Frascino, Mark Rutland, linux-kernel, kasan-dev, llvm,
syzbot+908886656a02769af987, Andrew Pinski
On Mon, Oct 21, 2024 at 2:00 PM Marco Elver <elver@google.com> wrote:
>
> Per [1], -fsanitize=kernel-hwaddress with GCC currently does not disable
> instrumentation in functions with __attribute__((no_sanitize_address)).
>
> However, __attribute__((no_sanitize("hwaddress"))) does correctly
> disable instrumentation. Use it instead.
>
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117196 [1]
> Link: https://lore.kernel.org/r/000000000000f362e80620e27859@google.com
> Link: https://lore.kernel.org/r/ZvFGwKfoC4yVjN_X@J2N7QTR9R3
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218854
> Reported-by: syzbot+908886656a02769af987@syzkaller.appspotmail.com
> Tested-by: Andrey Konovalov <andreyknvl@gmail.com>
> Cc: Andrew Pinski <pinskia@gmail.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Signed-off-by: Marco Elver <elver@google.com>
> ---
> include/linux/compiler-gcc.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index f805adaa316e..cd6f9aae311f 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -80,7 +80,11 @@
> #define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))
> #endif
>
> +#ifdef __SANITIZE_HWADDRESS__
> +#define __no_sanitize_address __attribute__((__no_sanitize__("hwaddress")))
> +#else
> #define __no_sanitize_address __attribute__((__no_sanitize_address__))
> +#endif
>
> #if defined(__SANITIZE_THREAD__)
> #define __no_sanitize_thread __attribute__((__no_sanitize_thread__))
> --
> 2.47.0.rc1.288.g06298d1525-goog
>
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
Thank you!
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Revert "kasan: Disable Software Tag-Based KASAN with GCC"
2024-10-21 12:00 ` [PATCH 2/2] Revert "kasan: Disable Software Tag-Based KASAN with GCC" Marco Elver
@ 2024-10-21 17:13 ` Andrey Konovalov
0 siblings, 0 replies; 9+ messages in thread
From: Andrey Konovalov @ 2024-10-21 17:13 UTC (permalink / raw)
To: Marco Elver
Cc: Will Deacon, Andrey Ryabinin, Alexander Potapenko, Dmitry Vyukov,
Vincenzo Frascino, Mark Rutland, linux-kernel, kasan-dev, llvm,
Andrew Pinski
On Mon, Oct 21, 2024 at 2:00 PM Marco Elver <elver@google.com> wrote:
>
> This reverts commit 7aed6a2c51ffc97a126e0ea0c270fab7af97ae18.
>
> Now that __no_sanitize_address attribute is fixed for KASAN_SW_TAGS with
> GCC, allow re-enabling KASAN_SW_TAGS with GCC.
>
> Cc: Andrey Konovalov <andreyknvl@gmail.com>
> Cc: Andrew Pinski <pinskia@gmail.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Signed-off-by: Marco Elver <elver@google.com>
> ---
> lib/Kconfig.kasan | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan
> index 233ab2096924..98016e137b7f 100644
> --- a/lib/Kconfig.kasan
> +++ b/lib/Kconfig.kasan
> @@ -22,11 +22,8 @@ config ARCH_DISABLE_KASAN_INLINE
> config CC_HAS_KASAN_GENERIC
> def_bool $(cc-option, -fsanitize=kernel-address)
>
> -# GCC appears to ignore no_sanitize_address when -fsanitize=kernel-hwaddress
> -# is passed. See https://bugzilla.kernel.org/show_bug.cgi?id=218854 (and
> -# the linked LKML thread) for more details.
> config CC_HAS_KASAN_SW_TAGS
> - def_bool !CC_IS_GCC && $(cc-option, -fsanitize=kernel-hwaddress)
> + def_bool $(cc-option, -fsanitize=kernel-hwaddress)
>
> # This option is only required for software KASAN modes.
> # Old GCC versions do not have proper support for no_sanitize_address.
> @@ -101,7 +98,7 @@ config KASAN_SW_TAGS
> help
> Enables Software Tag-Based KASAN.
>
> - Requires Clang.
> + Requires GCC 11+ or Clang.
>
> Supported only on arm64 CPUs and relies on Top Byte Ignore.
>
> --
> 2.47.0.rc1.288.g06298d1525-goog
>
Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC
2024-10-21 12:00 [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC Marco Elver
2024-10-21 12:00 ` [PATCH 2/2] Revert "kasan: Disable Software Tag-Based KASAN with GCC" Marco Elver
2024-10-21 17:12 ` [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC Andrey Konovalov
@ 2024-10-21 17:20 ` Will Deacon
2024-10-21 17:29 ` Andrew Pinski
2024-10-23 16:21 ` Will Deacon
3 siblings, 1 reply; 9+ messages in thread
From: Will Deacon @ 2024-10-21 17:20 UTC (permalink / raw)
To: Marco Elver
Cc: Andrey Ryabinin, Alexander Potapenko, Andrey Konovalov,
Dmitry Vyukov, Vincenzo Frascino, Mark Rutland, linux-kernel,
kasan-dev, llvm, syzbot+908886656a02769af987, Andrew Pinski
On Mon, Oct 21, 2024 at 02:00:10PM +0200, Marco Elver wrote:
> Per [1], -fsanitize=kernel-hwaddress with GCC currently does not disable
> instrumentation in functions with __attribute__((no_sanitize_address)).
>
> However, __attribute__((no_sanitize("hwaddress"))) does correctly
> disable instrumentation. Use it instead.
>
> Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117196 [1]
> Link: https://lore.kernel.org/r/000000000000f362e80620e27859@google.com
> Link: https://lore.kernel.org/r/ZvFGwKfoC4yVjN_X@J2N7QTR9R3
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=218854
> Reported-by: syzbot+908886656a02769af987@syzkaller.appspotmail.com
> Tested-by: Andrey Konovalov <andreyknvl@gmail.com>
> Cc: Andrew Pinski <pinskia@gmail.com>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Signed-off-by: Marco Elver <elver@google.com>
> ---
> include/linux/compiler-gcc.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index f805adaa316e..cd6f9aae311f 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -80,7 +80,11 @@
> #define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))
> #endif
>
> +#ifdef __SANITIZE_HWADDRESS__
> +#define __no_sanitize_address __attribute__((__no_sanitize__("hwaddress")))
> +#else
> #define __no_sanitize_address __attribute__((__no_sanitize_address__))
> +#endif
Does this work correctly for all versions of GCC that support
-fsanitize=kernel-hwaddress?
Will
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC
2024-10-21 17:20 ` Will Deacon
@ 2024-10-21 17:29 ` Andrew Pinski
2024-10-22 21:42 ` Marco Elver
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Pinski @ 2024-10-21 17:29 UTC (permalink / raw)
To: Will Deacon
Cc: Marco Elver, Andrey Ryabinin, Alexander Potapenko,
Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino, Mark Rutland,
linux-kernel, kasan-dev, llvm, syzbot+908886656a02769af987,
Andrew Pinski (QUIC)
On Mon, Oct 21, 2024 at 10:21 AM Will Deacon <will@kernel.org> wrote:
>
> On Mon, Oct 21, 2024 at 02:00:10PM +0200, Marco Elver wrote:
> > Per [1], -fsanitize=kernel-hwaddress with GCC currently does not disable
> > instrumentation in functions with __attribute__((no_sanitize_address)).
> >
> > However, __attribute__((no_sanitize("hwaddress"))) does correctly
> > disable instrumentation. Use it instead.
> >
> > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117196 [1]
> > Link: https://lore.kernel.org/r/000000000000f362e80620e27859@google.com
> > Link: https://lore.kernel.org/r/ZvFGwKfoC4yVjN_X@J2N7QTR9R3
> > Link: https://bugzilla.kernel.org/show_bug.cgi?id=218854
> > Reported-by: syzbot+908886656a02769af987@syzkaller.appspotmail.com
> > Tested-by: Andrey Konovalov <andreyknvl@gmail.com>
> > Cc: Andrew Pinski <pinskia@gmail.com>
> > Cc: Mark Rutland <mark.rutland@arm.com>
> > Cc: Will Deacon <will@kernel.org>
> > Signed-off-by: Marco Elver <elver@google.com>
> > ---
> > include/linux/compiler-gcc.h | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> > index f805adaa316e..cd6f9aae311f 100644
> > --- a/include/linux/compiler-gcc.h
> > +++ b/include/linux/compiler-gcc.h
> > @@ -80,7 +80,11 @@
> > #define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))
> > #endif
> >
> > +#ifdef __SANITIZE_HWADDRESS__
> > +#define __no_sanitize_address __attribute__((__no_sanitize__("hwaddress")))
> > +#else
> > #define __no_sanitize_address __attribute__((__no_sanitize_address__))
> > +#endif
>
> Does this work correctly for all versions of GCC that support
> -fsanitize=kernel-hwaddress?
Yes, tested from GCC 11+, kernel-hwaddress was added in GCC 11.
Also tested from clang 9.0+ and it works there too.
Thanks,
Andrew Pinski
>
> Will
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC
2024-10-21 17:29 ` Andrew Pinski
@ 2024-10-22 21:42 ` Marco Elver
2024-10-23 14:55 ` Will Deacon
0 siblings, 1 reply; 9+ messages in thread
From: Marco Elver @ 2024-10-22 21:42 UTC (permalink / raw)
To: Andrew Pinski
Cc: Will Deacon, Andrey Ryabinin, Alexander Potapenko,
Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino, Mark Rutland,
linux-kernel, kasan-dev, llvm, syzbot+908886656a02769af987,
Andrew Pinski (QUIC)
On Mon, 21 Oct 2024 at 19:29, Andrew Pinski <pinskia@gmail.com> wrote:
>
> On Mon, Oct 21, 2024 at 10:21 AM Will Deacon <will@kernel.org> wrote:
> >
> > On Mon, Oct 21, 2024 at 02:00:10PM +0200, Marco Elver wrote:
> > > Per [1], -fsanitize=kernel-hwaddress with GCC currently does not disable
> > > instrumentation in functions with __attribute__((no_sanitize_address)).
> > >
> > > However, __attribute__((no_sanitize("hwaddress"))) does correctly
> > > disable instrumentation. Use it instead.
> > >
> > > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117196 [1]
> > > Link: https://lore.kernel.org/r/000000000000f362e80620e27859@google.com
> > > Link: https://lore.kernel.org/r/ZvFGwKfoC4yVjN_X@J2N7QTR9R3
> > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=218854
> > > Reported-by: syzbot+908886656a02769af987@syzkaller.appspotmail.com
> > > Tested-by: Andrey Konovalov <andreyknvl@gmail.com>
> > > Cc: Andrew Pinski <pinskia@gmail.com>
> > > Cc: Mark Rutland <mark.rutland@arm.com>
> > > Cc: Will Deacon <will@kernel.org>
> > > Signed-off-by: Marco Elver <elver@google.com>
> > > ---
> > > include/linux/compiler-gcc.h | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> > > index f805adaa316e..cd6f9aae311f 100644
> > > --- a/include/linux/compiler-gcc.h
> > > +++ b/include/linux/compiler-gcc.h
> > > @@ -80,7 +80,11 @@
> > > #define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))
> > > #endif
> > >
> > > +#ifdef __SANITIZE_HWADDRESS__
> > > +#define __no_sanitize_address __attribute__((__no_sanitize__("hwaddress")))
> > > +#else
> > > #define __no_sanitize_address __attribute__((__no_sanitize_address__))
> > > +#endif
> >
> > Does this work correctly for all versions of GCC that support
> > -fsanitize=kernel-hwaddress?
>
> Yes, tested from GCC 11+, kernel-hwaddress was added in GCC 11.
> Also tested from clang 9.0+ and it works there too.
+1 yes. From what I can tell GCC always supported
no_sanitize("hwaddress") for -fsanitize=kernel-hwaddress.
Even for Clang, we define __no_sanitize_address to include
no_sanitize("hwaddress"):
https://elixir.bootlin.com/linux/v6.11.4/source/include/linux/compiler-clang.h#L29
So this has just been an oversight when GCC support for KASAN_SW_TAGS
was introduced.
Having a Fixes tag for this would be nice, but I don't think we
explicitly added GCC support, and instead just relied on
CC_HAS_KASAN_SW_TAGS with cc-option telling us if the flag is
supported.
But maybe we can use this:
Fixes: 7b861a53e46b ("kasan: Bump required compiler version")
Because it's the first time we encountered issues with no_sanitize,
and bumped the required GCC version as a result. Perhaps going along
with that should have been fixing of compiler-gcc.h's definition of
__no_sanitize_address.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC
2024-10-22 21:42 ` Marco Elver
@ 2024-10-23 14:55 ` Will Deacon
0 siblings, 0 replies; 9+ messages in thread
From: Will Deacon @ 2024-10-23 14:55 UTC (permalink / raw)
To: Marco Elver
Cc: Andrew Pinski, Andrey Ryabinin, Alexander Potapenko,
Andrey Konovalov, Dmitry Vyukov, Vincenzo Frascino, Mark Rutland,
linux-kernel, kasan-dev, llvm, syzbot+908886656a02769af987,
Andrew Pinski (QUIC)
On Tue, Oct 22, 2024 at 11:42:40PM +0200, Marco Elver wrote:
> On Mon, 21 Oct 2024 at 19:29, Andrew Pinski <pinskia@gmail.com> wrote:
> >
> > On Mon, Oct 21, 2024 at 10:21 AM Will Deacon <will@kernel.org> wrote:
> > >
> > > On Mon, Oct 21, 2024 at 02:00:10PM +0200, Marco Elver wrote:
> > > > Per [1], -fsanitize=kernel-hwaddress with GCC currently does not disable
> > > > instrumentation in functions with __attribute__((no_sanitize_address)).
> > > >
> > > > However, __attribute__((no_sanitize("hwaddress"))) does correctly
> > > > disable instrumentation. Use it instead.
> > > >
> > > > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117196 [1]
> > > > Link: https://lore.kernel.org/r/000000000000f362e80620e27859@google.com
> > > > Link: https://lore.kernel.org/r/ZvFGwKfoC4yVjN_X@J2N7QTR9R3
> > > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=218854
> > > > Reported-by: syzbot+908886656a02769af987@syzkaller.appspotmail.com
> > > > Tested-by: Andrey Konovalov <andreyknvl@gmail.com>
> > > > Cc: Andrew Pinski <pinskia@gmail.com>
> > > > Cc: Mark Rutland <mark.rutland@arm.com>
> > > > Cc: Will Deacon <will@kernel.org>
> > > > Signed-off-by: Marco Elver <elver@google.com>
> > > > ---
> > > > include/linux/compiler-gcc.h | 4 ++++
> > > > 1 file changed, 4 insertions(+)
> > > >
> > > > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> > > > index f805adaa316e..cd6f9aae311f 100644
> > > > --- a/include/linux/compiler-gcc.h
> > > > +++ b/include/linux/compiler-gcc.h
> > > > @@ -80,7 +80,11 @@
> > > > #define __noscs __attribute__((__no_sanitize__("shadow-call-stack")))
> > > > #endif
> > > >
> > > > +#ifdef __SANITIZE_HWADDRESS__
> > > > +#define __no_sanitize_address __attribute__((__no_sanitize__("hwaddress")))
> > > > +#else
> > > > #define __no_sanitize_address __attribute__((__no_sanitize_address__))
> > > > +#endif
> > >
> > > Does this work correctly for all versions of GCC that support
> > > -fsanitize=kernel-hwaddress?
> >
> > Yes, tested from GCC 11+, kernel-hwaddress was added in GCC 11.
> > Also tested from clang 9.0+ and it works there too.
>
> +1 yes. From what I can tell GCC always supported
> no_sanitize("hwaddress") for -fsanitize=kernel-hwaddress.
Thanks, both, for confirming this. I'll pick these up as fixes in the
arm64 tree.
> Even for Clang, we define __no_sanitize_address to include
> no_sanitize("hwaddress"):
> https://elixir.bootlin.com/linux/v6.11.4/source/include/linux/compiler-clang.h#L29
>
> So this has just been an oversight when GCC support for KASAN_SW_TAGS
> was introduced.
>
> Having a Fixes tag for this would be nice, but I don't think we
> explicitly added GCC support, and instead just relied on
> CC_HAS_KASAN_SW_TAGS with cc-option telling us if the flag is
> supported.
>
> But maybe we can use this:
>
> Fixes: 7b861a53e46b ("kasan: Bump required compiler version")
I can add that to patch 1.
Will
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC
2024-10-21 12:00 [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC Marco Elver
` (2 preceding siblings ...)
2024-10-21 17:20 ` Will Deacon
@ 2024-10-23 16:21 ` Will Deacon
3 siblings, 0 replies; 9+ messages in thread
From: Will Deacon @ 2024-10-23 16:21 UTC (permalink / raw)
To: Marco Elver
Cc: catalin.marinas, kernel-team, Will Deacon, Andrey Ryabinin,
Alexander Potapenko, Andrey Konovalov, Dmitry Vyukov,
Vincenzo Frascino, Mark Rutland, linux-kernel, kasan-dev, llvm,
syzbot+908886656a02769af987, Andrew Pinski
On Mon, 21 Oct 2024 14:00:10 +0200, Marco Elver wrote:
> Per [1], -fsanitize=kernel-hwaddress with GCC currently does not disable
> instrumentation in functions with __attribute__((no_sanitize_address)).
>
> However, __attribute__((no_sanitize("hwaddress"))) does correctly
> disable instrumentation. Use it instead.
>
>
> [...]
Applied to arm64 (for-next/fixes), thanks!
[1/2] kasan: Fix Software Tag-Based KASAN with GCC
https://git.kernel.org/arm64/c/894b00a3350c
[2/2] Revert "kasan: Disable Software Tag-Based KASAN with GCC"
https://git.kernel.org/arm64/c/237ab03e301d
Cheers,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-10-23 16:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-21 12:00 [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC Marco Elver
2024-10-21 12:00 ` [PATCH 2/2] Revert "kasan: Disable Software Tag-Based KASAN with GCC" Marco Elver
2024-10-21 17:13 ` Andrey Konovalov
2024-10-21 17:12 ` [PATCH 1/2] kasan: Fix Software Tag-Based KASAN with GCC Andrey Konovalov
2024-10-21 17:20 ` Will Deacon
2024-10-21 17:29 ` Andrew Pinski
2024-10-22 21:42 ` Marco Elver
2024-10-23 14:55 ` Will Deacon
2024-10-23 16:21 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®