Skip to contentSkip to conversation

ubsan: remove cc-option test for UBSAN_TRAP

PATCH Applied Nick Desaulniers 4 participants 11 messages Apr 7, 2023 – May 17, 2023

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

PATCH 1/1 ubsan: remove cc-option test for UBSAN_TRAP

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

---
Masahiro, Kees: get_maintainer.pl leaves much to be desired for this file. Can one of you please pick this up?

 lib/Kconfig.ubsan | 1 -
 1 file changed, 1 deletion(-)
lib/Kconfig.ubsan +0 -1
index fd15230a703b..0e7ad0782399 100644
@@ -15,7 +15,6 @@ if UBSAN
 config UBSAN_TRAP
 	bool "On Sanitizer warnings, abort the running kernel code"
 	depends on !COMPILE_TEST
-	depends on $(cc-option, -fsanitize-undefined-trap-on-error)
 	help
 	  Building kernels with Sanitizer features enabled tends to grow
 	  the kernel size by around 5%, due to adding all the debugging
Signature · 1 line
2.40.0.577.gac1e443424-goog
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

As an aside, we should really consider having some standard format of comment around cc-option checks so that we can easily remove them when they become stale...

Quoted 22 lines

---
Masahiro, Kees: get_maintainer.pl leaves much to be desired for this file. Can one of you please pick this up?

 lib/Kconfig.ubsan | 1 -
 1 file changed, 1 deletion(-)
lib/Kconfig.ubsan +0 -1
index fd15230a703b..0e7ad0782399 100644
@@ -15,7 +15,6 @@ if UBSAN
 config UBSAN_TRAP
 	bool "On Sanitizer warnings, abort the running kernel code"
 	depends on !COMPILE_TEST
-	depends on $(cc-option, -fsanitize-undefined-trap-on-error)
 	help
 	  Building kernels with Sanitizer features enabled tends to grow
 	  the kernel size by around 5%, due to adding all the debugging
Signature · 1 line
2.40.0.577.gac1e443424-goog
#2 lore raw
Quoted 22 lines · Nathan Chancellor
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

As an aside, we should really consider having some standard format of comment around cc-option checks so that we can easily remove them when they become stale...

Quoted 7 lines

---
Masahiro, Kees: get_maintainer.pl leaves much to be desired for this file. Can one of you please pick this up?

 lib/Kconfig.ubsan | 1 -
 1 file changed, 1 deletion(-)
Quoted 16 lines
Quoted 13 lines
lib/Kconfig.ubsan +0 -2
index fd15230a703b..0e7ad0782399 100644
@@ -15,7 +15,6 @@ if UBSAN
 config UBSAN_TRAP
      bool "On Sanitizer warnings, abort the running kernel code"
      depends on !COMPILE_TEST
-     depends on $(cc-option, -fsanitize-undefined-trap-on-error)
      help
        Building kernels with Sanitizer features enabled tends to grow
        the kernel size by around 5%, due to adding all the debugging
--
Quoted 2 lines

2.40.0.577.gac1e443424-goog

-fsanitize-undefined-trap-on-error is a legacy option from 2013 when -fcatch-undefined-behavior instead of -fsanitize=undefined enabled UBSan.
On the Clang side, http://reviews.llvm.org/D10464 added -fsanitize-trap= in June 2015.
It's best to use -fsanitize-trap=undefined and avoid uses of -fsanitize-undefined-trap-on-error.

Signature · 1 line
宋方睿
#3 lore raw
Quoted 42 lines · Fangrui Song
Quoted 38 lines · Nathan Chancellor
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

As an aside, we should really consider having some standard format of comment around cc-option checks so that we can easily remove them when they become stale...

Quoted 22 lines

---
Masahiro, Kees: get_maintainer.pl leaves much to be desired for this file. Can one of you please pick this up?

 lib/Kconfig.ubsan | 1 -
 1 file changed, 1 deletion(-)
lib/Kconfig.ubsan +0 -2
index fd15230a703b..0e7ad0782399 100644
@@ -15,7 +15,6 @@ if UBSAN
 config UBSAN_TRAP
      bool "On Sanitizer warnings, abort the running kernel code"
      depends on !COMPILE_TEST
-     depends on $(cc-option, -fsanitize-undefined-trap-on-error)
      help
        Building kernels with Sanitizer features enabled tends to grow
        the kernel size by around 5%, due to adding all the debugging
--

2.40.0.577.gac1e443424-goog

(quoted diff) +0 -2
-fsanitize-undefined-trap-on-error is a legacy option from 2013 when
-fcatch-undefined-behavior instead of -fsanitize=undefined enabled
Quoted 5 lines

