summaryrefslogtreecommitdiffstats
path: root/kernel/ptrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/ptrace.c')
-rw-r--r--kernel/ptrace.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 266ddcc1d8bb..60f356d91060 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -60,19 +60,25 @@ int ptrace_access_vm(struct task_struct *tsk, unsigned long addr,
60} 60}
61 61
62 62
63void __ptrace_link(struct task_struct *child, struct task_struct *new_parent,
64 const struct cred *ptracer_cred)
65{
66 BUG_ON(!list_empty(&child->ptrace_entry));
67 list_add(&child->ptrace_entry, &new_parent->ptraced);
68 child->parent = new_parent;
69 child->ptracer_cred = get_cred(ptracer_cred);
70}
71
63/* 72/*
64 * ptrace a task: make the debugger its new parent and 73 * ptrace a task: make the debugger its new parent and
65 * move it to the ptrace list. 74 * move it to the ptrace list.
66 * 75 *
67 * Must be called with the tasklist lock write-held. 76 * Must be called with the tasklist lock write-held.
68 */ 77 */
69void __ptrace_link(struct task_struct *child, struct task_struct *new_parent) 78static void ptrace_link(struct task_struct *child, struct task_struct *new_parent)
70{ 79{
71 BUG_ON(!list_empty(&child->ptrace_entry));
72 list_add(&child->ptrace_entry, &new_parent->ptraced);
73 child->parent = new_parent;
74 rcu_read_lock(); 80 rcu_read_lock();
75 child->ptracer_cred = get_cred(__task_cred(new_parent)); 81 __ptrace_link(child, new_parent, __task_cred(new_parent));
76 rcu_read_unlock(); 82 rcu_read_unlock();
77} 83}
78 84
@@ -386,7 +392,7 @@ static int ptrace_attach(struct task_struct *task, long request,
386 flags |= PT_SEIZED; 392 flags |= PT_SEIZED;
387 task->ptrace = flags; 393 task->ptrace = flags;
388 394
389 __ptrace_link(task, current); 395 ptrace_link(task, current);
390 396
391 /* SEIZE doesn't trap tracee on attach */ 397 /* SEIZE doesn't trap tracee on attach */
392 if (!seize) 398 if (!seize)
@@ -459,7 +465,7 @@ static int ptrace_traceme(void)
459 */ 465 */
460 if (!ret && !(current->real_parent->flags & PF_EXITING)) { 466 if (!ret && !(current->real_parent->flags & PF_EXITING)) {
461 current->ptrace = PT_PTRACED; 467 current->ptrace = PT_PTRACED;
462 __ptrace_link(current, current->real_parent); 468 ptrace_link(current, current->real_parent);
463 } 469 }
464 } 470 }
465 write_unlock_irq(&tasklist_lock); 471 write_unlock_irq(&tasklist_lock);