]> Git Repo - linux.git/commitdiff
ptrace: the killed tracee should not enter the syscall
authorOleg Nesterov <[email protected]>
Fri, 23 Mar 2012 22:02:39 +0000 (15:02 -0700)
committerLinus Torvalds <[email protected]>
Fri, 23 Mar 2012 23:58:40 +0000 (16:58 -0700)
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 <[email protected]>
Tested-by: Indan Zupancic <[email protected]>
Signed-off-by: Oleg Nesterov <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Pedro Alves <[email protected]>
Cc: Jan Kratochvil <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/tracehook.h

index a71a2927a6a094831c1c71140c314258c3dc9950..51bd91d911c3b3233e90301a4092a84750827776 100644 (file)
@@ -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));
 
@@ -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);
 }
 
 /**
@@ -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);
 }
 
 /**
This page took 0.047653 seconds and 4 git commands to generate.