Skip to content

Commit 79c54c9

Browse files
author
Al Viro
committed
sparc: fix livelock in uaccess
sparc equivalent of 26178ec "x86: mm: consolidate VM_FAULT_RETRY handling" If e.g. get_user() triggers a page fault and a fatal signal is caught, we might end up with handle_mm_fault() returning VM_FAULT_RETRY and not doing anything to page tables. In such case we must *not* return to the faulting insn - that would repeat the entire thing without making any progress; what we need instead is to treat that as failed (user) memory access. Signed-off-by: Al Viro <[email protected]>
1 parent dce4549 commit 79c54c9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

arch/sparc/mm/fault_32.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,11 @@ asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
187187
*/
188188
fault = handle_mm_fault(vma, address, flags, regs);
189189

190-
if (fault_signal_pending(fault, regs))
190+
if (fault_signal_pending(fault, regs)) {
191+
if (!from_user)
192+
goto no_context;
191193
return;
194+
}
192195

193196
/* The fault is fully completed (including releasing mmap lock) */
194197
if (fault & VM_FAULT_COMPLETED)

arch/sparc/mm/fault_64.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,13 @@ asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
424424

425425
fault = handle_mm_fault(vma, address, flags, regs);
426426

427-
if (fault_signal_pending(fault, regs))
427+
if (fault_signal_pending(fault, regs)) {
428+
if (regs->tstate & TSTATE_PRIV) {
429+
insn = get_fault_insn(regs, insn);
430+
goto handle_kernel_fault;
431+
}
428432
goto exit_exception;
433+
}
429434

430435
/* The fault is fully completed (including releasing mmap lock) */
431436
if (fault & VM_FAULT_COMPLETED)

0 commit comments

Comments
 (0)