Skip to content

Commit 03b691d

Browse files
nickdesaulniersTogoFire
authored andcommitted
ubsan: disable UBSAN_DIV_ZERO for clang
Building with UBSAN_DIV_ZERO with clang produces numerous fallthrough warnings from objtool. In the case of uncheck division, UBSAN_DIV_ZERO may introduce new control flow to check for division by zero. Because the result of the division is undefined, LLVM may optimize the control flow such that after the call to __ubsan_handle_divrem_overflow doesn't matter. If panic_on_warn was set, __ubsan_handle_divrem_overflow would panic. The problem is is that panic_on_warn is run time configurable. If it's disabled, then we cannot guarantee that we will be able to recover safely. Disable this config for clang until we can come up with a solution in LLVM. Link: ClangBuiltLinux/linux#1657 Link: llvm/llvm-project#56289 Link: https://lore.kernel.org/lkml/CAHk-=wj1qhf7y3VNACEexyp5EbkNpdcu_542k-xZpzmYLOjiCg@mail.gmail.com/ Reported-by: Sudip Mukherjee <[email protected]> Suggested-by: Linus Torvalds <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Change-Id: Ib148a383852bd6a0e9e2c8bafcd10961c37991dc Acked-by: Nathan Chancellor <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Alexander Winkowski <[email protected]> (cherry picked from commit 65b37d8468a4afffbef4ba91c5ae53d3d90e7911) Signed-off-by: TogoFire <[email protected]>
1 parent ff85f19 commit 03b691d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/Kconfig.ubsan

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ config UBSAN_SHIFT
8484
config UBSAN_DIV_ZERO
8585
bool "Perform checking for integer divide-by-zero"
8686
depends on $(cc-option,-fsanitize=integer-divide-by-zero)
87+
# https://github.com/ClangBuiltLinux/linux/issues/1657
88+
# https://github.com/llvm/llvm-project/issues/56289
89+
depends on !CC_IS_CLANG
8790
help
8891
This option enables -fsanitize=integer-divide-by-zero which checks
8992
for integer division by zero. This is effectively redundant with the

0 commit comments

Comments
 (0)