Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_fork.c
Show First 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | |||||
#include <security/audit/audit.h> | #include <security/audit/audit.h> | ||||
#include <security/mac/mac_framework.h> | #include <security/mac/mac_framework.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/pmap.h> | #include <vm/pmap.h> | ||||
#include <vm/vm_map.h> | #include <vm/vm_map.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <vm/vm_domain.h> | |||||
#ifdef KDTRACE_HOOKS | #ifdef KDTRACE_HOOKS | ||||
#include <sys/dtrace_bsd.h> | #include <sys/dtrace_bsd.h> | ||||
dtrace_fork_func_t dtrace_fasttrap_fork; | dtrace_fork_func_t dtrace_fasttrap_fork; | ||||
#endif | #endif | ||||
SDT_PROVIDER_DECLARE(proc); | SDT_PROVIDER_DECLARE(proc); | ||||
SDT_PROBE_DEFINE3(proc, kernel, , create, "struct proc *", | SDT_PROBE_DEFINE3(proc, kernel, , create, "struct proc *", | ||||
▲ Show 20 Lines • Show All 309 Lines • ▼ Show 20 Lines | do_fork(struct thread *td, int flags, struct proc *p2, struct thread *td2, | ||||
PROC_LOCK(p2); | PROC_LOCK(p2); | ||||
PROC_LOCK(p1); | PROC_LOCK(p1); | ||||
sx_xunlock(&allproc_lock); | sx_xunlock(&allproc_lock); | ||||
bcopy(&p1->p_startcopy, &p2->p_startcopy, | bcopy(&p1->p_startcopy, &p2->p_startcopy, | ||||
__rangeof(struct proc, p_startcopy, p_endcopy)); | __rangeof(struct proc, p_startcopy, p_endcopy)); | ||||
pargs_hold(p2->p_args); | pargs_hold(p2->p_args); | ||||
PROC_UNLOCK(p1); | PROC_UNLOCK(p1); | ||||
bzero(&p2->p_startzero, | bzero(&p2->p_startzero, | ||||
__rangeof(struct proc, p_startzero, p_endzero)); | __rangeof(struct proc, p_startzero, p_endzero)); | ||||
/* Tell the prison that we exist. */ | /* Tell the prison that we exist. */ | ||||
prison_proc_hold(p2->p_ucred->cr_prison); | prison_proc_hold(p2->p_ucred->cr_prison); | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | #endif | ||||
* Increase reference counts on shared objects. | * Increase reference counts on shared objects. | ||||
*/ | */ | ||||
p2->p_flag = P_INMEM; | p2->p_flag = P_INMEM; | ||||
p2->p_flag2 = p1->p_flag2 & (P2_NOTRACE | P2_NOTRACE_EXEC); | p2->p_flag2 = p1->p_flag2 & (P2_NOTRACE | P2_NOTRACE_EXEC); | ||||
p2->p_swtick = ticks; | p2->p_swtick = ticks; | ||||
if (p1->p_flag & P_PROFIL) | if (p1->p_flag & P_PROFIL) | ||||
startprofclock(p2); | startprofclock(p2); | ||||
td2->td_ucred = crhold(p2->p_ucred); | td2->td_ucred = crhold(p2->p_ucred); | ||||
/* | |||||
* Whilst the proc lock is held, copy the VM domain data out | |||||
* using the VM domain method. | |||||
*/ | |||||
vm_domain_policy_init(&p2->p_vm_dom_policy); | |||||
if (vm_domain_policy_localcopy(&p2->p_vm_dom_policy, | |||||
&p1->p_vm_dom_policy) != 0) { | |||||
/* failed; fall through to none */ | |||||
vm_domain_policy_set(&p2->p_vm_dom_policy, | |||||
VM_POLICY_NONE, -1); | |||||
} | |||||
if (flags & RFSIGSHARE) { | if (flags & RFSIGSHARE) { | ||||
p2->p_sigacts = sigacts_hold(p1->p_sigacts); | p2->p_sigacts = sigacts_hold(p1->p_sigacts); | ||||
} else { | } else { | ||||
sigacts_copy(newsigacts, p1->p_sigacts); | sigacts_copy(newsigacts, p1->p_sigacts); | ||||
p2->p_sigacts = newsigacts; | p2->p_sigacts = newsigacts; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 556 Lines • Show Last 20 Lines |