aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ptrace.h11
-rw-r--r--include/linux/tracehook.h16
-rw-r--r--kernel/exit.c8
-rw-r--r--kernel/signal.c14
-rw-r--r--mm/oom_kill.c3
5 files changed, 20 insertions, 32 deletions
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 4f224f169524..3ff20b322598 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -146,17 +146,6 @@ int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
146 unsigned long data); 146 unsigned long data);
147 147
148/** 148/**
149 * task_ptrace - return %PT_* flags that apply to a task
150 * @task: pointer to &task_struct in question
151 *
152 * Returns the %PT_* flags that apply to @task.
153 */
154static inline int task_ptrace(struct task_struct *task)
155{
156 return task->ptrace;
157}
158
159/**
160 * ptrace_event - possibly stop for a ptrace event notification 149 * ptrace_event - possibly stop for a ptrace event notification
161 * @mask: %PT_* bit to check in @current->ptrace 150 * @mask: %PT_* bit to check in @current->ptrace
162 * @event: %PTRACE_EVENT_* value to report if @mask is set 151 * @event: %PTRACE_EVENT_* value to report if @mask is set
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 15745cdd32ce..a3e838784f43 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -63,7 +63,7 @@ struct linux_binprm;
63 */ 63 */
64static inline int tracehook_expect_breakpoints(struct task_struct *task) 64static inline int tracehook_expect_breakpoints(struct task_struct *task)
65{ 65{
66 return (task_ptrace(task) & PT_PTRACED) != 0; 66 return (task->ptrace & PT_PTRACED) != 0;
67} 67}
68 68
69/* 69/*
@@ -71,7 +71,7 @@ static inline int tracehook_expect_breakpoints(struct task_struct *task)
71 */ 71 */
72static inline void ptrace_report_syscall(struct pt_regs *regs) 72static inline void ptrace_report_syscall(struct pt_regs *regs)
73{ 73{
74 int ptrace = task_ptrace(current); 74 int ptrace = current->ptrace;
75 75
76 if (!(ptrace & PT_PTRACED)) 76 if (!(ptrace & PT_PTRACED))
77 return; 77 return;
@@ -155,7 +155,7 @@ static inline void tracehook_report_syscall_exit(struct pt_regs *regs, int step)
155static inline int tracehook_unsafe_exec(struct task_struct *task) 155static inline int tracehook_unsafe_exec(struct task_struct *task)
156{ 156{
157 int unsafe = 0; 157 int unsafe = 0;
158 int ptrace = task_ptrace(task); 158 int ptrace = task->ptrace;
159 if (ptrace & PT_PTRACED) { 159 if (ptrace & PT_PTRACED) {
160 if (ptrace & PT_PTRACE_CAP) 160 if (ptrace & PT_PTRACE_CAP)
161 unsafe |= LSM_UNSAFE_PTRACE_CAP; 161 unsafe |= LSM_UNSAFE_PTRACE_CAP;
@@ -178,7 +178,7 @@ static inline int tracehook_unsafe_exec(struct task_struct *task)
178 */ 178 */
179static inline struct task_struct *tracehook_tracer_task(struct task_struct *tsk) 179static inline struct task_struct *tracehook_tracer_task(struct task_struct *tsk)
180{ 180{
181 if (task_ptrace(tsk) & PT_PTRACED) 181 if (tsk->ptrace & PT_PTRACED)
182 return rcu_dereference(tsk->parent); 182 return rcu_dereference(tsk->parent);
183 return NULL; 183 return NULL;
184} 184}
@@ -202,7 +202,7 @@ static inline void tracehook_report_exec(struct linux_binfmt *fmt,
202 struct pt_regs *regs) 202 struct pt_regs *regs)
203{ 203{
204 if (!ptrace_event(PT_TRACE_EXEC, PTRACE_EVENT_EXEC, 0) && 204 if (!ptrace_event(PT_TRACE_EXEC, PTRACE_EVENT_EXEC, 0) &&
205 unlikely(task_ptrace(current) & PT_PTRACED)) 205 unlikely(current->ptrace & PT_PTRACED))
206 send_sig(SIGTRAP, current, 0); 206 send_sig(SIGTRAP, current, 0);
207} 207}
208 208
@@ -285,7 +285,7 @@ static inline void tracehook_report_clone(struct pt_regs *regs,
285 unsigned long clone_flags, 285 unsigned long clone_flags,
286 pid_t pid, struct task_struct *child) 286 pid_t pid, struct task_struct *child)
287{ 287{
288 if (unlikely(task_ptrace(child))) { 288 if (unlikely(child->ptrace)) {
289 /* 289 /*
290 * It doesn't matter who attached/attaching to this 290 * It doesn't matter who attached/attaching to this
291 * task, the pending SIGSTOP is right in any case. 291 * task, the pending SIGSTOP is right in any case.
@@ -403,7 +403,7 @@ static inline void tracehook_signal_handler(int sig, siginfo_t *info,
403static inline int tracehook_consider_ignored_signal(struct task_struct *task, 403static inline int tracehook_consider_ignored_signal(struct task_struct *task,
404 int sig) 404 int sig)
405{ 405{
406 return (task_ptrace(task) & PT_PTRACED) != 0; 406 return (task->ptrace & PT_PTRACED) != 0;
407} 407}
408 408
409/** 409/**
@@ -422,7 +422,7 @@ static inline int tracehook_consider_ignored_signal(struct task_struct *task,
422static inline int tracehook_consider_fatal_signal(struct task_struct *task, 422static inline int tracehook_consider_fatal_signal(struct task_struct *task,
423 int sig) 423 int sig)
424{ 424{
425 return (task_ptrace(task) & PT_PTRACED) != 0; 425 return (task->ptrace & PT_PTRACED) != 0;
426} 426}
427 427
428#define DEATH_REAP -1 428#define DEATH_REAP -1
diff --git a/kernel/exit.c b/kernel/exit.c
index 289f59d686bf..e5cc05644609 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -765,7 +765,7 @@ static void reparent_leader(struct task_struct *father, struct task_struct *p,
765 p->exit_signal = SIGCHLD; 765 p->exit_signal = SIGCHLD;
766 766
767 /* If it has exited notify the new parent about this child's death. */ 767 /* If it has exited notify the new parent about this child's death. */
768 if (!task_ptrace(p) && 768 if (!p->ptrace &&
769 p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) { 769 p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) {
770 do_notify_parent(p, p->exit_signal); 770 do_notify_parent(p, p->exit_signal);
771 if (task_detached(p)) { 771 if (task_detached(p)) {
@@ -795,7 +795,7 @@ static void forget_original_parent(struct task_struct *father)
795 do { 795 do {
796 t->real_parent = reaper; 796 t->real_parent = reaper;
797 if (t->parent == father) { 797 if (t->parent == father) {
798 BUG_ON(task_ptrace(t)); 798 BUG_ON(t->ptrace);
799 t->parent = t->real_parent; 799 t->parent = t->real_parent;
800 } 800 }
801 if (t->pdeath_signal) 801 if (t->pdeath_signal)
@@ -1565,7 +1565,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
1565 * Notification and reaping will be cascaded to the real 1565 * Notification and reaping will be cascaded to the real
1566 * parent when the ptracer detaches. 1566 * parent when the ptracer detaches.
1567 */ 1567 */
1568 if (likely(!ptrace) && unlikely(task_ptrace(p))) { 1568 if (likely(!ptrace) && unlikely(p->ptrace)) {
1569 /* it will become visible, clear notask_error */ 1569 /* it will become visible, clear notask_error */
1570 wo->notask_error = 0; 1570 wo->notask_error = 0;
1571 return 0; 1571 return 0;
@@ -1608,7 +1608,7 @@ static int wait_consider_task(struct wait_opts *wo, int ptrace,
1608 * own children, it should create a separate process which 1608 * own children, it should create a separate process which
1609 * takes the role of real parent. 1609 * takes the role of real parent.
1610 */ 1610 */
1611 if (likely(!ptrace) && task_ptrace(p) && 1611 if (likely(!ptrace) && p->ptrace &&
1612 same_thread_group(p->parent, p->real_parent)) 1612 same_thread_group(p->parent, p->real_parent))
1613 return 0; 1613 return 0;
1614 1614
diff --git a/kernel/signal.c b/kernel/signal.c
index 97e575a3387e..0f3370872506 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1592,7 +1592,7 @@ int do_notify_parent(struct task_struct *tsk, int sig)
1592 /* do_notify_parent_cldstop should have been called instead. */ 1592 /* do_notify_parent_cldstop should have been called instead. */
1593 BUG_ON(task_is_stopped_or_traced(tsk)); 1593 BUG_ON(task_is_stopped_or_traced(tsk));
1594 1594
1595 BUG_ON(!task_ptrace(tsk) && 1595 BUG_ON(!tsk->ptrace &&
1596 (tsk->group_leader != tsk || !thread_group_empty(tsk))); 1596 (tsk->group_leader != tsk || !thread_group_empty(tsk)));
1597 1597
1598 info.si_signo = sig; 1598 info.si_signo = sig;
@@ -1631,7 +1631,7 @@ int do_notify_parent(struct task_struct *tsk, int sig)
1631 1631
1632 psig = tsk->parent->sighand; 1632 psig = tsk->parent->sighand;
1633 spin_lock_irqsave(&psig->siglock, flags); 1633 spin_lock_irqsave(&psig->siglock, flags);
1634 if (!task_ptrace(tsk) && sig == SIGCHLD && 1634 if (!tsk->ptrace && sig == SIGCHLD &&
1635 (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN || 1635 (psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN ||
1636 (psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))) { 1636 (psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))) {
1637 /* 1637 /*
@@ -1731,7 +1731,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
1731 1731
1732static inline int may_ptrace_stop(void) 1732static inline int may_ptrace_stop(void)
1733{ 1733{
1734 if (!likely(task_ptrace(current))) 1734 if (!likely(current->ptrace))
1735 return 0; 1735 return 0;
1736 /* 1736 /*
1737 * Are we in the middle of do_coredump? 1737 * Are we in the middle of do_coredump?
@@ -1989,7 +1989,7 @@ static bool do_signal_stop(int signr)
1989 if (!(sig->flags & SIGNAL_STOP_STOPPED)) 1989 if (!(sig->flags & SIGNAL_STOP_STOPPED))
1990 sig->group_exit_code = signr; 1990 sig->group_exit_code = signr;
1991 else 1991 else
1992 WARN_ON_ONCE(!task_ptrace(current)); 1992 WARN_ON_ONCE(!current->ptrace);
1993 1993
1994 sig->group_stop_count = 0; 1994 sig->group_stop_count = 0;
1995 1995
@@ -2014,7 +2014,7 @@ static bool do_signal_stop(int signr)
2014 } 2014 }
2015 } 2015 }
2016 2016
2017 if (likely(!task_ptrace(current))) { 2017 if (likely(!current->ptrace)) {
2018 int notify = 0; 2018 int notify = 0;
2019 2019
2020 /* 2020 /*
@@ -2093,7 +2093,7 @@ static void do_jobctl_trap(void)
2093static int ptrace_signal(int signr, siginfo_t *info, 2093static int ptrace_signal(int signr, siginfo_t *info,
2094 struct pt_regs *regs, void *cookie) 2094 struct pt_regs *regs, void *cookie)
2095{ 2095{
2096 if (!task_ptrace(current)) 2096 if (!current->ptrace)
2097 return signr; 2097 return signr;
2098 2098
2099 ptrace_signal_deliver(regs, cookie); 2099 ptrace_signal_deliver(regs, cookie);
@@ -2179,7 +2179,7 @@ relock:
2179 do_notify_parent_cldstop(current, false, why); 2179 do_notify_parent_cldstop(current, false, why);
2180 2180
2181 leader = current->group_leader; 2181 leader = current->group_leader;
2182 if (task_ptrace(leader) && !real_parent_is_ptracer(leader)) 2182 if (leader->ptrace && !real_parent_is_ptracer(leader))
2183 do_notify_parent_cldstop(leader, true, why); 2183 do_notify_parent_cldstop(leader, true, why);
2184 2184
2185 read_unlock(&tasklist_lock); 2185 read_unlock(&tasklist_lock);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index e4b0991ca351..b0be989d4365 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -339,8 +339,7 @@ static struct task_struct *select_bad_process(unsigned int *ppoints,
339 * then wait for it to finish before killing 339 * then wait for it to finish before killing
340 * some other task unnecessarily. 340 * some other task unnecessarily.
341 */ 341 */
342 if (!(task_ptrace(p->group_leader) & 342 if (!(p->group_leader->ptrace & PT_TRACE_EXIT))
343 PT_TRACE_EXIT))
344 return ERR_PTR(-1UL); 343 return ERR_PTR(-1UL);
345 } 344 }
346 } 345 }