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;
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
385 * will be cleared if the child completes the transition or any
536 * If it's our own child, there is no notification to do. But if our normal
537 * children self-reap, then this child was prevented by ptrace and we must
566 static int ptrace_detach(struct task_struct *child, unsigned int data)
572 ptrace_disable(child);
579 WARN_ON(!child->ptrace || child->exit_state);
584 child->exit_code = data;
585 __ptrace_detach(current, child);
588 proc_ptrace_connector(child, PTRACE_DETACH);
662 static int ptrace_setoptions(struct task_struct *child, unsigned long data)
672 flags = child->ptrace;
675 child->ptrace = flags;
680 static int ptrace_getsiginfo(struct task_struct *child, kernel_siginfo_t *info)
685 if (lock_task_sighand(child, &flags)) {
687 if (likely(child->last_siginfo != NULL)) {
688 copy_siginfo(info, child->last_siginfo);
691 unlock_task_sighand(child, &flags);
696 static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *info)
701 if (lock_task_sighand(child, &flags)) {
703 if (likely(child->last_siginfo != NULL)) {
704 copy_siginfo(child->last_siginfo, info);
707 unlock_task_sighand(child, &flags);
712 static int ptrace_peek_siginfo(struct task_struct *child,
737 pending = &child->signal->shared_pending;
739 pending = &child->pending;
746 spin_lock_irq(&child->sighand->siglock);
754 spin_unlock_irq(&child->sighand->siglock);
826 static int ptrace_resume(struct task_struct *child, long request,
833 set_task_syscall_work(child, SYSCALL_TRACE);
835 clear_task_syscall_work(child, SYSCALL_TRACE);
839 set_task_syscall_work(child, SYSCALL_EMU);
841 clear_task_syscall_work(child, SYSCALL_EMU);
847 user_enable_block_step(child);
851 user_enable_single_step(child);
853 user_disable_single_step(child);
865 spin_lock_irq(&child->sighand->siglock);
866 child->exit_code = data;
867 child->jobctl &= ~JOBCTL_TRACED;
868 wake_up_state(child, __TASK_TRACED);
869 spin_unlock_irq(&child->sighand->siglock);
921 ptrace_get_syscall_info_entry(struct task_struct *child, struct pt_regs *regs,
928 info->entry.nr = syscall_get_nr(child, regs);
929 syscall_get_arguments(child, regs, args);
938 ptrace_get_syscall_info_seccomp(struct task_struct *child, struct pt_regs *regs,
948 ptrace_get_syscall_info_entry(child, regs, info);
950 info->seccomp.ret_data = child->ptrace_message;
957 ptrace_get_syscall_info_exit(struct task_struct *child, struct pt_regs *regs,
961 info->exit.rval = syscall_get_error(child, regs);
964 info->exit.rval = syscall_get_return_value(child, regs);
971 ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
974 struct pt_regs *regs = task_pt_regs(child);
977 .arch = syscall_get_arch(child),
986 * child->last_siginfo because ptrace_freeze_traced()
990 switch (child->last_siginfo ? child->last_siginfo->si_code : 0) {
992 switch (child->ptrace_message) {
994 actual_size = ptrace_get_syscall_info_entry(child, regs,
998 actual_size = ptrace_get_syscall_info_exit(child, regs,
1004 actual_size = ptrace_get_syscall_info_seccomp(child, regs,
1014 int ptrace_request(struct task_struct *child, long request,
1017 bool seized = child->ptrace & PT_SEIZED;
1027 return generic_ptrace_peekdata(child, addr, data);
1030 return generic_ptrace_pokedata(child, addr, data);
1036 ret = ptrace_setoptions(child, data);
1039 ret = put_user(child->ptrace_message, datalp);
1043 ret = ptrace_peek_siginfo(child, addr, data);
1047 ret = ptrace_getsiginfo(child, &siginfo);
1055 ret = ptrace_setsiginfo(child, &siginfo);
1066 if (test_tsk_restore_sigmask(child))
1067 mask = &child->saved_sigmask;
1069 mask = &child->blocked;
1099 spin_lock_irq(&child->sighand->siglock);
1100 child->blocked = new_set;
1101 spin_unlock_irq(&child->sighand->siglock);
1103 clear_tsk_restore_sigmask(child);
1113 * after this request. If @child is already trapped, the
1120 if (unlikely(!seized || !lock_task_sighand(child, &flags)))
1129 if (likely(task_set_jobctl_pending(child, JOBCTL_TRAP_STOP)))
1130 ptrace_signal_wake_up(child, child->jobctl & JOBCTL_LISTENING);
1132 unlock_task_sighand(child, &flags);
1145 if (unlikely(!seized || !lock_task_sighand(child, &flags)))
1148 si = child->last_siginfo;
1150 child->jobctl |= JOBCTL_LISTENING;
1155 if (child->jobctl & JOBCTL_TRAP_NOTIFY)
1156 ptrace_signal_wake_up(child, true);
1159 unlock_task_sighand(child, &flags);
1163 ret = ptrace_detach(child, data);
1168 struct mm_struct *mm = get_task_mm(child);
1202 return ptrace_resume(child, request, data);
1205 send_sig_info(SIGKILL, SEND_SIG_NOINFO, child);
1221 ret = ptrace_regset(child, request, addr, &kiov);
1228 ret = ptrace_get_syscall_info(child, addr, datavp);
1233 ret = seccomp_get_filter(child, addr, datavp);
1237 ret = seccomp_get_metadata(child, addr, datavp);
1242 ret = ptrace_get_rseq_configuration(child, addr, datavp);
1247 ret = syscall_user_dispatch_set_config(child, addr, datavp);
1251 ret = syscall_user_dispatch_get_config(child, addr, datavp);
1264 struct task_struct *child;
1272 child = find_get_task_by_vpid(pid);
1273 if (!child) {
1279 ret = ptrace_attach(child, request, addr, data);
1283 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1288 ret = arch_ptrace(child, request, addr, data);
1290 ptrace_unfreeze_traced(child);
1293 put_task_struct(child);
1322 int compat_ptrace_request(struct task_struct *child, compat_long_t request,
1333 ret = ptrace_access_vm(child, addr, &word, sizeof(word),
1343 ret = ptrace_access_vm(child, addr, &data, sizeof(data),
1349 ret = put_user((compat_ulong_t) child->ptrace_message, datap);
1353 ret = ptrace_getsiginfo(child, &siginfo);
1364 ret = ptrace_setsiginfo(child, &siginfo);
1386 ret = ptrace_regset(child, request, addr, &kiov);
1394 ret = ptrace_request(child, request, addr, data);
1403 struct task_struct *child;
1411 child = find_get_task_by_vpid(pid);
1412 if (!child) {
1418 ret = ptrace_attach(child, request, addr, data);
1422 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1425 ret = compat_arch_ptrace(child, request, addr, data);
1427 ptrace_unfreeze_traced(child);
1431 put_task_struct(child);