Skip to content

Commit 4466927

Browse files
misalehMarc Zyngier
authored andcommitted
KVM: arm64: Handle UBSAN faults
As now UBSAN can be enabled, handle brk64 exits from UBSAN. Re-use the decoding code from the kernel, and panic with UBSAN message. Signed-off-by: Mostafa Saleh <smostafa@google.com> Reviewed-by: Kees Cook <kees@kernel.org> Link: https://lore.kernel.org/r/20250430162713.1997569-5-smostafa@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 61b38f7 commit 4466927

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/arm64/kvm/handle_exit.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/kvm.h>
1212
#include <linux/kvm_host.h>
13+
#include <linux/ubsan.h>
1314

1415
#include <asm/esr.h>
1516
#include <asm/exception.h>
@@ -474,6 +475,11 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr,
474475
print_nvhe_hyp_panic("BUG", panic_addr);
475476
} else if (IS_ENABLED(CONFIG_CFI_CLANG) && esr_is_cfi_brk(esr)) {
476477
kvm_nvhe_report_cfi_failure(panic_addr);
478+
} else if (IS_ENABLED(CONFIG_UBSAN_KVM_EL2) &&
479+
ESR_ELx_EC(esr) == ESR_ELx_EC_BRK64 &&
480+
esr_is_ubsan_brk(esr)) {
481+
print_nvhe_hyp_panic(report_ubsan_failure(esr & UBSAN_BRK_MASK),
482+
panic_addr);
477483
} else {
478484
print_nvhe_hyp_panic("panic", panic_addr);
479485
}

0 commit comments

Comments
 (0)