Lines Matching full: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;
158 if (!(child->jobctl & JOBCTL_STOP_SIGMASK))
159 child->jobctl |= SIGSTOP;
164 * @child in the butt. Note that @resume should be used iff @child
168 if (child->jobctl & JOBCTL_STOP_PENDING || task_is_traced(child))
169 ptrace_signal_wake_up(child, true);
171 spin_unlock(&child->sighand->siglock);
219 * The child may be awake and may have cleared
220 * JOBCTL_PTRACE_FROZEN (see ptrace_resume). The child will
235 * @child: ptracee to check for
236 * @ignore_state: don't check whether @child is currently %TASK_TRACED
238 * Check whether @child is being ptraced by %current and ready for further
239 * ptrace operations. If @ignore_state is %false, @child also should be in
240 * %TASK_TRACED state and on return the child is guaranteed to be traced
241 * and not executing. If @ignore_state is %true, @child can be in any
245 * Grabs and releases tasklist_lock and @child->sighand->siglock.
248 * 0 on success, -ESRCH if %child is not ready.
250 static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
256 * possible race where someone else was tracing our child and
258 * we are sure that this is our traced child and that can only
262 if (child->ptrace && child->parent == current) {
264 * child->sighand can't be NULL, release_task()
267 if (ignore_state || ptrace_freeze_traced(child))
273 WARN_ON_ONCE(!wait_task_inactive(child, __TASK_TRACED|TASK_FROZEN)))
304 * because setting up the necessary parent/child relationship
458 * will be cleared if the child completes the transition or any
553 * If it's our own child, there is no notification to do. But if our normal
554 * children self-reap, then this child was prevented by ptrace and we must
583 static int ptrace_detach(struct task_struct *child, unsigned int data)
589 ptrace_disable(child);
596 WARN_ON(!child->ptrace || child->exit_state);
601 child->exit_code = data;
602 __ptrace_detach(current, child);
605 proc_ptrace_connector(child, PTRACE_DETACH);
679 static int ptrace_setoptions(struct task_struct *child, unsigned long data)
689 flags = child->ptrace;
692 child->ptrace = flags;
697 static int ptrace_getsiginfo(struct task_struct *child, kernel_siginfo_t *info)
702 if (lock_task_sighand(child, &flags)) {
704 if (likely(child->last_siginfo != NULL)) {
705 copy_siginfo(info, child->last_siginfo);
708 unlock_task_sighand(child, &flags);
713 static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *info)
718 if (lock_task_sighand(child, &flags)) {
720 if (likely(child->last_siginfo != NULL)) {
721 copy_siginfo(child->last_siginfo, info);
724 unlock_task_sighand(child, &flags);
729 static int ptrace_peek_siginfo(struct task_struct *child,
754 pending = &child->signal->shared_pending;
756 pending = &child->pending;
763 spin_lock_irq(&child->sighand->siglock);
771 spin_unlock_irq(&child->sighand->siglock);
843 static int ptrace_resume(struct task_struct *child, long request,
850 set_task_syscall_work(child, SYSCALL_TRACE);
852 clear_task_syscall_work(child, SYSCALL_TRACE);
856 set_task_syscall_work(child, SYSCALL_EMU);
858 clear_task_syscall_work(child, SYSCALL_EMU);
864 user_enable_block_step(child);
868 user_enable_single_step(child);
870 user_disable_single_step(child);
882 spin_lock_irq(&child->sighand->siglock);
883 child->exit_code = data;
884 child->jobctl &= ~JOBCTL_TRACED;
885 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);
1219 return ptrace_resume(child, request, data);
1222 send_sig_info(SIGKILL, SEND_SIG_NOINFO, child);
1238 ret = ptrace_regset(child, request, addr, &kiov);
1245 ret = ptrace_get_syscall_info(child, addr, datavp);
1250 ret = seccomp_get_filter(child, addr, datavp);
1254 ret = seccomp_get_metadata(child, addr, datavp);
1259 ret = ptrace_get_rseq_configuration(child, addr, datavp);
1264 ret = syscall_user_dispatch_set_config(child, addr, datavp);
1268 ret = syscall_user_dispatch_get_config(child, addr, datavp);
1281 struct task_struct *child;
1289 child = find_get_task_by_vpid(pid);
1290 if (!child) {
1296 ret = ptrace_attach(child, request, addr, data);
1300 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1305 ret = arch_ptrace(child, request, addr, data);
1307 ptrace_unfreeze_traced(child);
1310 put_task_struct(child);
1339 int compat_ptrace_request(struct task_struct *child, compat_long_t request,
1350 ret = ptrace_access_vm(child, addr, &word, sizeof(word),
1360 ret = ptrace_access_vm(child, addr, &data, sizeof(data),
1366 ret = put_user((compat_ulong_t) child->ptrace_message, datap);
1370 ret = ptrace_getsiginfo(child, &siginfo);
1381 ret = ptrace_setsiginfo(child, &siginfo);
1403 ret = ptrace_regset(child, request, addr, &kiov);
1411 ret = ptrace_request(child, request, addr, data);
1420 struct task_struct *child;
1428 child = find_get_task_by_vpid(pid);
1429 if (!child) {
1435 ret = ptrace_attach(child, request, addr, data);
1439 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1442 ret = compat_arch_ptrace(child, request, addr, data);
1444 ptrace_unfreeze_traced(child);
1448 put_task_struct(child);