From 07bc84b75a5e24359507576e0f172a1c2a67e486 Mon Sep 17 00:00:00 2001 From: Nick Alcock Date: Thu, 13 Aug 2015 16:47:50 +0100 Subject: [PATCH] dtrace: prevent the stack protector from breaking syscall tracing. The systrace_syscall() function is unusual in that it requires %rax to be conserved in the function prologue (until the volatile asm which collects the syscall number from it and sticks it in a local variable). GCC doesn't know about this, and recent GCC has started smashing it with the stack protector prologue. Fix this by turning off stack protection in this one function (which does not benefit from it anyway -- it contains only two assignments, neither of which can overrun -- and is a notable hot spot). Also declare it asmlinkage, like every other syscall already is: it is called from asm, just like them. Orabug: 21630345 Signed-off-by: Nick Alcock Acked-by: Kris Van Hees --- arch/x86/kernel/dtrace_syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/dtrace_syscall.c b/arch/x86/kernel/dtrace_syscall.c index 21a8dd806a24..d18e638e30fd 100644 --- a/arch/x86/kernel/dtrace_syscall.c +++ b/arch/x86/kernel/dtrace_syscall.c @@ -69,8 +69,12 @@ static systrace_info_t systrace_info = }; -long systrace_syscall(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2, - uintptr_t arg3, uintptr_t arg4, uintptr_t arg5) +/* + * The stack protector has a tendency to clobber %rax in the prologue. + */ +__attribute__((__optimize__("no-stack-protector"))) +asmlinkage long systrace_syscall(uintptr_t arg0, uintptr_t arg1, uintptr_t arg2, + uintptr_t arg3, uintptr_t arg4, uintptr_t arg5) { long rc = 0; unsigned long sysnum; -- 2.50.1