UBSan.
On the Clang side, http://reviews.llvm.org/D10464 added -fsanitize-trap= in June 2015.
It's best to use -fsanitize-trap=undefined and avoid uses of -fsanitize-undefined-trap-on-error.

But that's Clang-only. -fsanitize-undefined-trap-on-error works for both GCC and Clang.

Signature · 1 line
Kees Cook
#4 lore raw
Quoted 53 lines · Kees Cook
Quoted 42 lines · Fangrui Song
Quoted 38 lines · Nathan Chancellor
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

As an aside, we should really consider having some standard format of comment around cc-option checks so that we can easily remove them when they become stale...

Quoted 22 lines

---
Masahiro, Kees: get_maintainer.pl leaves much to be desired for this file. Can one of you please pick this up?

 lib/Kconfig.ubsan | 1 -
 1 file changed, 1 deletion(-)
lib/Kconfig.ubsan +0 -2
index fd15230a703b..0e7ad0782399 100644
@@ -15,7 +15,6 @@ if UBSAN
 config UBSAN_TRAP
      bool "On Sanitizer warnings, abort the running kernel code"
      depends on !COMPILE_TEST
-     depends on $(cc-option, -fsanitize-undefined-trap-on-error)
      help
        Building kernels with Sanitizer features enabled tends to grow
        the kernel size by around 5%, due to adding all the debugging
--

2.40.0.577.gac1e443424-goog

(quoted diff) +0 -2
-fsanitize-undefined-trap-on-error is a legacy option from 2013 when
-fcatch-undefined-behavior instead of -fsanitize=undefined enabled
Quoted 5 lines

UBSan.
On the Clang side, http://reviews.llvm.org/D10464 added -fsanitize-trap= in June 2015.
It's best to use -fsanitize-trap=undefined and avoid uses of -fsanitize-undefined-trap-on-error.

But that's Clang-only. -fsanitize-undefined-trap-on-error works for both GCC and Clang.

Quoted 2 lines

--
Kees Cook

Just filed a -fsanitize-trap= feature request for GCC:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109489 :)

https://reviews.llvm.org/D10464 (2015) does mention the state of the legacy option:

// https://clang.llvm.org/docs/UsersManual.html#cmdoption-fsanitize-undefined-trap-on-error
-fsanitize-undefined-trap-on-error
Deprecated alias for -fsanitize-trap=undefined.

Signature · 1 line
宋方睿
#5 lore raw
Quoted 61 lines · Fangrui Song
Quoted 53 lines · Kees Cook
Quoted 42 lines · Fangrui Song
Quoted 38 lines · Nathan Chancellor
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

As an aside, we should really consider having some standard format of comment around cc-option checks so that we can easily remove them when they become stale...

Quoted 22 lines

---
Masahiro, Kees: get_maintainer.pl leaves much to be desired for this file. Can one of you please pick this up?

 lib/Kconfig.ubsan | 1 -
 1 file changed, 1 deletion(-)
lib/Kconfig.ubsan +0 -2
index fd15230a703b..0e7ad0782399 100644
@@ -15,7 +15,6 @@ if UBSAN
 config UBSAN_TRAP
      bool "On Sanitizer warnings, abort the running kernel code"
      depends on !COMPILE_TEST
-     depends on $(cc-option, -fsanitize-undefined-trap-on-error)
      help
        Building kernels with Sanitizer features enabled tends to grow
        the kernel size by around 5%, due to adding all the debugging
--

2.40.0.577.gac1e443424-goog

(quoted diff) +0 -2
-fsanitize-undefined-trap-on-error is a legacy option from 2013 when
-fcatch-undefined-behavior instead of -fsanitize=undefined enabled
Quoted 5 lines

UBSan.
On the Clang side, http://reviews.llvm.org/D10464 added -fsanitize-trap= in June 2015.
It's best to use -fsanitize-trap=undefined and avoid uses of -fsanitize-undefined-trap-on-error.

But that's Clang-only. -fsanitize-undefined-trap-on-error works for both GCC and Clang.

Quoted 2 lines

--
Kees Cook

Just filed a -fsanitize-trap= feature request for GCC:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109489 :)

Quoted 6 lines

https://reviews.llvm.org/D10464 (2015) does mention the state of the legacy option:

// https://clang.llvm.org/docs/UsersManual.html#cmdoption-fsanitize-undefined-trap-on-error
-fsanitize-undefined-trap-on-error
Deprecated alias for -fsanitize-trap=undefined.

