summaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2018-06-22 06:45:07 -0400
committerThomas Gleixner <tglx@linutronix.de>2018-06-22 13:04:22 -0400
commit784e0300fe9fe4aa81bd7df9d59e138f56bb605b (patch)
tree442642dae3c8e1b50ab68460c2e7662684d9e194 /arch/powerpc
parent9a789fcfe8605417f7a1a970355f5efa4fe88c64 (diff)
rseq: Avoid infinite recursion when delivering SIGSEGV
When delivering a signal to a task that is using rseq, we call into __rseq_handle_notify_resume() so that the registers pushed in the sigframe are updated to reflect the state of the restartable sequence (for example, ensuring that the signal returns to the abort handler if necessary). However, if the rseq management fails due to an unrecoverable fault when accessing userspace or certain combinations of RSEQ_CS_* flags, then we will attempt to deliver a SIGSEGV. This has the potential for infinite recursion if the rseq code continuously fails on signal delivery. Avoid this problem by using force_sigsegv() instead of force_sig(), which is explicitly designed to reset the SEGV handler to SIG_DFL in the case of a recursive fault. In doing so, remove rseq_signal_deliver() from the internal rseq API and have an optional struct ksignal * parameter to rseq_handle_notify_resume() instead. Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: peterz@infradead.org Cc: paulmck@linux.vnet.ibm.com Cc: boqun.feng@gmail.com Link: https://lkml.kernel.org/r/1529664307-983-1-git-send-email-will.deacon@arm.com
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/kernel/signal.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/powerpc/kernel/signal.c b/arch/powerpc/kernel/signal.c
index 17fe4339ba59..b3e8db376ecd 100644
--- a/arch/powerpc/kernel/signal.c
+++ b/arch/powerpc/kernel/signal.c
@@ -134,7 +134,7 @@ static void do_signal(struct task_struct *tsk)
134 /* Re-enable the breakpoints for the signal stack */ 134 /* Re-enable the breakpoints for the signal stack */
135 thread_change_pc(tsk, tsk->thread.regs); 135 thread_change_pc(tsk, tsk->thread.regs);
136 136
137 rseq_signal_deliver(tsk->thread.regs); 137 rseq_signal_deliver(&ksig, tsk->thread.regs);
138 138
139 if (is32) { 139 if (is32) {
140 if (ksig.ka.sa.sa_flags & SA_SIGINFO) 140 if (ksig.ka.sa.sa_flags & SA_SIGINFO)
@@ -170,7 +170,7 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags)
170 if (thread_info_flags & _TIF_NOTIFY_RESUME) { 170 if (thread_info_flags & _TIF_NOTIFY_RESUME) {
171 clear_thread_flag(TIF_NOTIFY_RESUME); 171 clear_thread_flag(TIF_NOTIFY_RESUME);
172 tracehook_notify_resume(regs); 172 tracehook_notify_resume(regs);
173 rseq_handle_notify_resume(regs); 173 rseq_handle_notify_resume(NULL, regs);
174 } 174 }
175 175
176 user_enter(); 176 user_enter();