diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/compat/freebsd32/freebsd32.h | 1 | ||||
-rw-r--r-- | sys/kern/kern_proc.c | 17 | ||||
-rw-r--r-- | sys/sys/user.h | 3 |
3 files changed, 16 insertions, 5 deletions
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h index 94f886e..155612b 100644 --- a/sys/compat/freebsd32/freebsd32.h +++ b/sys/compat/freebsd32/freebsd32.h @@ -343,6 +343,7 @@ struct kinfo_proc32 { char ki_loginclass[LOGINCLASSLEN+1]; char ki_sparestrings[50]; int ki_spareints[KI_NSPARE_INT]; + int ki_tracer; int ki_flag2; int ki_fibnum; u_int ki_cr_flags; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 6689186..740c4a6 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -791,6 +791,8 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) struct ucred *cred; struct sigacts *ps; + /* For proc_realparent. */ + sx_assert(&proctree_lock, SX_LOCKED); PROC_LOCK_ASSERT(p, MA_OWNED); bzero(kp, sizeof(*kp)); @@ -920,7 +922,9 @@ fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) kp->ki_acflag = p->p_acflag; kp->ki_lock = p->p_lock; if (p->p_pptr) - kp->ki_ppid = p->p_pptr->p_pid; + kp->ki_ppid = proc_realparent(p)->p_pid; + if (p->p_flag & P_TRACED) + kp->ki_tracer = p->p_pptr->p_pid; } /* @@ -1166,6 +1170,7 @@ freebsd32_kinfo_proc_out(const struct kinfo_proc *ki, struct kinfo_proc32 *ki32) bcopy(ki->ki_comm, ki32->ki_comm, COMMLEN + 1); bcopy(ki->ki_emul, ki32->ki_emul, KI_EMULNAMELEN + 1); bcopy(ki->ki_loginclass, ki32->ki_loginclass, LOGINCLASSLEN + 1); + CP(*ki, *ki32, ki_tracer); CP(*ki, *ki32, ki_flag2); CP(*ki, *ki32, ki_fibnum); CP(*ki, *ki32, ki_cr_flags); @@ -1287,10 +1292,11 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS) error = sysctl_wire_old_buffer(req, 0); if (error) return (error); + sx_slock(&proctree_lock); error = pget((pid_t)name[0], PGET_CANSEE, &p); - if (error != 0) - return (error); - error = sysctl_out_proc(p, req, flags, 0); + if (error == 0) + error = sysctl_out_proc(p, req, flags, 0); + sx_sunlock(&proctree_lock); return (error); } @@ -1318,6 +1324,7 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS) error = sysctl_wire_old_buffer(req, 0); if (error != 0) return (error); + sx_slock(&proctree_lock); sx_slock(&allproc_lock); for (doingzomb=0 ; doingzomb < 2 ; doingzomb++) { if (!doingzomb) @@ -1422,11 +1429,13 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS) error = sysctl_out_proc(p, req, flags, doingzomb); if (error) { sx_sunlock(&allproc_lock); + sx_sunlock(&proctree_lock); return (error); } } } sx_sunlock(&allproc_lock); + sx_sunlock(&proctree_lock); return (0); } diff --git a/sys/sys/user.h b/sys/sys/user.h index f7b18df..6775ff7 100644 --- a/sys/sys/user.h +++ b/sys/sys/user.h @@ -84,7 +84,7 @@ * it in two places: function fill_kinfo_proc in sys/kern/kern_proc.c and * function kvm_proclist in lib/libkvm/kvm_proc.c . */ -#define KI_NSPARE_INT 7 +#define KI_NSPARE_INT 6 #define KI_NSPARE_LONG 12 #define KI_NSPARE_PTR 6 @@ -187,6 +187,7 @@ struct kinfo_proc { */ char ki_sparestrings[50]; /* spare string space */ int ki_spareints[KI_NSPARE_INT]; /* spare room for growth */ + int ki_tracer; /* Pid of tracing process */ int ki_flag2; /* P2_* flags */ int ki_fibnum; /* Default FIB number */ u_int ki_cr_flags; /* Credential flags */ |