Circling back. it seems that GCC 13 will have -fsanitize-trap=undefined (a commit from 2022-06).
The current https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
says "The -fsanitize-undefined-trap-on-error option is deprecated equivalent of -fsanitize-trap=all."

We need to discourage further uses of the deprecated -fsanitize-undefined-trap-on-error.

Applied
#6 lore raw
In reply to Nick Desaulniers
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

Applied to for-next/hardening, thanks!

[1/1] ubsan: remove cc-option test for UBSAN_TRAP

      https://git.kernel.org/kees/c/08e4044243a6
Signature · 1 line
Kees Cook
#7 lore raw
Quoted 9 lines · Kees Cook
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

Quoted 9 lines

Applied to for-next/hardening, thanks!

[1/1] ubsan: remove cc-option test for UBSAN_TRAP

      https://git.kernel.org/kees/c/08e4044243a6

--
Kees Cook

For this -fsanitize-undefined-trap-on-error, I think we need a v2 patch that tries -fsanitize-trap=all as well.

-fsanitize-undefined-trap-on-error has been deprecated in Clang for 8 years, and at some point we will remove the option.

GCC implements -fsanitize-trap=all later, but -fsanitize-undefined-trap-on-error is documented as deprecated as well.

Signature · 1 line
宋方睿
#8 lore raw
Quoted 16 lines · Fangrui Song
Quoted 14 lines · Kees Cook
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

Applied to for-next/hardening, thanks!

[1/1] ubsan: remove cc-option test for UBSAN_TRAP

      https://git.kernel.org/kees/c/08e4044243a6
Quoted 7 lines
Quoted 4 lines

--
Kees Cook

For this -fsanitize-undefined-trap-on-error, I think we need a v2 patch that tries -fsanitize-trap=all as well.

Correction: -fsanitize-trap=undefined

Quoted 6 lines

-fsanitize-undefined-trap-on-error has been deprecated in Clang for 8 years, and at some point we will remove the option.

GCC implements -fsanitize-trap=all later, but -fsanitize-undefined-trap-on-error is documented as deprecated as well.

#9 lore raw
Quoted 25 lines · Fangrui Song
Quoted 16 lines · Fangrui Song
Quoted 14 lines · Kees Cook
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

Applied to for-next/hardening, thanks!

[1/1] ubsan: remove cc-option test for UBSAN_TRAP

      https://git.kernel.org/kees/c/08e4044243a6
Quoted 7 lines
Quoted 4 lines

--
Kees Cook

For this -fsanitize-undefined-trap-on-error, I think we need a v2 patch that tries -fsanitize-trap=all as well.

Quoted 8 lines

Correction: -fsanitize-trap=undefined

Quoted 6 lines

-fsanitize-undefined-trap-on-error has been deprecated in Clang for 8 years, and at some point we will remove the option.

GCC implements -fsanitize-trap=all later, but -fsanitize-undefined-trap-on-error is documented as deprecated as well.

Right now all the compilers support the old way, and I'd rather remove a cc-option call than add two. :)

Signature · 1 line
Kees Cook
#10 lore raw
Quoted 39 lines · Kees Cook
Quoted 25 lines · Fangrui Song
Quoted 16 lines · Fangrui Song
Quoted 14 lines · Kees Cook
Quoted 6 lines · Nick Desaulniers

-fsanitize-undefined-trap-on-error has been supported since GCC 5.1 and Clang 3.2. The minimum supported version of these according to Documentation/process/changes.rst is 5.1 and 11.0.0 respectively. Drop this cc-option check.

Applied to for-next/hardening, thanks!

[1/1] ubsan: remove cc-option test for UBSAN_TRAP

      https://git.kernel.org/kees/c/08e4044243a6
Quoted 7 lines
Quoted 4 lines

--
Kees Cook

For this -fsanitize-undefined-trap-on-error, I think we need a v2 patch that tries -fsanitize-trap=all as well.

Quoted 8 lines

Correction: -fsanitize-trap=undefined

Quoted 6 lines

-fsanitize-undefined-trap-on-error has been deprecated in Clang for 8 years, and at some point we will remove the option.

GCC implements -fsanitize-trap=all later, but -fsanitize-undefined-trap-on-error is documented as deprecated as well.

Right now all the compilers support the old way, and I'd rather remove a cc-option call than add two. :)

Quoted 2 lines

--
Kees Cook

Hmm, this gives Clang developers a disadvantage... Anyone who removes Clang's -fsanitize-undefined-trap-on-error (or give it a warning before removal) will probably face complaints from kernel developers...

Signature · 1 line
宋方睿