Skip to content

Commit

Permalink
[PATCH] uml: fix advanced sysemu check
Browse files Browse the repository at this point in the history
cleanup and fix the check for advanced sysemu (PTRACE_SYSEMU_SINGLESTEP
option)

Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Bodo Stroesser authored and Linus Torvalds committed Sep 5, 2005
1 parent d9838d8 commit f9dfefe
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions arch/um/os-Linux/start_up.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ __uml_setup("nosysemu", nosysemu_cmd_param,
static void __init check_sysemu(void)
{
void *stack;
int pid, syscall, n, status, count=0;
int pid, n, status, count=0;

printk("Checking syscall emulation patch for ptrace...");
sysemu_supported = 0;
Expand Down Expand Up @@ -192,29 +192,35 @@ static void __init check_sysemu(void)

printk("Checking advanced syscall emulation patch for ptrace...");
pid = start_ptraced_child(&stack);

if(ptrace(PTRACE_OLDSETOPTIONS, pid, 0,
(void *) PTRACE_O_TRACESYSGOOD) < 0)
panic("check_ptrace: PTRACE_OLDSETOPTIONS failed, errno = %d",
errno);

while(1){
count++;
if(ptrace(PTRACE_SYSEMU_SINGLESTEP, pid, 0, 0) < 0)
goto fail;
CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
if(n < 0)
panic("check_ptrace : wait failed, errno = %d", errno);
if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP))
panic("check_ptrace : expected (SIGTRAP|SYSCALL_TRAP), "
"got status = %d", status);

syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
0);
if(syscall == __NR_getpid){
if(WIFSTOPPED(status) && (WSTOPSIG(status) == (SIGTRAP|0x80))){
if (!count)
panic("check_ptrace : SYSEMU_SINGLESTEP doesn't singlestep");
panic("check_ptrace : SYSEMU_SINGLESTEP "
"doesn't singlestep");
n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
os_getpid());
if(n < 0)
panic("check_sysemu : failed to modify system "
"call return, errno = %d", errno);
break;
}
else if(WIFSTOPPED(status) && (WSTOPSIG(status) == SIGTRAP))
count++;
else
panic("check_ptrace : expected SIGTRAP or "
"(SIGTRAP|0x80), got status = %d", status);
}
if (stop_ptraced_child(pid, stack, 0, 0) < 0)
goto fail_stopped;
Expand Down Expand Up @@ -250,8 +256,8 @@ static void __init check_ptrace(void)
CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED));
if(n < 0)
panic("check_ptrace : wait failed, errno = %d", errno);
if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP + 0x80))
panic("check_ptrace : expected SIGTRAP + 0x80, "
if(!WIFSTOPPED(status) || (WSTOPSIG(status) != (SIGTRAP|0x80)))
panic("check_ptrace : expected (SIGTRAP|0x80), "
"got status = %d", status);

syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
Expand Down

0 comments on commit f9dfefe

Please sign in to comment.