Lines Matching refs:child

69 void __ptrace_link(struct task_struct *child, struct task_struct *new_parent,
72 BUG_ON(!list_empty(&child->ptrace_entry));
73 list_add(&child->ptrace_entry, &new_parent->ptraced);
74 child->parent = new_parent;
75 child->ptracer_cred = get_cred(ptracer_cred);
84 static void ptrace_link(struct task_struct *child, struct task_struct *new_parent)
86 __ptrace_link(child, new_parent, current_cred());
91 * @child: ptracee to be unlinked
93 * Remove @child from the ptrace list, move it back to the original parent,
117 void __ptrace_unlink(struct task_struct *child)
120 BUG_ON(!child->ptrace);
122 clear_task_syscall_work(child, SYSCALL_TRACE);
124 clear_task_syscall_work(child, SYSCALL_EMU);
127 child->parent = child->real_parent;
128 list_del_init(&child->ptrace_entry);
129 old_cred = child->ptracer_cred;
130 child->ptracer_cred = NULL;
133 spin_lock(&child->sighand->siglock);
134 child->ptrace = 0;
139 task_clear_jobctl_pending(child, JOBCTL_TRAP_MASK);
140 task_clear_jobctl_trapping(child);
144 * @child isn't dead.
146 if (!(child->flags & PF_EXITING) &&
147 (child->signal->flags & SIGNAL_STOP_STOPPED ||
148 child->signal->group_stop_count))
149 child->jobctl |= JOBCTL_STOP_PENDING;
153 * @child in the butt. Note that @resume should be used iff @child
157 if (child->jobctl & JOBCTL_STOP_PENDING || task_is_traced(child))
158 ptrace_signal_wake_up(child, true);
160 spin_unlock(&child->sighand->siglock);
208 * The child may be awake and may have cleared
209 * JOBCTL_PTRACE_FROZEN (see ptrace_resume). The child will
224 * @child: ptracee to check for
225 * @ignore_state: don't check whether @child is currently %TASK_TRACED
227 * Check whether @child is being ptraced by %current and ready for further
228 * ptrace operations. If @ignore_state is %false, @child also should be in
229 * %TASK_TRACED state and on return the child is guaranteed to be traced
230 * and not executing. If @ignore_state is %true, @child can be in any
234 * Grabs and releases tasklist_lock and @child->sighand->siglock.
237 * 0 on success, -ESRCH if %child is not ready.
239 static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
245 * possible race where someone else was tracing our child and
247 * we are sure that this is our traced child and that can only
251 if (child->ptrace && child->parent == current) {
253 * child->sighand can't be NULL, release_task()
256 if (ignore_state || ptrace_freeze_traced(child))
262 WARN_ON_ONCE(!wait_task_inactive(child, __TASK_TRACED|TASK_FROZEN)))
293 * because setting up the necessary parent/child relationship
388 * will be cleared if the child completes the transition or any
533 * If it's our own child, there is no notification to do. But if our normal
534 * children self-reap, then this child was prevented by ptrace and we must
563 static int ptrace_detach(struct task_struct *child, unsigned int data)
569 ptrace_disable(child);
576 WARN_ON(!child->ptrace || child->exit_state);
581 child->exit_code = data;
582 __ptrace_detach(current, child);
585 proc_ptrace_connector(child, PTRACE_DETACH);
659 static int ptrace_setoptions(struct task_struct *child, unsigned long data)
669 flags = child->ptrace;
672 child->ptrace = flags;
677 static int ptrace_getsiginfo(struct task_struct *child, kernel_siginfo_t *info)
682 if (lock_task_sighand(child, &flags)) {
684 if (likely(child->last_siginfo != NULL)) {
685 copy_siginfo(info, child->last_siginfo);
688 unlock_task_sighand(child, &flags);
693 static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *info)
698 if (lock_task_sighand(child, &flags)) {
700 if (likely(child->last_siginfo != NULL)) {
701 copy_siginfo(child->last_siginfo, info);
704 unlock_task_sighand(child, &flags);
709 static int ptrace_peek_siginfo(struct task_struct *child,
734 pending = &child->signal->shared_pending;
736 pending = &child->pending;
743 spin_lock_irq(&child->sighand->siglock);
751 spin_unlock_irq(&child->sighand->siglock);
823 static int ptrace_resume(struct task_struct *child, long request,
830 set_task_syscall_work(child, SYSCALL_TRACE);
832 clear_task_syscall_work(child, SYSCALL_TRACE);
836 set_task_syscall_work(child, SYSCALL_EMU);
838 clear_task_syscall_work(child, SYSCALL_EMU);
844 user_enable_block_step(child);
848 user_enable_single_step(child);
850 user_disable_single_step(child);
862 spin_lock_irq(&child->sighand->siglock);
863 child->exit_code = data;
864 child->jobctl &= ~JOBCTL_TRACED;
865 wake_up_state(child, __TASK_TRACED);
866 spin_unlock_irq(&child->sighand->siglock);
918 ptrace_get_syscall_info_entry(struct task_struct *child, struct pt_regs *regs,
925 info->entry.nr = syscall_get_nr(child, regs);
926 syscall_get_arguments(child, regs, args);
935 ptrace_get_syscall_info_seccomp(struct task_struct *child, struct pt_regs *regs,
945 ptrace_get_syscall_info_entry(child, regs, info);
947 info->seccomp.ret_data = child->ptrace_message;
954 ptrace_get_syscall_info_exit(struct task_struct *child, struct pt_regs *regs,
958 info->exit.rval = syscall_get_error(child, regs);
961 info->exit.rval = syscall_get_return_value(child, regs);
968 ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
971 struct pt_regs *regs = task_pt_regs(child);
974 .arch = syscall_get_arch(child),
983 * child->last_siginfo because ptrace_freeze_traced()
987 switch (child->last_siginfo ? child->last_siginfo->si_code : 0) {
989 switch (child->ptrace_message) {
991 actual_size = ptrace_get_syscall_info_entry(child, regs,
995 actual_size = ptrace_get_syscall_info_exit(child, regs,
1001 actual_size = ptrace_get_syscall_info_seccomp(child, regs,
1011 int ptrace_request(struct task_struct *child, long request,
1014 bool seized = child->ptrace & PT_SEIZED;
1024 return generic_ptrace_peekdata(child, addr, data);
1027 return generic_ptrace_pokedata(child, addr, data);
1033 ret = ptrace_setoptions(child, data);
1036 ret = put_user(child->ptrace_message, datalp);
1040 ret = ptrace_peek_siginfo(child, addr, data);
1044 ret = ptrace_getsiginfo(child, &siginfo);
1052 ret = ptrace_setsiginfo(child, &siginfo);
1063 if (test_tsk_restore_sigmask(child))
1064 mask = &child->saved_sigmask;
1066 mask = &child->blocked;
1096 spin_lock_irq(&child->sighand->siglock);
1097 child->blocked = new_set;
1098 spin_unlock_irq(&child->sighand->siglock);
1100 clear_tsk_restore_sigmask(child);
1110 * after this request. If @child is already trapped, the
1117 if (unlikely(!seized || !lock_task_sighand(child, &flags)))
1126 if (likely(task_set_jobctl_pending(child, JOBCTL_TRAP_STOP)))
1127 ptrace_signal_wake_up(child, child->jobctl & JOBCTL_LISTENING);
1129 unlock_task_sighand(child, &flags);
1142 if (unlikely(!seized || !lock_task_sighand(child, &flags)))
1145 si = child->last_siginfo;
1147 child->jobctl |= JOBCTL_LISTENING;
1152 if (child->jobctl & JOBCTL_TRAP_NOTIFY)
1153 ptrace_signal_wake_up(child, true);
1156 unlock_task_sighand(child, &flags);
1160 ret = ptrace_detach(child, data);
1165 struct mm_struct *mm = get_task_mm(child);
1199 return ptrace_resume(child, request, data);
1202 send_sig_info(SIGKILL, SEND_SIG_NOINFO, child);
1218 ret = ptrace_regset(child, request, addr, &kiov);
1225 ret = ptrace_get_syscall_info(child, addr, datavp);
1230 ret = seccomp_get_filter(child, addr, datavp);
1234 ret = seccomp_get_metadata(child, addr, datavp);
1239 ret = ptrace_get_rseq_configuration(child, addr, datavp);
1244 ret = syscall_user_dispatch_set_config(child, addr, datavp);
1248 ret = syscall_user_dispatch_get_config(child, addr, datavp);
1261 struct task_struct *child;
1269 child = find_get_task_by_vpid(pid);
1270 if (!child) {
1276 ret = ptrace_attach(child, request, addr, data);
1280 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1285 ret = arch_ptrace(child, request, addr, data);
1287 ptrace_unfreeze_traced(child);
1290 put_task_struct(child);
1319 int compat_ptrace_request(struct task_struct *child, compat_long_t request,
1330 ret = ptrace_access_vm(child, addr, &word, sizeof(word),
1340 ret = ptrace_access_vm(child, addr, &data, sizeof(data),
1346 ret = put_user((compat_ulong_t) child->ptrace_message, datap);
1350 ret = ptrace_getsiginfo(child, &siginfo);
1361 ret = ptrace_setsiginfo(child, &siginfo);
1383 ret = ptrace_regset(child, request, addr, &kiov);
1391 ret = ptrace_request(child, request, addr, data);
1400 struct task_struct *child;
1408 child = find_get_task_by_vpid(pid);
1409 if (!child) {
1415 ret = ptrace_attach(child, request, addr, data);
1419 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1422 ret = compat_arch_ptrace(child, request, addr, data);
1424 ptrace_unfreeze_traced(child);
1428 put_task_struct(child);