+#include <mach/task.h> /* for task_resume() */
+#include <kern/sched_prim.h> /* for thread_exception_return() */
+
+/* XXX ken/bsd_kern.c - prototype should be in common header */
+int get_task_userstop(task_t);
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
/* Macros to clear/set/test flags. */
#define SET(t, f) (t) |= (f)
AUDIT_ARG(cmd, uap->req);
AUDIT_ARG(pid, uap->pid);
AUDIT_ARG(cmd, uap->req);
AUDIT_ARG(pid, uap->pid);
AUDIT_ARG(value, uap->data);
if (uap->req == PT_DENY_ATTACH) {
AUDIT_ARG(value, uap->data);
if (uap->req == PT_DENY_ATTACH) {
exit1(p, W_EXITCODE(ENOTSUP, 0), retval);
/* drop funnel before we return */
exit1(p, W_EXITCODE(ENOTSUP, 0), retval);
/* drop funnel before we return */
- if (ISSET(p->p_flag, P_TRACED)) {
- SET(p->p_flag, P_SIGEXC);
+ proc_lock(p);
+ if (ISSET(p->p_lflag, P_LTRACED)) {
+ SET(p->p_lflag, P_LSIGEXC);
+ proc_unlock(p);
if ( kauth_authorize_process(proc_ucred(p), KAUTH_PROCESS_CANTRACE,
t, (uintptr_t)&err, 0, 0) == 0 ) {
/* it's OK to attach */
if ( kauth_authorize_process(proc_ucred(p), KAUTH_PROCESS_CANTRACE,
t, (uintptr_t)&err, 0, 0) == 0 ) {
/* it's OK to attach */
* You can't do what you want to the process if:
* (1) It's not being traced at all,
*/
* You can't do what you want to the process if:
* (1) It's not being traced at all,
*/
/*
* Mach version of ptrace executes request directly here,
* thus simplifying the interaction of ptrace and signals.
*/
/*
* Mach version of ptrace executes request directly here,
* thus simplifying the interaction of ptrace and signals.
*/
- pp = pfind(t->p_oppid);
- proc_reparent(t, pp ? pp : initproc);
+ proc_unlock(t);
+ pp = proc_find(t->p_oppid);
+ proc_reparentlocked(t, pp ? pp : initproc, 1, 0);
+ if (pp != PROC_NULL)
+ proc_rele(pp);
+ proc_lock(t);
+
- CLR(t->p_flag, P_TRACED);
- CLR(t->p_flag, P_SIGEXC);
+ CLR(t->p_lflag, P_LTRACED);
+ CLR(t->p_lflag, P_LSIGEXC);
+ proc_unlock(t);
if (uap->addr != (user_addr_t)1) {
#if defined(ppc)
#define ALIGNED(addr,size) (((unsigned)(addr)&((size)-1))==0)
if (uap->addr != (user_addr_t)1) {
#if defined(ppc)
#define ALIGNED(addr,size) (((unsigned)(addr)&((size)-1))==0)
th_act = port_name_to_thread(CAST_DOWN(mach_port_name_t, uap->addr));
if (th_act == THREAD_NULL)
return (ESRCH);
ut = (uthread_t)get_bsdthread_info(th_act);
if (uap->data)
ut->uu_siglist |= sigmask(uap->data);
th_act = port_name_to_thread(CAST_DOWN(mach_port_name_t, uap->addr));
if (th_act == THREAD_NULL)
return (ESRCH);
ut = (uthread_t)get_bsdthread_info(th_act);
if (uap->data)
ut->uu_siglist |= sigmask(uap->data);