arm: Add syscall detection for restartable sequences
Syscalls are not allowed inside restartable sequences, so add a call to rseq_syscall() at the very beginning of system call exiting path for CONFIG_DEBUG_RSEQ=y kernel. This could help us to detect whether there is a syscall issued inside restartable sequences. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Joel Fernandes <joelaf@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Dave Watson <davejwatson@fb.com> Cc: Will Deacon <will.deacon@arm.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: "H . Peter Anvin" <hpa@zytor.com> Cc: Chris Lameter <cl@linux.com> Cc: Russell King <linux@arm.linux.org.uk> Cc: Andrew Hunter <ahh@google.com> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Cc: "Paul E . McKenney" <paulmck@linux.vnet.ibm.com> Cc: Paul Turner <pjt@google.com> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Josh Triplett <josh@joshtriplett.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Ben Maurer <bmaurer@fb.com> Cc: linux-api@vger.kernel.org Cc: Andy Lutomirski <luto@amacapital.net> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lkml.kernel.org/r/20180602124408.8430-5-mathieu.desnoyers@efficios.com
This commit is contained in:
parent
9800b9dc13
commit
b74406f377
|
@ -39,12 +39,13 @@ saved_pc .req lr
|
||||||
|
|
||||||
.section .entry.text,"ax",%progbits
|
.section .entry.text,"ax",%progbits
|
||||||
.align 5
|
.align 5
|
||||||
#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING))
|
#if !(IS_ENABLED(CONFIG_TRACE_IRQFLAGS) || IS_ENABLED(CONFIG_CONTEXT_TRACKING) || \
|
||||||
|
IS_ENABLED(CONFIG_DEBUG_RSEQ))
|
||||||
/*
|
/*
|
||||||
* This is the fast syscall return path. We do as little as possible here,
|
* This is the fast syscall return path. We do as little as possible here,
|
||||||
* such as avoiding writing r0 to the stack. We only use this path if we
|
* such as avoiding writing r0 to the stack. We only use this path if we
|
||||||
* have tracing and context tracking disabled - the overheads from those
|
* have tracing, context tracking and rseq debug disabled - the overheads
|
||||||
* features make this path too inefficient.
|
* from those features make this path too inefficient.
|
||||||
*/
|
*/
|
||||||
ret_fast_syscall:
|
ret_fast_syscall:
|
||||||
UNWIND(.fnstart )
|
UNWIND(.fnstart )
|
||||||
|
@ -71,14 +72,20 @@ fast_work_pending:
|
||||||
/* fall through to work_pending */
|
/* fall through to work_pending */
|
||||||
#else
|
#else
|
||||||
/*
|
/*
|
||||||
* The "replacement" ret_fast_syscall for when tracing or context tracking
|
* The "replacement" ret_fast_syscall for when tracing, context tracking,
|
||||||
* is enabled. As we will need to call out to some C functions, we save
|
* or rseq debug is enabled. As we will need to call out to some C functions,
|
||||||
* r0 first to avoid needing to save registers around each C function call.
|
* we save r0 first to avoid needing to save registers around each C function
|
||||||
|
* call.
|
||||||
*/
|
*/
|
||||||
ret_fast_syscall:
|
ret_fast_syscall:
|
||||||
UNWIND(.fnstart )
|
UNWIND(.fnstart )
|
||||||
UNWIND(.cantunwind )
|
UNWIND(.cantunwind )
|
||||||
str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
|
str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
|
||||||
|
#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
|
||||||
|
/* do_rseq_syscall needs interrupts enabled. */
|
||||||
|
mov r0, sp @ 'regs'
|
||||||
|
bl do_rseq_syscall
|
||||||
|
#endif
|
||||||
disable_irq_notrace @ disable interrupts
|
disable_irq_notrace @ disable interrupts
|
||||||
ldr r2, [tsk, #TI_ADDR_LIMIT]
|
ldr r2, [tsk, #TI_ADDR_LIMIT]
|
||||||
cmp r2, #TASK_SIZE
|
cmp r2, #TASK_SIZE
|
||||||
|
@ -113,6 +120,12 @@ ENDPROC(ret_fast_syscall)
|
||||||
*/
|
*/
|
||||||
ENTRY(ret_to_user)
|
ENTRY(ret_to_user)
|
||||||
ret_slow_syscall:
|
ret_slow_syscall:
|
||||||
|
#if IS_ENABLED(CONFIG_DEBUG_RSEQ)
|
||||||
|
/* do_rseq_syscall needs interrupts enabled. */
|
||||||
|
enable_irq_notrace @ enable interrupts
|
||||||
|
mov r0, sp @ 'regs'
|
||||||
|
bl do_rseq_syscall
|
||||||
|
#endif
|
||||||
disable_irq_notrace @ disable interrupts
|
disable_irq_notrace @ disable interrupts
|
||||||
ENTRY(ret_to_user_from_irq)
|
ENTRY(ret_to_user_from_irq)
|
||||||
ldr r2, [tsk, #TI_ADDR_LIMIT]
|
ldr r2, [tsk, #TI_ADDR_LIMIT]
|
||||||
|
|
|
@ -710,3 +710,10 @@ asmlinkage void addr_limit_check_failed(void)
|
||||||
{
|
{
|
||||||
addr_limit_user_check();
|
addr_limit_user_check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_RSEQ
|
||||||
|
asmlinkage void do_rseq_syscall(struct pt_regs *regs)
|
||||||
|
{
|
||||||
|
rseq_syscall(regs);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue