aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2018-02-02 12:31:39 -0500
committerCatalin Marinas <catalin.marinas@arm.com>2018-02-06 17:53:44 -0500
commit5dfc6ed27710c42cbc15db5c0d4475699991da0a (patch)
treeb2cb8fd601a5694ce4992354dc83c0fbd6e2f459
parent91b2d3442f6a44dce875670d702af22737ad5eff (diff)
arm64: entry: Apply BP hardening for high-priority synchronous exceptions
Software-step and PC alignment fault exceptions have higher priority than instruction abort exceptions, so apply the BP hardening hooks there too if the user PC appears to reside in kernel space. Reported-by: Dan Hettena <dhettena@nvidia.com> Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/kernel/entry.S5
-rw-r--r--arch/arm64/mm/fault.c9
2 files changed, 13 insertions, 1 deletions
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S
index 4dd1b5a46642..af22793103af 100644
--- a/arch/arm64/kernel/entry.S
+++ b/arch/arm64/kernel/entry.S
@@ -767,7 +767,10 @@ el0_sp_pc:
767 * Stack or PC alignment exception handling 767 * Stack or PC alignment exception handling
768 */ 768 */
769 mrs x26, far_el1 769 mrs x26, far_el1
770 enable_daif 770 enable_da_f
771#ifdef CONFIG_TRACE_IRQFLAGS
772 bl trace_hardirqs_off
773#endif
771 ct_user_exit 774 ct_user_exit
772 mov x0, x26 775 mov x0, x26
773 mov x1, x25 776 mov x1, x25
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index af530eb9f2ed..43b28a782ed4 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -732,6 +732,12 @@ asmlinkage void __exception do_sp_pc_abort(unsigned long addr,
732 struct siginfo info; 732 struct siginfo info;
733 struct task_struct *tsk = current; 733 struct task_struct *tsk = current;
734 734
735 if (user_mode(regs)) {
736 if (instruction_pointer(regs) > TASK_SIZE)
737 arm64_apply_bp_hardening();
738 local_irq_enable();
739 }
740
735 if (show_unhandled_signals && unhandled_signal(tsk, SIGBUS)) 741 if (show_unhandled_signals && unhandled_signal(tsk, SIGBUS))
736 pr_info_ratelimited("%s[%d]: %s exception: pc=%p sp=%p\n", 742 pr_info_ratelimited("%s[%d]: %s exception: pc=%p sp=%p\n",
737 tsk->comm, task_pid_nr(tsk), 743 tsk->comm, task_pid_nr(tsk),
@@ -791,6 +797,9 @@ asmlinkage int __exception do_debug_exception(unsigned long addr,
791 if (interrupts_enabled(regs)) 797 if (interrupts_enabled(regs))
792 trace_hardirqs_off(); 798 trace_hardirqs_off();
793 799
800 if (user_mode(regs) && instruction_pointer(regs) > TASK_SIZE)
801 arm64_apply_bp_hardening();
802
794 if (!inf->fn(addr, esr, regs)) { 803 if (!inf->fn(addr, esr, regs)) {
795 rv = 1; 804 rv = 1;
796 } else { 805 } else {