diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2007-04-12 22:14:16 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2007-04-12 22:14:16 +0000 |
commit | 37f4013a076fcf2727b9b326a013d3678068ac5d (patch) | |
tree | 2f20108518ca9b7f670f0a876189e4b8c0dd40c3 /sys/kern | |
parent | 12cedcbc559e597ed5f6a4fbe8e267492a950a77 (diff) |
move p_limit and p_cred into struct process
leave macros behind for now to keep the commit small
ok art beck miod pedro
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/init_main.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_acct.c | 12 | ||||
-rw-r--r-- | sys/kern/kern_exit.c | 20 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 36 | ||||
-rw-r--r-- | sys/kern/kern_resource.c | 10 | ||||
-rw-r--r-- | sys/kern/kern_sysctl.c | 5 |
6 files changed, 49 insertions, 38 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 01dd7faa856..a8cf415a9df 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.138 2007/04/03 08:05:43 art Exp $ */ +/* $OpenBSD: init_main.c,v 1.139 2007/04/12 22:14:15 tedu Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -303,7 +303,7 @@ main(void *framep) TAILQ_INIT(&p->p_selects); /* Create the limits structures. */ - p->p_limit = &limit0; + p->p_p->ps_limit = &limit0; for (i = 0; i < sizeof(p->p_rlimit)/sizeof(p->p_rlimit[0]); i++) limit0.pl_rlimit[i].rlim_cur = limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY; diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 262cda6a6c0..4a78715dcb7 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_acct.c,v 1.20 2007/01/16 17:52:18 thib Exp $ */ +/* $OpenBSD: kern_acct.c,v 1.21 2007/04/12 22:14:15 tedu Exp $ */ /* $NetBSD: kern_acct.c,v 1.42 1996/02/04 02:15:12 christos Exp $ */ /*- @@ -175,9 +175,9 @@ acct_process(struct proc *p) * Raise the file limit so that accounting can't be stopped by the * user. (XXX - we should think about the cpu limit too). */ - if (p->p_limit->p_refcnt > 1) { - oplim = p->p_limit; - p->p_limit = limcopy(p->p_limit); + if (p->p_p->ps_limit->p_refcnt > 1) { + oplim = p->p_p->ps_limit; + p->p_p->ps_limit = limcopy(p->p_p->ps_limit); } p->p_rlimit[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; @@ -231,8 +231,8 @@ acct_process(struct proc *p) (off_t)0, UIO_SYSSPACE, IO_APPEND|IO_UNIT, p->p_ucred, NULL, p); if (oplim) { - limfree(p->p_limit); - p->p_limit = oplim; + limfree(p->p_p->ps_limit); + p->p_p->ps_limit = oplim; } return error; diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index cd9a2692627..4c85dd84543 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.70 2007/04/11 14:27:08 tedu Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.71 2007/04/12 22:14:15 tedu Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -325,8 +325,6 @@ exit1(struct proc *p, int rv, int flags) * Other substructures are freed from wait(). */ curproc = NULL; - limfree(p->p_limit); - p->p_limit = NULL; /* * If emulation has process exit hook, call it now. @@ -593,14 +591,6 @@ proc_zap(struct proc *p) (void)chgproccnt(p->p_cred->p_ruid, -1); /* - * Free up credentials. - */ - if (--p->p_cred->p_refcnt == 0) { - crfree(p->p_cred->pc_ucred); - pool_put(&pcred_pool, p->p_cred); - } - - /* * Release reference to text vnode */ if (p->p_textvp) @@ -613,8 +603,14 @@ proc_zap(struct proc *p) #if 0 TAILQ_REMOVE(&p->p_p->ps_threads, p, p_thr_link); #endif - if (TAILQ_EMPTY(&p->p_p->ps_threads)) + if (TAILQ_EMPTY(&p->p_p->ps_threads)) { + limfree(p->p_p->ps_limit); + if (--p->p_p->ps_cred->p_refcnt == 0) { + crfree(p->p_p->ps_cred->pc_ucred); + pool_put(&pcred_pool, p->p_p->ps_cred); + } pool_put(&process_pool, p->p_p); + } pool_put(&proc_pool, p); nprocs--; diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index c187ea87f18..71941682d39 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.89 2007/04/03 08:05:43 art Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.90 2007/04/12 22:14:15 tedu Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -270,10 +270,17 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, atomic_setbits_int(&p2->p_flag, p1->p_flag & (P_SUGID | P_SUGIDEXEC)); if (flags & FORK_PTRACE) atomic_setbits_int(&p2->p_flag, p1->p_flag & P_TRACED); - p2->p_cred = pool_get(&pcred_pool, PR_WAITOK); - bcopy(p1->p_cred, p2->p_cred, sizeof(*p2->p_cred)); - p2->p_cred->p_refcnt = 1; - crhold(p1->p_ucred); +#ifdef RTHREADS + if (flags & FORK_THREAD) { + /* nothing */ + } else +#endif + { + p2->p_p->ps_cred = pool_get(&pcred_pool, PR_WAITOK); + bcopy(p1->p_p->ps_cred, p2->p_p->ps_cred, sizeof(*p2->p_p->ps_cred)); + p2->p_p->ps_cred->p_refcnt = 1; + crhold(p1->p_ucred); + } TAILQ_INIT(&p2->p_selects); @@ -290,16 +297,23 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, p2->p_fd = fdcopy(p1); /* - * If p_limit is still copy-on-write, bump refcnt, + * If ps_limit is still copy-on-write, bump refcnt, * otherwise get a copy that won't be modified. * (If PL_SHAREMOD is clear, the structure is shared * copy-on-write.) */ - if (p1->p_limit->p_lflags & PL_SHAREMOD) - p2->p_limit = limcopy(p1->p_limit); - else { - p2->p_limit = p1->p_limit; - p2->p_limit->p_refcnt++; +#ifdef RTHREADS + if (flags & FORK_THREAD) { + /* nothing */ + } else +#endif + { + if (p1->p_p->ps_limit->p_lflags & PL_SHAREMOD) + p2->p_p->ps_limit = limcopy(p1->p_p->ps_limit); + else { + p2->p_p->ps_limit = p1->p_p->ps_limit; + p2->p_p->ps_limit->p_refcnt++; + } } if (p1->p_session->s_ttyvp != NULL && p1->p_flag & P_CONTROLT) diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index cb146e36d3f..f139dbd2f0a 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.31 2005/11/28 00:14:29 jsg Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.32 2007/04/12 22:14:15 tedu Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -229,10 +229,10 @@ dosetrlimit(struct proc *p, u_int which, struct rlimit *limp) limp->rlim_max > alimp->rlim_max) if ((error = suser(p, 0)) != 0) return (error); - if (p->p_limit->p_refcnt > 1 && - (p->p_limit->p_lflags & PL_SHAREMOD) == 0) { - p->p_limit->p_refcnt--; - p->p_limit = limcopy(p->p_limit); + if (p->p_p->ps_limit->p_refcnt > 1 && + (p->p_p->ps_limit->p_lflags & PL_SHAREMOD) == 0) { + p->p_p->ps_limit->p_refcnt--; + p->p_p->ps_limit = limcopy(p->p_p->ps_limit); alimp = &p->p_rlimit[which]; } diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 0f6b4ae48a5..43e7cbec29b 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.149 2007/03/22 16:55:31 deraadt Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.150 2007/04/12 22:14:15 tedu Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -1175,6 +1175,7 @@ fill_eproc(struct proc *p, struct eproc *ep) strncpy(ep->e_emul, p->p_emul->e_name, EMULNAMELEN); ep->e_emul[EMULNAMELEN] = '\0'; ep->e_maxrss = p->p_rlimit ? p->p_rlimit[RLIMIT_RSS].rlim_cur : 0; + ep->e_limit = p->p_p->ps_limit; } #ifndef SMALL_KERNEL @@ -1193,7 +1194,7 @@ fill_kproc2(struct proc *p, struct kinfo_proc2 *ki) ki->p_paddr = PTRTOINT64(p); ki->p_fd = PTRTOINT64(p->p_fd); ki->p_stats = PTRTOINT64(p->p_stats); - ki->p_limit = PTRTOINT64(p->p_limit); + ki->p_limit = PTRTOINT64(p->p_p->ps_limit); ki->p_vmspace = PTRTOINT64(p->p_vmspace); ki->p_sigacts = PTRTOINT64(p->p_sigacts); ki->p_sess = PTRTOINT64(p->p_session); |