]> www.infradead.org Git - users/willy/xarray.git/commit
x86/traps: Enable UBSAN traps on x86
authorGatlin Newhouse <gatlin.newhouse@gmail.com>
Wed, 24 Jul 2024 00:01:55 +0000 (00:01 +0000)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 6 Aug 2024 11:42:40 +0000 (13:42 +0200)
commit7424fc6b86c8980a87169e005f5cd4438d18efe6
tree090afe00201332780aef7b4a16369caf7ed17ba4
parent8400291e289ee6b2bf9779ff1c83a291501f017b
x86/traps: Enable UBSAN traps on x86

Currently ARM64 extracts which specific sanitizer has caused a trap via
encoded data in the trap instruction. Clang on x86 currently encodes the
same data in the UD1 instruction but x86 handle_bug() and
is_valid_bugaddr() currently only look at UD2.

Bring x86 to parity with ARM64, similar to commit 25b84002afb9 ("arm64:
Support Clang UBSAN trap codes for better reporting"). See the llvm
links for information about the code generation.

Enable the reporting of UBSAN sanitizer details on x86 compiled with clang
when CONFIG_UBSAN_TRAP=y by analysing UD1 and retrieving the type immediate
which is encoded by the compiler after the UD1.

[ tglx: Simplified it by moving the printk() into handle_bug() ]

Signed-off-by: Gatlin Newhouse <gatlin.newhouse@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/all/20240724000206.451425-1-gatlin.newhouse@gmail.com
Link: https://github.com/llvm/llvm-project/commit/c5978f42ec8e9#diff-bb68d7cd885f41cfc35843998b0f9f534adb60b415f647109e597ce448e92d9f
Link: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/X86/X86InstrSystem.td#L27
arch/x86/include/asm/bug.h
arch/x86/kernel/traps.c
include/linux/ubsan.h
lib/Kconfig.ubsan