Lines Matching full:child

41 void __ptrace_link(struct task_struct *child, struct task_struct *new_parent)  in __ptrace_link()  argument
43 BUG_ON(!list_empty(&child->ptrace_entry)); in __ptrace_link()
44 list_add(&child->ptrace_entry, &new_parent->ptraced); in __ptrace_link()
45 child->parent = new_parent; in __ptrace_link()
50 * @child: ptracee to be unlinked
52 * Remove @child from the ptrace list, move it back to the original parent,
76 void __ptrace_unlink(struct task_struct *child) in __ptrace_unlink() argument
78 BUG_ON(!child->ptrace); in __ptrace_unlink()
80 child->ptrace = 0; in __ptrace_unlink()
81 child->parent = child->real_parent; in __ptrace_unlink()
82 list_del_init(&child->ptrace_entry); in __ptrace_unlink()
84 spin_lock(&child->sighand->siglock); in __ptrace_unlink()
90 task_clear_jobctl_pending(child, JOBCTL_TRAP_MASK); in __ptrace_unlink()
91 task_clear_jobctl_trapping(child); in __ptrace_unlink()
95 * @child isn't dead. in __ptrace_unlink()
97 if (!(child->flags & PF_EXITING) && in __ptrace_unlink()
98 (child->signal->flags & SIGNAL_STOP_STOPPED || in __ptrace_unlink()
99 child->signal->group_stop_count)) { in __ptrace_unlink()
100 child->jobctl |= JOBCTL_STOP_PENDING; in __ptrace_unlink()
109 if (!(child->jobctl & JOBCTL_STOP_SIGMASK)) in __ptrace_unlink()
110 child->jobctl |= SIGSTOP; in __ptrace_unlink()
115 * @child in the butt. Note that @resume should be used iff @child in __ptrace_unlink()
119 if (child->jobctl & JOBCTL_STOP_PENDING || task_is_traced(child)) in __ptrace_unlink()
120 signal_wake_up(child, task_is_traced(child)); in __ptrace_unlink()
122 spin_unlock(&child->sighand->siglock); in __ptrace_unlink()
127 * @child: ptracee to check for
128 * @ignore_state: don't check whether @child is currently %TASK_TRACED
130 * Check whether @child is being ptraced by %current and ready for further
131 * ptrace operations. If @ignore_state is %false, @child also should be in
132 * %TASK_TRACED state and on return the child is guaranteed to be traced
133 * and not executing. If @ignore_state is %true, @child can be in any
137 * Grabs and releases tasklist_lock and @child->sighand->siglock.
140 * 0 on success, -ESRCH if %child is not ready.
142 int ptrace_check_attach(struct task_struct *child, bool ignore_state) in ptrace_check_attach() argument
148 * possible race where someone else was tracing our child and in ptrace_check_attach()
150 * we are sure that this is our traced child and that can only in ptrace_check_attach()
154 if ((child->ptrace & PT_PTRACED) && child->parent == current) { in ptrace_check_attach()
156 * child->sighand can't be NULL, release_task() in ptrace_check_attach()
159 spin_lock_irq(&child->sighand->siglock); in ptrace_check_attach()
160 WARN_ON_ONCE(task_is_stopped(child)); in ptrace_check_attach()
161 if (ignore_state || (task_is_traced(child) && in ptrace_check_attach()
162 !(child->jobctl & JOBCTL_LISTENING))) in ptrace_check_attach()
164 spin_unlock_irq(&child->sighand->siglock); in ptrace_check_attach()
169 ret = wait_task_inactive(child, TASK_TRACED) ? 0 : -ESRCH; in ptrace_check_attach()
192 * because setting up the necessary parent/child relationship in __ptrace_may_access()
302 * will be cleared if the child completes the transition or any in ptrace_attach()
389 * If it's our own child, there is no notification to do. But if our normal
390 * children self-reap, then this child was prevented by ptrace and we must
419 static int ptrace_detach(struct task_struct *child, unsigned int data) in ptrace_detach() argument
427 ptrace_disable(child); in ptrace_detach()
428 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); in ptrace_detach()
432 * This child can be already killed. Make sure de_thread() or in ptrace_detach()
435 if (child->ptrace) { in ptrace_detach()
436 child->exit_code = data; in ptrace_detach()
437 dead = __ptrace_detach(current, child); in ptrace_detach()
441 proc_ptrace_connector(child, PTRACE_DETACH); in ptrace_detach()
443 release_task(child); in ptrace_detach()
529 static int ptrace_setoptions(struct task_struct *child, unsigned long data) in ptrace_setoptions() argument
531 child->ptrace &= ~PT_TRACE_MASK; in ptrace_setoptions()
534 child->ptrace |= PT_TRACESYSGOOD; in ptrace_setoptions()
537 child->ptrace |= PT_TRACE_FORK; in ptrace_setoptions()
540 child->ptrace |= PT_TRACE_VFORK; in ptrace_setoptions()
543 child->ptrace |= PT_TRACE_CLONE; in ptrace_setoptions()
546 child->ptrace |= PT_TRACE_EXEC; in ptrace_setoptions()
549 child->ptrace |= PT_TRACE_VFORK_DONE; in ptrace_setoptions()
552 child->ptrace |= PT_TRACE_EXIT; in ptrace_setoptions()
557 static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info) in ptrace_getsiginfo() argument
562 if (lock_task_sighand(child, &flags)) { in ptrace_getsiginfo()
564 if (likely(child->last_siginfo != NULL)) { in ptrace_getsiginfo()
565 *info = *child->last_siginfo; in ptrace_getsiginfo()
568 unlock_task_sighand(child, &flags); in ptrace_getsiginfo()
573 static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info) in ptrace_setsiginfo() argument
578 if (lock_task_sighand(child, &flags)) { in ptrace_setsiginfo()
580 if (likely(child->last_siginfo != NULL)) { in ptrace_setsiginfo()
581 *child->last_siginfo = *info; in ptrace_setsiginfo()
584 unlock_task_sighand(child, &flags); in ptrace_setsiginfo()
608 static int ptrace_resume(struct task_struct *child, long request, in ptrace_resume() argument
615 set_tsk_thread_flag(child, TIF_SYSCALL_TRACE); in ptrace_resume()
617 clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE); in ptrace_resume()
621 set_tsk_thread_flag(child, TIF_SYSCALL_EMU); in ptrace_resume()
623 clear_tsk_thread_flag(child, TIF_SYSCALL_EMU); in ptrace_resume()
629 user_enable_block_step(child); in ptrace_resume()
633 user_enable_single_step(child); in ptrace_resume()
635 user_disable_single_step(child); in ptrace_resume()
638 child->exit_code = data; in ptrace_resume()
639 wake_up_state(child, __TASK_TRACED); in ptrace_resume()
685 int ptrace_request(struct task_struct *child, long request, in ptrace_request() argument
688 bool seized = child->ptrace & PT_SEIZED; in ptrace_request()
698 return generic_ptrace_peekdata(child, addr, data); in ptrace_request()
701 return generic_ptrace_pokedata(child, addr, data); in ptrace_request()
707 ret = ptrace_setoptions(child, data); in ptrace_request()
710 ret = put_user(child->ptrace_message, datalp); in ptrace_request()
714 ret = ptrace_getsiginfo(child, &siginfo); in ptrace_request()
723 ret = ptrace_setsiginfo(child, &siginfo); in ptrace_request()
730 * after this request. If @child is already trapped, the in ptrace_request()
737 if (unlikely(!seized || !lock_task_sighand(child, &flags))) in ptrace_request()
746 if (likely(task_set_jobctl_pending(child, JOBCTL_TRAP_STOP))) in ptrace_request()
747 signal_wake_up(child, child->jobctl & JOBCTL_LISTENING); in ptrace_request()
749 unlock_task_sighand(child, &flags); in ptrace_request()
762 if (unlikely(!seized || !lock_task_sighand(child, &flags))) in ptrace_request()
765 si = child->last_siginfo; in ptrace_request()
767 child->jobctl |= JOBCTL_LISTENING; in ptrace_request()
772 if (child->jobctl & JOBCTL_TRAP_NOTIFY) in ptrace_request()
773 signal_wake_up(child, true); in ptrace_request()
776 unlock_task_sighand(child, &flags); in ptrace_request()
780 ret = ptrace_detach(child, data); in ptrace_request()
785 struct mm_struct *mm = get_task_mm(child); in ptrace_request()
821 return ptrace_resume(child, request, data); in ptrace_request()
824 if (child->exit_state) /* already dead */ in ptrace_request()
826 return ptrace_resume(child, request, SIGKILL); in ptrace_request()
842 ret = ptrace_regset(child, request, addr, &kiov); in ptrace_request()
857 struct task_struct *child; in ptrace_get_task_struct() local
860 child = find_task_by_vpid(pid); in ptrace_get_task_struct()
861 if (child) in ptrace_get_task_struct()
862 get_task_struct(child); in ptrace_get_task_struct()
865 if (!child) in ptrace_get_task_struct()
867 return child; in ptrace_get_task_struct()
871 #define arch_ptrace_attach(child) do { } while (0) argument
877 struct task_struct *child; in SYSCALL_DEFINE4() local
887 child = ptrace_get_task_struct(pid); in SYSCALL_DEFINE4()
888 if (IS_ERR(child)) { in SYSCALL_DEFINE4()
889 ret = PTR_ERR(child); in SYSCALL_DEFINE4()
894 ret = ptrace_attach(child, request, data); in SYSCALL_DEFINE4()
900 arch_ptrace_attach(child); in SYSCALL_DEFINE4()
904 ret = ptrace_check_attach(child, request == PTRACE_KILL || in SYSCALL_DEFINE4()
909 ret = arch_ptrace(child, request, addr, data); in SYSCALL_DEFINE4()
912 put_task_struct(child); in SYSCALL_DEFINE4()
941 int compat_ptrace_request(struct task_struct *child, compat_long_t request, in compat_ptrace_request() argument
952 ret = access_process_vm(child, addr, &word, sizeof(word), 0); in compat_ptrace_request()
961 ret = access_process_vm(child, addr, &data, sizeof(data), 1); in compat_ptrace_request()
966 ret = put_user((compat_ulong_t) child->ptrace_message, datap); in compat_ptrace_request()
970 ret = ptrace_getsiginfo(child, &siginfo); in compat_ptrace_request()
983 ret = ptrace_setsiginfo(child, &siginfo); in compat_ptrace_request()
1005 ret = ptrace_regset(child, request, addr, &kiov); in compat_ptrace_request()
1013 ret = ptrace_request(child, request, addr, data); in compat_ptrace_request()
1022 struct task_struct *child; in compat_sys_ptrace() local
1030 child = ptrace_get_task_struct(pid); in compat_sys_ptrace()
1031 if (IS_ERR(child)) { in compat_sys_ptrace()
1032 ret = PTR_ERR(child); in compat_sys_ptrace()
1037 ret = ptrace_attach(child, request, data); in compat_sys_ptrace()
1043 arch_ptrace_attach(child); in compat_sys_ptrace()
1047 ret = ptrace_check_attach(child, request == PTRACE_KILL || in compat_sys_ptrace()
1050 ret = compat_arch_ptrace(child, request, addr, data); in compat_sys_ptrace()
1053 put_task_struct(child); in compat_sys_ptrace()