]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
ptrace: change tracehook_report_syscall_exit() to handle stepping
authorOleg Nesterov <oleg@redhat.com>
Wed, 16 Dec 2009 00:47:19 +0000 (16:47 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 16 Dec 2009 15:20:08 +0000 (07:20 -0800)
commit2f0edac5555983dc28033acce8a355f588fd01b2
treea17d83571df83ca0a09bd048f01e8d9d2e9bbff7
parent25baa35befeebe6a4a8d8d12a4fc5b95918bda54
ptrace: change tracehook_report_syscall_exit() to handle stepping

Suggested by Roland.

Change tracehook_report_syscall_exit() to look at step flag and send the
trap signal if needed.

This change affects ia64, microblaze, parisc, powerpc, sh.  They pass
nonzero "step" argument to tracehook but since it was ignored the tracee
reports via ptrace_notify(), this is not right and not consistent.

- PTRACE_SETSIGINFO doesn't work

- if the tracer resumes the tracee with signr != 0 the new signal
  is generated rather than delivering it

- If PT_TRACESYSGOOD is set the tracee reports the wrong exit_code

I don't have a powerpc machine, but I think this test-case should see the
difference:

#include <unistd.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <assert.h>
#include <stdio.h>

int main(void)
{
int pid, status;

if (!(pid = fork())) {
assert(ptrace(PTRACE_TRACEME) == 0);
kill(getpid(), SIGSTOP);

getppid();

return 0;
}

assert(pid == wait(&status));
assert(ptrace(PTRACE_SETOPTIONS, pid, 0, PTRACE_O_TRACESYSGOOD) == 0);

assert(ptrace(PTRACE_SYSCALL, pid, 0,0) == 0);
assert(pid == wait(&status));

assert(ptrace(PTRACE_SINGLESTEP, pid, 0,0) == 0);
assert(pid == wait(&status));

if (status == 0x57F)
return 0;

printf("kernel bug: status=%X shouldn't have 0x80\n", status);
return 1;
}

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Roland McGrath <roland@redhat.com>
Cc: <linux-arch@vger.kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/tracehook.h