aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-07-08 19:00:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-07-09 13:33:26 -0400
commit7c8df28633bf0b7eb253f866029be0ac59ddb062 (patch)
treed8fba38a54a339d460026f79952cab16240e4e5a
parente8c073c4ff51207f5c1c37fb054360bbc0f38251 (diff)
ptrace: revert "Prepare to fix racy accesses on task breakpoints"
This reverts commit bf26c018490c ("Prepare to fix racy accesses on task breakpoints"). The patch was fine but we can no longer race with SIGKILL after commit 9899d11f6544 ("ptrace: ensure arch_ptrace/ptrace_request can never race with SIGKILL"), the __TASK_TRACED tracee can't be woken up and ->ptrace_bps[] can't go away. Now that ptrace_get_breakpoints/ptrace_put_breakpoints have no callers, we can kill them and remove task->ptrace_bp_refcnt. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Michael Neuling <mikey@neuling.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Jan Kratochvil <jan.kratochvil@redhat.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Will Deacon <will.deacon@arm.com> Cc: Prasad <prasad@linux.vnet.ibm.com> Cc: Russell King <linux@arm.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--include/linux/ptrace.h10
-rw-r--r--include/linux/sched.h3
-rw-r--r--kernel/exit.c2
-rw-r--r--kernel/ptrace.c16
4 files changed, 1 insertions, 30 deletions
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
index 89573a33ab3c..07d0df6bf768 100644
--- a/include/linux/ptrace.h
+++ b/include/linux/ptrace.h
@@ -142,9 +142,6 @@ static inline void ptrace_init_task(struct task_struct *child, bool ptrace)
142{ 142{
143 INIT_LIST_HEAD(&child->ptrace_entry); 143 INIT_LIST_HEAD(&child->ptrace_entry);
144 INIT_LIST_HEAD(&child->ptraced); 144 INIT_LIST_HEAD(&child->ptraced);
145#ifdef CONFIG_HAVE_HW_BREAKPOINT
146 atomic_set(&child->ptrace_bp_refcnt, 1);
147#endif
148 child->jobctl = 0; 145 child->jobctl = 0;
149 child->ptrace = 0; 146 child->ptrace = 0;
150 child->parent = child->real_parent; 147 child->parent = child->real_parent;
@@ -351,11 +348,4 @@ extern int task_current_syscall(struct task_struct *target, long *callno,
351 unsigned long args[6], unsigned int maxargs, 348 unsigned long args[6], unsigned int maxargs,
352 unsigned long *sp, unsigned long *pc); 349 unsigned long *sp, unsigned long *pc);
353 350
354#ifdef CONFIG_HAVE_HW_BREAKPOINT
355extern int ptrace_get_breakpoints(struct task_struct *tsk);
356extern void ptrace_put_breakpoints(struct task_struct *tsk);
357#else
358static inline void ptrace_put_breakpoints(struct task_struct *tsk) { }
359#endif /* CONFIG_HAVE_HW_BREAKPOINT */
360
361#endif 351#endif
diff --git a/include/linux/sched.h b/include/linux/sched.h
index cdd5407b37e2..75324d8157e3 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1401,9 +1401,6 @@ struct task_struct {
1401 } memcg_batch; 1401 } memcg_batch;
1402 unsigned int memcg_kmem_skip_account; 1402 unsigned int memcg_kmem_skip_account;
1403#endif 1403#endif
1404#ifdef CONFIG_HAVE_HW_BREAKPOINT
1405 atomic_t ptrace_bp_refcnt;
1406#endif
1407#ifdef CONFIG_UPROBES 1404#ifdef CONFIG_UPROBES
1408 struct uprobe_task *utask; 1405 struct uprobe_task *utask;
1409#endif 1406#endif
diff --git a/kernel/exit.c b/kernel/exit.c
index fafe75d9e6f6..a949819055d5 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -808,7 +808,7 @@ void do_exit(long code)
808 /* 808 /*
809 * FIXME: do that only when needed, using sched_exit tracepoint 809 * FIXME: do that only when needed, using sched_exit tracepoint
810 */ 810 */
811 ptrace_put_breakpoints(tsk); 811 flush_ptrace_hw_breakpoint(tsk);
812 812
813 exit_notify(tsk, group_dead); 813 exit_notify(tsk, group_dead);
814#ifdef CONFIG_NUMA 814#ifdef CONFIG_NUMA
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index ba5e6cea181a..a146ee327f6a 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1221,19 +1221,3 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
1221 return ret; 1221 return ret;
1222} 1222}
1223#endif /* CONFIG_COMPAT */ 1223#endif /* CONFIG_COMPAT */
1224
1225#ifdef CONFIG_HAVE_HW_BREAKPOINT
1226int ptrace_get_breakpoints(struct task_struct *tsk)
1227{
1228 if (atomic_inc_not_zero(&tsk->ptrace_bp_refcnt))
1229 return 0;
1230
1231 return -1;
1232}
1233
1234void ptrace_put_breakpoints(struct task_struct *tsk)
1235{
1236 if (atomic_dec_and_test(&tsk->ptrace_bp_refcnt))
1237 flush_ptrace_hw_breakpoint(tsk);
1238}
1239#endif /* CONFIG_HAVE_HW_BREAKPOINT */