Skip to content

Commit

Permalink
ptrace: the killed tracee should not enter the syscall
Browse files Browse the repository at this point in the history
Another old/known problem.  If the tracee is killed after it reports
syscall_entry, it starts the syscall and debugger can't control this.
This confuses the users and this creates the security problems for
ptrace jailers.

Change tracehook_report_syscall_entry() to return non-zero if killed,
this instructs syscall_trace_enter() to abort the syscall.

Reported-by: Chris Evans <scarybeasts@gmail.com>
Tested-by: Indan Zupancic <indan@nul.nu>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Pedro Alves <palves@redhat.com>
Cc: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Oleg Nesterov authored and Linus Torvalds committed Mar 23, 2012
1 parent d533df0 commit 15cab95
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions include/linux/tracehook.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ struct linux_binprm;
/*
* ptrace report for syscall entry and exit looks identical.
*/
static inline void ptrace_report_syscall(struct pt_regs *regs)
static inline int ptrace_report_syscall(struct pt_regs *regs)
{
int ptrace = current->ptrace;

if (!(ptrace & PT_PTRACED))
return;
return 0;

ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));

Expand All @@ -72,6 +72,8 @@ static inline void ptrace_report_syscall(struct pt_regs *regs)
send_sig(current->exit_code, current, 1);
current->exit_code = 0;
}

return fatal_signal_pending(current);
}

/**
Expand All @@ -96,8 +98,7 @@ static inline void ptrace_report_syscall(struct pt_regs *regs)
static inline __must_check int tracehook_report_syscall_entry(
struct pt_regs *regs)
{
ptrace_report_syscall(regs);
return 0;
return ptrace_report_syscall(regs);
}

/**
Expand Down

0 comments on commit 15cab95

Please sign in to comment.