Commit fa157eec authored by Gerald Schaefer's avatar Gerald Schaefer Committed by Greg Kroah-Hartman

ptrace: fix return value of do_syscall_trace_enter()

commit 545c174d upstream.

strace may change the system call number, so regs->gprs[2] must not
be read before tracehook_report_syscall_entry(). This fixes a bug
where "strace -f" will hang after a vfork().
Signed-off-by: default avatarGerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ee7a0b92
...@@ -632,7 +632,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request, ...@@ -632,7 +632,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
{ {
long ret; long ret = 0;
/* Do the secure computing check first. */ /* Do the secure computing check first. */
secure_computing(regs->gprs[2]); secure_computing(regs->gprs[2]);
...@@ -641,7 +641,6 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) ...@@ -641,7 +641,6 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
* The sysc_tracesys code in entry.S stored the system * The sysc_tracesys code in entry.S stored the system
* call number to gprs[2]. * call number to gprs[2].
*/ */
ret = regs->gprs[2];
if (test_thread_flag(TIF_SYSCALL_TRACE) && if (test_thread_flag(TIF_SYSCALL_TRACE) &&
(tracehook_report_syscall_entry(regs) || (tracehook_report_syscall_entry(regs) ||
regs->gprs[2] >= NR_syscalls)) { regs->gprs[2] >= NR_syscalls)) {
...@@ -663,7 +662,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs) ...@@ -663,7 +662,7 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
regs->gprs[2], regs->orig_gpr2, regs->gprs[2], regs->orig_gpr2,
regs->gprs[3], regs->gprs[4], regs->gprs[3], regs->gprs[4],
regs->gprs[5]); regs->gprs[5]);
return ret; return ret ?: regs->gprs[2];
} }
asmlinkage void do_syscall_trace_exit(struct pt_regs *regs) asmlinkage void do_syscall_trace_exit(struct pt_regs *regs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment