tracehooks: preparation for ptrace-utrace
Subsystems (3)
PATCH 2/3 tracehooks: preparation for ptrace-utrace
- export __ptrace_detach() and do_notify_parent_cldstop()
- change some "if (ptrace)" checks to ensure the old ptrace code is not called when the tracee is PT_UTRACED
Signed-off-by Oleg Nesterov <[email protected]>
Integrated-by Tom Zanussi <[email protected]>
--- include/linux/ptrace.h | 2 ++ include/linux/sched.h | 1 + include/linux/tracehook.h | 10 +++++----- kernel/ptrace.c | 2 +- kernel/signal.c | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-)
include/linux/ptrace.h +2 -0
@@ -99,6 +99,8 @@#include <linux/compiler.h> /* For unlikely. */ #include <linux/sched.h> /* For struct task_struct. */ +extern bool __ptrace_detach (struct task_struct *tracer, +struct task_struct *tracee);extern long arch_ptrace (struct task_struct *child,long request,unsigned long addr,unsigned long data);
include/linux/sched.h +1 -0
@@ -2141,6 +2141,7 @@ extern int kill_pgrp(struct pid *pid, int sig, int priv);extern int kill_pid (struct pid *pid,int sig,int priv);extern int kill_proc_info (int ,struct siginfo *,pid_t );extern int do_notify_parent (struct task_struct *,int ); +extern void do_notify_parent_cldstop (struct task_struct *,int );extern void __wake_up_parent (struct task_struct *p,struct task_struct *parent);extern void force_sig (int ,struct task_struct *);extern int send_sig (int ,struct task_struct *,int );
include/linux/tracehook.h +5 -5
@@ -134,7 +134,7 @@ static inline __must_check int tracehook_report_syscall_entry(*/ static inline void tracehook_report_syscall_exit (struct pt_regs *regs,int step) { -if (step) { +if (step && (task_ptrace (current) &PT_PTRACED )) {siginfo_t info;user_single_step_siginfo (current, regs, &info);force_sig_info (SIGTRAP , &info, current);
@@ -156,7 +156,7 @@ static inline int tracehook_unsafe_exec(struct task_struct *task) {int unsafe =0 ;int ptrace =task_ptrace (task); -if (ptrace &PT_PTRACED ) { +if (ptrace) {if (ptrace &PT_PTRACE_CAP ) unsafe |=LSM_UNSAFE_PTRACE_CAP ;else
@@ -178,7 +178,7 @@ static inline int tracehook_unsafe_exec(struct task_struct *task)*/ static inline struct task_struct *tracehook_tracer_task (struct task_struct *tsk) { -if (task_ptrace (tsk) &PT_PTRACED ) +if (task_ptrace (tsk))return rcu_dereference (tsk->parent);return NULL ; }
@@ -386,7 +386,7 @@ static inline void tracehook_signal_handler(int sig, siginfo_t *info,const struct k_sigaction *ka, struct pt_regs *regs, int stepping) { - if (stepping) + if (stepping && (task_ptrace(current) & PT_PTRACED)) ptrace_notify(SIGTRAP); }
@@ -492,7 +492,7 @@ static inline int tracehook_get_signal(struct task_struct *task,*/ static inline int tracehook_notify_jctl (int notify,int why) { -return notify ?: (current->ptrace &PT_PTRACED ) ? why :0 ; +return notify ?:task_ptrace (current) ? why :0 ; }/**
kernel/ptrace.c +1 -1
@@ -274,7 +274,7 @@ static int ignoring_children(struct sighand_struct *sigh)* reap it now, in that case we must also wake up sub-threads sleeping in * do_wait(). */ -static bool __ptrace_detach (struct task_struct *tracer,struct task_struct *p) +bool __ptrace_detach (struct task_struct *tracer,struct task_struct *p) {__ptrace_unlink (p);
kernel/signal.c +2 -2
@@ -1522,7 +1522,7 @@ int do_notify_parent(struct task_struct *tsk, int sig)return ret; } -static void do_notify_parent_cldstop (struct task_struct *tsk,int why) +void do_notify_parent_cldstop (struct task_struct *tsk,int why) {struct siginfo info;unsigned long flags;
@@ -1792,7 +1792,7 @@ static int do_signal_stop(int signr)static int ptrace_signal (int signr,siginfo_t *info,struct pt_regs *regs,void *cookie) { -if (!task_ptrace (current)) +if (!(task_ptrace (current) &PT_PTRACED ))return signr;ptrace_signal_deliver (regs, cookie);
Signature · 1 line
1.7.0.4