Permalink
Browse files

Don't allow the child to run unchecked between two syscalls.

We were letting the child return from fork() and run to the next
syscall. This happened to work on my system with 'less', but
segfaulted on mutt. Instead, we need to reset the child to before the
syscall point, so that none of its code is ever run.
  • Loading branch information...
1 parent 9e91662 commit 1e854b1f1a3171516cffd2ec9222b04cf69da62a @nelhage committed Jan 18, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 attach.c
View
@@ -173,7 +173,9 @@ int attach_child(pid_t pid, const char *pty) {
if (err < 0)
goto out_kill;
- if (ptrace_save_regs(&dummy)) {
+ dummy.state = ptrace_after_syscall;
+ memcpy(&dummy.user, &child.user, sizeof child.user);
+ if (ptrace_restore_regs(&dummy)) {
err = errno;
goto out_kill;
}

0 comments on commit 1e854b1

Please sign in to comment.