Skip to contentSkip to conversation

kasan: turn on -fsanitize-address-use-after-scope

PATCH Superseded Andrey Ryabinin 2 participants 3 messages Dec 8, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kasan: turn on -fsanitize-address-use-after-scope

In the upcoming gcc7 release release, the -fsanitize=kernel-address option at first implied new -fsanitize-address-use-after-scope option. This would cause link errors on older kernels because they don't have two new functions required for use-after-scope support. Therefore, gcc7 changed default to -fno-sanitize-address-use-after-scope.

Now the kernel has everything required for that feature since commit 828347f8f9a5 ("kasan: support use-after-scope detection"). So, to make it work, we just have to enable use-after-scope in CFLAGS.

---
 scripts/Makefile.kasan | 2 ++
 1 file changed, 2 insertions(+)
scripts/Makefile.kasan +2 -0
index 37323b0..9576775 100644
@@ -28,4 +28,6 @@ else
         CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
     endif
 endif
+
+CFLAGS_KASAN += $(call cc-option, -fsanitize-address-use-after-scope)
 endif
Signature · 1 line
2.7.3
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 20 lines · Andrey Ryabinin

In the upcoming gcc7 release release, the -fsanitize=kernel-address option at first implied new -fsanitize-address-use-after-scope option. This would cause link errors on older kernels because they don't have two new functions required for use-after-scope support. Therefore, gcc7 changed default to -fno-sanitize-address-use-after-scope.

Now the kernel has everything required for that feature since commit 828347f8f9a5 ("kasan: support use-after-scope detection"). So, to make it work, we just have to enable use-after-scope in CFLAGS.

---
 scripts/Makefile.kasan | 2 ++
 1 file changed, 2 insertions(+)
scripts/Makefile.kasan +0 -0
index 37323b0..9576775 100644

scripts/Makefile.kasan else

Quoted 7 lines
scripts/Makefile.kasan +2 -1
@@ -28,4 +28,6 @@ else
         CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
     endif
 endif
+
+CFLAGS_KASAN += $(call cc-option, -fsanitize-address-use-after-scope)
 endif
--

Doubled word "release release" on the first line of description. But otherwise:

I've just submitted the corresponding gcc change:
https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=243441

#2 lore raw

PATCH v2 1/1 kasan: turn on -fsanitize-address-use-after-scope

In the upcoming gcc7 release, the -fsanitize=kernel-address option at first implied new -fsanitize-address-use-after-scope option. This would cause link errors on older kernels because they don't have two new functions required for use-after-scope support. Therefore, gcc7 changed default to -fno-sanitize-address-use-after-scope.

Now the kernel has everything required for that feature since commit 828347f8f9a5 ("kasan: support use-after-scope detection"). So, to make it work, we just have to enable use-after-scope in CFLAGS.

---
Changes since v1:
- s/release release/relase in changelog
- added Ack

 scripts/Makefile.kasan | 2 ++
 1 file changed, 2 insertions(+)
scripts/Makefile.kasan +2 -0
index 37323b0..9576775 100644
@@ -28,4 +28,6 @@ else
         CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
     endif
 endif
+
+CFLAGS_KASAN += $(call cc-option, -fsanitize-address-use-after-scope)
 endif
Signature · 1 line
2.7.3