Lines Matching refs: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);
218 * The child may be awake and may have cleared
219 * JOBCTL_PTRACE_FROZEN (see ptrace_resume). The child will
234 * @child: ptracee to check for
235 * @ignore_state: don't check whether @child is currently %TASK_TRACED
237 * Check whether @child is being ptraced by %current and ready for further
238 * ptrace operations. If @ignore_state is %false, @child also should be in
239 * %TASK_TRACED state and on return the child is guaranteed to be traced
240 * and not executing. If @ignore_state is %true, @child can be in any
244 * Grabs and releases tasklist_lock and @child->sighand->siglock.
247 * 0 on success, -ESRCH if %child is not ready.
249 static int ptrace_check_attach(struct task_struct *child, bool ignore_state)
255 * possible race where someone else was tracing our child and
257 * we are sure that this is our traced child and that can only
261 if (child->ptrace && child->parent == current) {
263 * child->sighand can't be NULL, release_task()
266 if (ignore_state || ptrace_freeze_traced(child))
272 WARN_ON_ONCE(!wait_task_inactive(child, __TASK_TRACED|TASK_FROZEN)))
303 * because setting up the necessary parent/child relationship
457 * will be cleared if the child completes the transition or any
552 * If it's our own child, there is no notification to do. But if our normal
553 * children self-reap, then this child was prevented by ptrace and we must
582 static int ptrace_detach(struct task_struct *child, unsigned int data)
588 ptrace_disable(child);
595 WARN_ON(!child->ptrace || child->exit_state);
600 child->exit_code = data;
601 __ptrace_detach(current, child);
604 proc_ptrace_connector(child, PTRACE_DETACH);
678 static int ptrace_setoptions(struct task_struct *child, unsigned long data)
688 flags = child->ptrace;
691 child->ptrace = flags;
696 static int ptrace_getsiginfo(struct task_struct *child, kernel_siginfo_t *info)
701 if (lock_task_sighand(child, &flags)) {
703 if (likely(child->last_siginfo != NULL)) {
704 copy_siginfo(info, child->last_siginfo);
707 unlock_task_sighand(child, &flags);
712 static int ptrace_setsiginfo(struct task_struct *child, const kernel_siginfo_t *info)
717 if (lock_task_sighand(child, &flags)) {
719 if (likely(child->last_siginfo != NULL)) {
720 copy_siginfo(child->last_siginfo, info);
723 unlock_task_sighand(child, &flags);
728 static int ptrace_peek_siginfo(struct task_struct *child,
753 pending = &child->signal->shared_pending;
755 pending = &child->pending;
762 spin_lock_irq(&child->sighand->siglock);
770 spin_unlock_irq(&child->sighand->siglock);
842 static int ptrace_resume(struct task_struct *child, long request,
849 set_task_syscall_work(child, SYSCALL_TRACE);
851 clear_task_syscall_work(child, SYSCALL_TRACE);
855 set_task_syscall_work(child, SYSCALL_EMU);
857 clear_task_syscall_work(child, SYSCALL_EMU);
863 user_enable_block_step(child);
867 user_enable_single_step(child);
869 user_disable_single_step(child);
881 spin_lock_irq(&child->sighand->siglock);
882 child->exit_code = data;
883 child->jobctl &= ~JOBCTL_TRACED;
884 wake_up_state(child, __TASK_TRACED);
885 spin_unlock_irq(&child->sighand->siglock);
937 ptrace_get_syscall_info_entry(struct task_struct *child, struct pt_regs *regs,
944 info->entry.nr = syscall_get_nr(child, regs);
945 syscall_get_arguments(child, regs, args);
954 ptrace_get_syscall_info_seccomp(struct task_struct *child, struct pt_regs *regs,
964 ptrace_get_syscall_info_entry(child, regs, info);
966 info->seccomp.ret_data = child->ptrace_message;
973 ptrace_get_syscall_info_exit(struct task_struct *child, struct pt_regs *regs,
977 info->exit.rval = syscall_get_error(child, regs);
980 info->exit.rval = syscall_get_return_value(child, regs);
987 ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
990 struct pt_regs *regs = task_pt_regs(child);
993 .arch = syscall_get_arch(child),
1002 * child->last_siginfo because ptrace_freeze_traced()
1006 switch (child->last_siginfo ? child->last_siginfo->si_code : 0) {
1008 switch (child->ptrace_message) {
1010 actual_size = ptrace_get_syscall_info_entry(child, regs,
1014 actual_size = ptrace_get_syscall_info_exit(child, regs,
1020 actual_size = ptrace_get_syscall_info_seccomp(child, regs,
1030 int ptrace_request(struct task_struct *child, long request,
1033 bool seized = child->ptrace & PT_SEIZED;
1043 return generic_ptrace_peekdata(child, addr, data);
1046 return generic_ptrace_pokedata(child, addr, data);
1052 ret = ptrace_setoptions(child, data);
1055 ret = put_user(child->ptrace_message, datalp);
1059 ret = ptrace_peek_siginfo(child, addr, data);
1063 ret = ptrace_getsiginfo(child, &siginfo);
1071 ret = ptrace_setsiginfo(child, &siginfo);
1082 if (test_tsk_restore_sigmask(child))
1083 mask = &child->saved_sigmask;
1085 mask = &child->blocked;
1115 spin_lock_irq(&child->sighand->siglock);
1116 child->blocked = new_set;
1117 spin_unlock_irq(&child->sighand->siglock);
1119 clear_tsk_restore_sigmask(child);
1129 * after this request. If @child is already trapped, the
1136 if (unlikely(!seized || !lock_task_sighand(child, &flags)))
1145 if (likely(task_set_jobctl_pending(child, JOBCTL_TRAP_STOP)))
1146 ptrace_signal_wake_up(child, child->jobctl & JOBCTL_LISTENING);
1148 unlock_task_sighand(child, &flags);
1161 if (unlikely(!seized || !lock_task_sighand(child, &flags)))
1164 si = child->last_siginfo;
1166 child->jobctl |= JOBCTL_LISTENING;
1171 if (child->jobctl & JOBCTL_TRAP_NOTIFY)
1172 ptrace_signal_wake_up(child, true);
1175 unlock_task_sighand(child, &flags);
1179 ret = ptrace_detach(child, data);
1184 struct mm_struct *mm = get_task_mm(child);
1218 return ptrace_resume(child, request, data);
1221 send_sig_info(SIGKILL, SEND_SIG_NOINFO, child);
1237 ret = ptrace_regset(child, request, addr, &kiov);
1244 ret = ptrace_get_syscall_info(child, addr, datavp);
1249 ret = seccomp_get_filter(child, addr, datavp);
1253 ret = seccomp_get_metadata(child, addr, datavp);
1258 ret = ptrace_get_rseq_configuration(child, addr, datavp);
1272 struct task_struct *child;
1280 child = find_get_task_by_vpid(pid);
1281 if (!child) {
1287 ret = ptrace_attach(child, request, addr, data);
1291 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1296 ret = arch_ptrace(child, request, addr, data);
1298 ptrace_unfreeze_traced(child);
1301 put_task_struct(child);
1330 int compat_ptrace_request(struct task_struct *child, compat_long_t request,
1341 ret = ptrace_access_vm(child, addr, &word, sizeof(word),
1351 ret = ptrace_access_vm(child, addr, &data, sizeof(data),
1357 ret = put_user((compat_ulong_t) child->ptrace_message, datap);
1361 ret = ptrace_getsiginfo(child, &siginfo);
1372 ret = ptrace_setsiginfo(child, &siginfo);
1394 ret = ptrace_regset(child, request, addr, &kiov);
1402 ret = ptrace_request(child, request, addr, data);
1411 struct task_struct *child;
1419 child = find_get_task_by_vpid(pid);
1420 if (!child) {
1426 ret = ptrace_attach(child, request, addr, data);
1430 ret = ptrace_check_attach(child, request == PTRACE_KILL ||
1433 ret = compat_arch_ptrace(child, request, addr, data);
1435 ptrace_unfreeze_traced(child);
1439 put_task_struct(child);