android_kernel_xiaomi_sdm845/arch
Al Viro 5329363861 alpha: fix a 14 years old bug in sigreturn tracing
The way sigreturn() is implemented on alpha breaks PTRACE_SYSCALL,
all way back to 1.3.95 when alpha has grown PTRACE_SYSCALL support.

What happens is direct return to ret_from_syscall, in order to bypass
mangling of a3 (error indicator) and prevent other mutilations of
registers (e.g. by syscall restart).  That's fine, but... the entire
TIF_SYSCALL_TRACE codepath is kept separate on alpha and post-syscall
stopping/notifying the tracer is after the syscall.  And the normal
path we are forcibly switching to doesn't have it.

So we end up with *one* stop in traced sigreturn() vs. two in other
syscalls.  And yes, strace is visibly broken by that; try to strace
the following
	#include <signal.h>
	#include <stdio.h>
	void f(int sig) {}
	main()
	{
		signal(SIGHUP, f);
		raise(SIGHUP);
		write(1, "eeeek\n", 6);
	}
and watch the show.  The
	close(1)                                = 405
in the end of strace output is coming from return value of write() (6 ==
__NR_close on alpha) and syscall number of exit_group() (__NR_exit_group ==
405 there).

The fix is fairly simple - the only thing we end up missing is the call
of syscall_trace() and we can tell whether we'd been called from the
SYSCALL_TRACE path by checking ra value.  Since we are setting the
switch_stack up (that's what sys_sigreturn() does), we have the right
environment for calling syscall_trace() - just before we call
undo_switch_stack() and return.  Since undo_switch_stack() will overwrite
s0 anyway, we can use it to store the result of "has it been called from
SYSCALL_TRACE path?" check.  The same thing applies in rt_sigreturn().

Tested-by: Michael Cree <mcree@orcon.net.nz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Matt Turner <mattst88@gmail.com>
2010-09-18 23:08:28 -04:00
..
alpha alpha: fix a 14 years old bug in sigreturn tracing 2010-09-18 23:08:28 -04:00
arm arm: fix really nasty sigreturn bug 2010-09-17 10:22:18 -07:00
avr32 Make do_execve() take a const filename pointer 2010-08-17 18:07:43 -07:00
blackfin Blackfin: bf52x/bf54x boards: drop unused nand page size 2010-08-27 16:08:43 -04:00
cris Make do_execve() take a const filename pointer 2010-08-17 18:07:43 -07:00
frv Make do_execve() take a const filename pointer 2010-08-17 18:07:43 -07:00
h8300 h8300: Fix missing consts in kernel_execve() 2010-09-07 13:52:28 -07:00
ia64 Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6 2010-09-16 12:58:44 -07:00
m32r Make do_execve() take a const filename pointer 2010-08-17 18:07:43 -07:00
m68k m68k,m68knommu: Wire up fanotify_init, fanotify_mark, and prlimit64 2010-09-13 20:28:45 +02:00
m68knommu m68k,m68knommu: Wire up fanotify_init, fanotify_mark, and prlimit64 2010-09-13 20:28:45 +02:00
microblaze Merge branch 'merge-devicetree' of git://git.secretlab.ca/git/linux-2.6 2010-08-18 09:26:17 -07:00
mips compat: Make compat_alloc_user_space() incorporate the access_ok() 2010-09-14 16:08:45 -07:00
mn10300 MN10300: Fix up the IRQ names for the on-chip serial ports 2010-09-14 17:06:28 -07:00
parisc compat: Make compat_alloc_user_space() incorporate the access_ok() 2010-09-14 16:08:45 -07:00
powerpc compat: Make compat_alloc_user_space() incorporate the access_ok() 2010-09-14 16:08:45 -07:00
s390 compat: Make compat_alloc_user_space() incorporate the access_ok() 2010-09-14 16:08:45 -07:00
score Make do_execve() take a const filename pointer 2010-08-17 18:07:43 -07:00
sh Make do_execve() take a const filename pointer 2010-08-17 18:07:43 -07:00
sparc compat: Make compat_alloc_user_space() incorporate the access_ok() 2010-09-14 16:08:45 -07:00
tile Merge branch 'stable' of git://git.kernel.org/pub/scm/linux/kernel/git/cmetcalf/linux-tile 2010-09-16 12:54:54 -07:00
um Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input 2010-08-28 13:55:31 -07:00
x86 Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip 2010-09-16 19:38:08 -07:00
xtensa Make do_execve() take a const filename pointer 2010-08-17 18:07:43 -07:00
.gitignore
Kconfig Merge branch 'perf/nmi' into perf/core 2010-08-05 08:45:05 +02:00