From 67f2eebb44e1f27017750eddaf5a5ea513cb9c71 Mon Sep 17 00:00:00 2001 From: mjg Date: Wed, 10 Jun 2015 10:43:59 +0000 Subject: Generalised support for copy-on-write structures shared by threads. Thread credentials are maintained as follows: each thread has a pointer to creds and a reference on them. The pointer is compared with proc's creds on userspace<->kernel boundary and updated if needed. This patch introduces a counter which can be compared instead, so that more structures can use this scheme without adding more comparisons on the boundary. --- sys/kern/init_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'sys/kern/init_main.c') diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index cf4eed1..37539c4 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -523,8 +523,6 @@ proc0_init(void *dummy __unused) #ifdef MAC mac_cred_create_swapper(newcred); #endif - td->td_ucred = crhold(newcred); - /* Create sigacts. */ p->p_sigacts = sigacts_alloc(); @@ -556,6 +554,10 @@ proc0_init(void *dummy __unused) p->p_limit->pl_rlimit[RLIMIT_MEMLOCK].rlim_max = pageablemem; p->p_cpulimit = RLIM_INFINITY; + PROC_LOCK(p); + thread_cow_get_proc(td, p); + PROC_UNLOCK(p); + /* Initialize resource accounting structures. */ racct_create(&p->p_racct); @@ -843,10 +845,10 @@ create_init(const void *udata __unused) audit_cred_proc1(newcred); #endif proc_set_cred(initproc, newcred); + cred_update_thread(FIRST_THREAD_IN_PROC(initproc)); PROC_UNLOCK(initproc); sx_xunlock(&proctree_lock); crfree(oldcred); - cred_update_thread(FIRST_THREAD_IN_PROC(initproc)); cpu_set_fork_handler(FIRST_THREAD_IN_PROC(initproc), start_init, NULL); } SYSINIT(init, SI_SUB_CREATE_INIT, SI_ORDER_FIRST, create_init, NULL); -- cgit v1.1