]> git.baikalelectronics.ru Git - kernel.git/commit
ubsan: disable UBSAN_DIV_ZERO for clang
authorNick Desaulniers <ndesaulniers@google.com>
Thu, 14 Jul 2022 20:56:43 +0000 (13:56 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 14 Jul 2022 22:45:26 +0000 (15:45 -0700)
commit1d9b6e3f6b119ff4e114e6d835c3f3224e032783
tree70882f76aadafb78cff39787cf8de945c0eed09b
parent9d5b7624f513b7d27f5bee18e062b09110419d66
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: https://github.com/ClangBuiltLinux/linux/issues/1657
Link: https://github.com/llvm/llvm-project/issues/56289
Link: https://lore.kernel.org/lkml/CAHk-=wj1qhf7y3VNACEexyp5EbkNpdcu_542k-xZpzmYLOjiCg@mail.gmail.com/
Reported-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/Kconfig.ubsan