Lines Matching full:child

68 void __ptrace_link(struct task_struct *child, struct task_struct *new_parent,
71 BUG_ON(!list_empty(&child->ptrace_entry));
72 list_add(&child->ptrace_entry, &new_parent->ptraced);
73 child->parent = new_parent;
74 child->ptracer_cred = get_cred(ptracer_cred);
83 static void ptrace_link(struct task_struct *child, struct task_struct *new_parent)
85 __ptrace_link(child, new_parent, current_cred());
90 * @child: ptracee to be unlinked
92 * Remove @child from the ptrace list, move it back to the original parent,
116 void __ptrace_unlink(struct task_struct *child)
119 BUG_ON(!child->ptrace);
121 clear_task_syscall_work(child, SYSCALL_TRACE);
123 clear_task_syscall_work(child, SYSCALL_EMU);
126 child->parent = child->real_parent;
127 list_del_init(&child->ptrace_entry);
128 old_cred = child->ptracer_cred;
129 child->ptracer_cred = NULL;
132 spin_lock(&child->sighand->siglock);
133 child->ptrace = 0;
138 task_clear_jobctl_pending(child, JOBCTL_TRAP_MASK);
139 task_clear_jobctl_trapping(child);
143 * @child isn't dead.
145 if (!(child->flags & PF_EXITING) &&
146 (child->signal->flags & SIGNAL_STOP_STOPPED ||
147 child->signal->group_stop_count)) {
148 child->jobctl |= JOBCTL_STOP_PENDING;
157 if (!(child->jobctl & JOBCTL_STOP_SIGMASK))
158 child->jobctl |= SIGSTOP;
163 * @child in the butt. Note that @resume should be used iff @child
167 if (child->jobctl & JOBCTL_STOP_PENDING || task_is_traced(child))
168 ptrace_signal_wake_up(child, true);
170 spin_unlock(&child->sighand->siglock);
231 * @child: ptracee to check for
232 * @ignore_state: don't check whether @child is currently %TASK_TRACED
234 * Check whether @child is being ptraced by %current and ready for further
235 * ptrace operations. If @ignore_state is %false, @child also should be in
236 * %TASK_TRACED state and on return the child is guaranteed to be traced
237 * and not executing. If @ignore_state is %true, @child can be in any
241 * Grabs and releases tasklist_lock and @child->sighand->siglock.
244 * 0 on success, -ESRCH if %child is not ready.
246 static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
252 * possible race where someone else was tracing our child and
254 * we are sure that this is our traced child and that can only
258 if (child->ptrace && child->parent == current) {
259 WARN_ON(READ_ONCE(child->__state) == __TASK_TRACED);
261 * child->sighand can't be NULL, release_task()
264 if (ignore_state || ptrace_freeze_traced(child))
270 if (!wait_task_inactive(child, __TASK_TRACED)) {
276 WARN_ON(READ_ONCE(child->__state) == __TASK_TRACED);
309 * because setting up the necessary parent/child relationship
437 * will be cleared if the child completes the transition or any
530 * If it's our own child, there is no notification to do. But if our normal
531 * children self-reap, then this child was prevented by ptrace and we must
560 static int ptrace_detach(struct task_struct *child, unsigned int data)
566 ptrace_disable(child);
573 WARN_ON(!child->ptrace || child->exit_state);
578 child->exit_code = data;
579 __ptrace_detach(current, child);
582 proc_ptrace_connector(child, PTRACE_DETACH);
656 static int ptrace_setoptions(struct task_struct *child, unsigned long data)
677 flags = child->ptrace;
680 child->ptrace = flags;
685 static int ptrace_getsiginfo(struct task_struct *child, kernel_siginfo_t *info)
690 if (lock_task_sighand(child, &flags)) {
692 if (likely(child->last_siginfo != NULL)) {
693 copy_siginfo(info, child->last_siginfo);
696 unlock_task_sighand(child, &flags);
701 static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *info)
706 if (lock_task_sighand(child, &flags)) {
708 if (likely(child->last_siginfo != NULL)) {
709 copy_siginfo(child->last_siginfo, info);
712 unlock_task_sighand(child, &flags);
717 static int ptrace_peek_siginfo(struct task_struct *child,
742 pending = &child->signal->shared_pending;
744 pending = &child->pending;
751 spin_lock_irq(&child->sighand->siglock);
759 spin_unlock_irq(&child->sighand->siglock);
835 static int ptrace_resume(struct task_struct *child, long request,
844 set_task_syscall_work(child, SYSCALL_TRACE);
846 clear_task_syscall_work(child, SYSCALL_TRACE);
850 set_task_syscall_work(child, SYSCALL_EMU);
852 clear_task_syscall_work(child, SYSCALL_EMU);
858 user_enable_block_step(child);
862 user_enable_single_step(child);
864 user_disable_single_step(child);
882 spin_lock_irq(&child->sighand->siglock);
883 child->exit_code = data;
884 wake_up_state(child, __TASK_TRACED);
886 spin_unlock_irq(&child->sighand->siglock);
938 ptrace_get_syscall_info_entry(struct task_struct *child, struct pt_regs *regs,
945 info->entry.nr = syscall_get_nr(child, regs);
946 syscall_get_arguments(child, regs, args);
955 ptrace_get_syscall_info_seccomp(struct task_struct *child, struct pt_regs *regs,
965 ptrace_get_syscall_info_entry(child, regs, info);
967 info->seccomp.ret_data = child->ptrace_message;
974 ptrace_get_syscall_info_exit(struct task_struct *child, struct pt_regs *regs,
978 info->exit.rval = syscall_get_error(child, regs);
981 info->exit.rval = syscall_get_return_value(child, regs);
988 ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
991 struct pt_regs *regs = task_pt_regs(child);
994 .arch = syscall_get_arch(child),
1003 * child->last_siginfo because ptrace_freeze_traced()
1007 switch (child->last_siginfo ? child->last_siginfo->si_code : 0) {
1009 switch (child->ptrace_message) {
1011 actual_size = ptrace_get_syscall_info_entry(child, regs,
1015 actual_size = ptrace_get_syscall_info_exit(child, regs,
1021 actual_size = ptrace_get_syscall_info_seccomp(child, regs,
1031 int ptrace_request(struct task_struct *child, long request,
1034 bool seized = child->ptrace & PT_SEIZED;
1044 return generic_ptrace_peekdata(child, addr, data);
1047 return generic_ptrace_pokedata(child, addr, data);
1053 ret = ptrace_setoptions(child, data);
1056 ret = put_user(child->ptrace_message, datalp);
1060 ret = ptrace_peek_siginfo(child, addr, data);
1064 ret = ptrace_getsiginfo(child, &siginfo);
1072 ret = ptrace_setsiginfo(child, &siginfo);
1083 if (test_tsk_restore_sigmask(child))
1084 mask = &child->saved_sigmask;
1086 mask = &child->blocked;
1116 spin_lock_irq(&child->sighand->siglock);
1117 child->blocked = new_set;
1118 spin_unlock_irq(&child->sighand->siglock);
1120 clear_tsk_restore_sigmask(child);
1130 * after this request. If @child is already trapped, the
1137 if (unlikely(!seized || !lock_task_sighand(child, &flags)))
1146 if (likely(task_set_jobctl_pending(child, JOBCTL_TRAP_STOP)))
1147 ptrace_signal_wake_up(child, child->jobctl & JOBCTL_LISTENING);
1149 unlock_task_sighand(child, &flags);
1162 if (unlikely(!seized || !lock_task_sighand(child, &flags)))
1165 si = child->last_siginfo;
1167 child->jobctl |= JOBCTL_LISTENING;
1172 if (child->jobctl & JOBCTL_TRAP_NOTIFY)
1173 ptrace_signal_wake_up(child, true);
1176 unlock_task_sighand(child, &flags);
1180 ret = ptrace_detach(child, data);
1185 struct mm_struct *mm = get_task_mm(child);
1221 return ptrace_resume(child, request, data);
1224 if (child->exit_state) /* already dead */
1226 return ptrace_resume(child, request, SIGKILL);
1241 ret = ptrace_regset(child, request, addr, &kiov);
1248 ret = ptrace_get_syscall_info(child, addr, datavp);
1253 ret = seccomp_get_filter(child, addr, datavp);
1257 ret = seccomp_get_metadata(child, addr, datavp);
1262 ret = ptrace_get_rseq_configuration(child, addr, datavp);
1274 #define arch_ptrace_attach(child) do { } while (0)
1280 struct task_struct *child;
1290 child = find_get_task_by_vpid(pid);
1291 if (!child) {
1297 ret = ptrace_attach(child, request, addr, data);
1303 arch_ptrace_attach(child);
1307 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1312 ret = arch_ptrace(child, request, addr, data);
1314 ptrace_unfreeze_traced(child);
1317 put_task_struct(child);
1346 int compat_ptrace_request(struct task_struct *child, compat_long_t request,
1357 ret = ptrace_access_vm(child, addr, &word, sizeof(word),
1367 ret = ptrace_access_vm(child, addr, &data, sizeof(data),
1373 ret = put_user((compat_ulong_t) child->ptrace_message, datap);
1377 ret = ptrace_getsiginfo(child, &siginfo);
1388 ret = ptrace_setsiginfo(child, &siginfo);
1410 ret = ptrace_regset(child, request, addr, &kiov);
1418 ret = ptrace_request(child, request, addr, data);
1427 struct task_struct *child;
1435 child = find_get_task_by_vpid(pid);
1436 if (!child) {
1442 ret = ptrace_attach(child, request, addr, data);
1448 arch_ptrace_attach(child);
1452 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1455 ret = compat_arch_ptrace(child, request, addr, data);
1457 ptrace_unfreeze_traced(child);
1461 put_task_struct(child);