From 06d074249fa373865805136b3d34aeb7c20ee5d2 Mon Sep 17 00:00:00 2001 From: Sangmoon Kim Date: Fri, 15 Oct 2021 20:45:13 +0900 Subject: [PATCH] ANDROID: arm64: add vendor hooks for bti and pauth fault Add hooks to gather data of unusual aborts and summarize it with other information. Bug: 203187389 Signed-off-by: Sangmoon Kim Change-Id: I37b3047e72f64dc210d3d3bffe5ee207daeba8d6 --- arch/arm64/kernel/traps.c | 2 ++ drivers/android/vendor_hooks.c | 2 ++ include/trace/hooks/traps.h | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index e5e65f785c43..6c39a61ec115 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -414,6 +414,7 @@ NOKPROBE_SYMBOL(do_undefinstr); void do_bti(struct pt_regs *regs) { + trace_android_rvh_do_bti(regs, user_mode(regs)); BUG_ON(!user_mode(regs)); force_signal_inject(SIGILL, ILL_ILLOPC, regs->pc, 0); } @@ -425,6 +426,7 @@ void do_ptrauth_fault(struct pt_regs *regs, unsigned int esr) * Unexpected FPAC exception or pointer authentication failure in * the kernel: kill the task before it does any more harm. */ + trace_android_rvh_do_ptrauth_fault(regs, esr, user_mode(regs)); BUG_ON(!user_mode(regs)); force_signal_inject(SIGILL, ILL_ILLOPN, regs->pc, esr); } diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index e3506cdeacb0..1f6ac9318411 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -243,6 +243,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alter_mutex_list_add); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mutex_unlock_slowpath); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_rwsem_wake_finish); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_undefinstr); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_bti); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_do_ptrauth_fault); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_bad_mode); EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_arm64_serror_panic); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_selinux_avc_insert); diff --git a/include/trace/hooks/traps.h b/include/trace/hooks/traps.h index 350a14369acc..f8d56a207afc 100644 --- a/include/trace/hooks/traps.h +++ b/include/trace/hooks/traps.h @@ -17,6 +17,16 @@ DECLARE_RESTRICTED_HOOK(android_rvh_do_undefinstr, TP_ARGS(regs, user), TP_CONDITION(!user)); +DECLARE_RESTRICTED_HOOK(android_rvh_do_bti, + TP_PROTO(struct pt_regs *regs, bool user), + TP_ARGS(regs, user), + TP_CONDITION(!user)); + +DECLARE_RESTRICTED_HOOK(android_rvh_do_ptrauth_fault, + TP_PROTO(struct pt_regs *regs, unsigned int esr, bool user), + TP_ARGS(regs, esr, user), + TP_CONDITION(!user)); + DECLARE_RESTRICTED_HOOK(android_rvh_bad_mode, TP_PROTO(struct pt_regs *regs, unsigned int esr, int reason), TP_ARGS(regs, reason, esr), 1);