Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_proc.c
Show First 20 Lines • Show All 948 Lines • ▼ Show 20 Lines | |||||
* Must be called with the target process locked. | * Must be called with the target process locked. | ||||
*/ | */ | ||||
static void | static void | ||||
fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) | fill_kinfo_proc_only(struct proc *p, struct kinfo_proc *kp) | ||||
{ | { | ||||
struct thread *td0; | struct thread *td0; | ||||
struct tty *tp; | struct tty *tp; | ||||
struct session *sp; | struct session *sp; | ||||
struct ucred *cred; | |||||
struct sigacts *ps; | struct sigacts *ps; | ||||
struct timeval boottime; | struct timeval boottime; | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
bzero(kp, sizeof(*kp)); | bzero(kp, sizeof(*kp)); | ||||
kp->ki_structsize = sizeof(*kp); | kp->ki_structsize = sizeof(*kp); | ||||
kp->ki_paddr = p; | kp->ki_paddr = p; | ||||
kp->ki_addr =/* p->p_addr; */0; /* XXX */ | kp->ki_addr =/* p->p_addr; */0; /* XXX */ | ||||
kp->ki_args = p->p_args; | kp->ki_args = p->p_args; | ||||
kp->ki_textvp = p->p_textvp; | kp->ki_textvp = p->p_textvp; | ||||
#ifdef KTRACE | #ifdef KTRACE | ||||
kp->ki_tracep = p->p_tracevp; | kp->ki_tracep = p->p_tracevp; | ||||
kp->ki_traceflag = p->p_traceflag; | kp->ki_traceflag = p->p_traceflag; | ||||
#endif | #endif | ||||
kp->ki_fd = p->p_fd; | kp->ki_fd = p->p_fd; | ||||
kp->ki_vmspace = p->p_vmspace; | kp->ki_vmspace = p->p_vmspace; | ||||
kp->ki_flag = p->p_flag; | kp->ki_flag = p->p_flag; | ||||
kp->ki_flag2 = p->p_flag2; | kp->ki_flag2 = p->p_flag2; | ||||
cred = p->p_ucred; | |||||
mjg: why is this moved? | |||||
Done Inline Actionscredential information is moved into the thread-specific function below. This is relevant for the parts of the credential that become thread-specific eith this patch, for the parts that still aren’t thread specific: I moved them anyway to keep consistency in the code and future proof further credential changes. jack_gandi.net: credential information is moved into the thread-specific function below. This is relevant for… | |||||
if (cred) { | |||||
kp->ki_uid = cred->cr_uid; | |||||
kp->ki_ruid = cred->cr_ruid; | |||||
kp->ki_svuid = cred->cr_svuid; | |||||
kp->ki_cr_flags = 0; | |||||
if (cred->cr_flags & CRED_FLAG_CAPMODE) | |||||
kp->ki_cr_flags |= KI_CRF_CAPABILITY_MODE; | |||||
/* XXX bde doesn't like KI_NGROUPS */ | |||||
if (cred->cr_ngroups > KI_NGROUPS) { | |||||
kp->ki_ngroups = KI_NGROUPS; | |||||
kp->ki_cr_flags |= KI_CRF_GRP_OVERFLOW; | |||||
} else | |||||
kp->ki_ngroups = cred->cr_ngroups; | |||||
bcopy(cred->cr_groups, kp->ki_groups, | |||||
kp->ki_ngroups * sizeof(gid_t)); | |||||
kp->ki_rgid = cred->cr_rgid; | |||||
kp->ki_svgid = cred->cr_svgid; | |||||
/* If jailed(cred), emulate the old P_JAILED flag. */ | |||||
if (jailed(cred)) { | |||||
kp->ki_flag |= P_JAILED; | |||||
/* If inside the jail, use 0 as a jail ID. */ | |||||
if (cred->cr_prison != curthread->td_ucred->cr_prison) | |||||
kp->ki_jid = cred->cr_prison->pr_id; | |||||
} | |||||
strlcpy(kp->ki_loginclass, cred->cr_loginclass->lc_name, | |||||
sizeof(kp->ki_loginclass)); | |||||
} | |||||
ps = p->p_sigacts; | ps = p->p_sigacts; | ||||
if (ps) { | if (ps) { | ||||
mtx_lock(&ps->ps_mtx); | mtx_lock(&ps->ps_mtx); | ||||
kp->ki_sigignore = ps->ps_sigignore; | kp->ki_sigignore = ps->ps_sigignore; | ||||
kp->ki_sigcatch = ps->ps_sigcatch; | kp->ki_sigcatch = ps->ps_sigcatch; | ||||
mtx_unlock(&ps->ps_mtx); | mtx_unlock(&ps->ps_mtx); | ||||
} | } | ||||
if (p->p_state != PRS_NEW && | if (p->p_state != PRS_NEW && | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | |||||
* target process locked. If 'preferthread' is set, overwrite certain | * target process locked. If 'preferthread' is set, overwrite certain | ||||
* process-related fields that are maintained for both threads and | * process-related fields that are maintained for both threads and | ||||
* processes. | * processes. | ||||
*/ | */ | ||||
static void | static void | ||||
fill_kinfo_thread(struct thread *td, struct kinfo_proc *kp, int preferthread) | fill_kinfo_thread(struct thread *td, struct kinfo_proc *kp, int preferthread) | ||||
{ | { | ||||
struct proc *p; | struct proc *p; | ||||
struct ucred *cred; | |||||
p = td->td_proc; | p = td->td_proc; | ||||
kp->ki_tdaddr = td; | kp->ki_tdaddr = td; | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
if (preferthread) | if (preferthread) | ||||
PROC_STATLOCK(p); | PROC_STATLOCK(p); | ||||
thread_lock(td); | thread_lock(td); | ||||
cred = td->td_ucred; | |||||
if (cred) { | |||||
kp->ki_uid = cred->cr_uid; | |||||
kp->ki_ruid = cred->cr_ruid; | |||||
kp->ki_svuid = cred->cr_svuid; | |||||
kp->ki_cr_flags = 0; | |||||
if (cred->cr_flags & CRED_FLAG_CAPMODE) | |||||
kp->ki_cr_flags |= KI_CRF_CAPABILITY_MODE; | |||||
/* XXX bde doesn't like KI_NGROUPS */ | |||||
if (cred->cr_ngroups > KI_NGROUPS) { | |||||
kp->ki_ngroups = KI_NGROUPS; | |||||
kp->ki_cr_flags |= KI_CRF_GRP_OVERFLOW; | |||||
} else | |||||
kp->ki_ngroups = cred->cr_ngroups; | |||||
bcopy(cred->cr_groups, kp->ki_groups, | |||||
kp->ki_ngroups * sizeof(gid_t)); | |||||
kp->ki_rgid = cred->cr_rgid; | |||||
kp->ki_svgid = cred->cr_svgid; | |||||
/* If jailed(cred), emulate the old P_JAILED flag. */ | |||||
if (jailed(cred)) { | |||||
kp->ki_flag |= P_JAILED; | |||||
/* If inside the jail, use 0 as a jail ID. */ | |||||
if (cred->cr_prison != curthread->td_ucred->cr_prison) | |||||
kp->ki_jid = cred->cr_prison->pr_id; | |||||
} | |||||
strlcpy(kp->ki_loginclass, cred->cr_loginclass->lc_name, | |||||
sizeof(kp->ki_loginclass)); | |||||
} | |||||
if (td->td_wmesg != NULL) | if (td->td_wmesg != NULL) | ||||
strlcpy(kp->ki_wmesg, td->td_wmesg, sizeof(kp->ki_wmesg)); | strlcpy(kp->ki_wmesg, td->td_wmesg, sizeof(kp->ki_wmesg)); | ||||
else | else | ||||
bzero(kp->ki_wmesg, sizeof(kp->ki_wmesg)); | bzero(kp->ki_wmesg, sizeof(kp->ki_wmesg)); | ||||
if (strlcpy(kp->ki_tdname, td->td_name, sizeof(kp->ki_tdname)) >= | if (strlcpy(kp->ki_tdname, td->td_name, sizeof(kp->ki_tdname)) >= | ||||
sizeof(kp->ki_tdname)) { | sizeof(kp->ki_tdname)) { | ||||
strlcpy(kp->ki_moretdname, | strlcpy(kp->ki_moretdname, | ||||
td->td_name + sizeof(kp->ki_tdname) - 1, | td->td_name + sizeof(kp->ki_tdname) - 1, | ||||
▲ Show 20 Lines • Show All 2,078 Lines • Show Last 20 Lines |
why is this moved?