diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2009-12-23 07:40:32 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2009-12-23 07:40:32 +0000 |
commit | 8640ed18d254c01ccd2e43c98334e3a84dbd726b (patch) | |
tree | 3e9adc9a98ceed6febeb0afdeac0ce275e7b5b23 | |
parent | 1a1674c6dc27b27df4dd59ed6187fc8837f3d38b (diff) |
The process's rdomain should be, well, per-process and not per-rthread,
so put it in struct process instead of struct proc. While at it,
move the p_emul member inside struct proc so that it gets copied
automatically instead of requiring manual assignment.
ok deraadt@
-rw-r--r-- | sys/kern/init_main.c | 8 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 12 | ||||
-rw-r--r-- | sys/kern/uipc_syscalls.c | 10 | ||||
-rw-r--r-- | sys/netinet/in_pcb.c | 4 | ||||
-rw-r--r-- | sys/netinet/ip_output.c | 5 | ||||
-rw-r--r-- | sys/sys/proc.h | 8 |
6 files changed, 25 insertions, 22 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 720c379abf6..f9afb875ce0 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.163 2009/11/27 20:05:50 guenther Exp $ */ +/* $OpenBSD: init_main.c,v 1.164 2009/12/23 07:40:31 guenther Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -264,6 +264,9 @@ main(void *framep) process0.ps_refcnt = 1; p->p_p = &process0; + /* Set the default routing domain. */ + process0.ps_rdomain = 0; + LIST_INSERT_HEAD(&allproc, p, p_list); p->p_pgrp = &pgrp0; LIST_INSERT_HEAD(PIDHASH(0), p, p_hash); @@ -314,9 +317,6 @@ main(void *framep) limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3; limit0.p_refcnt = 1; - /* Set the default routing domain. */ - p->p_rdomain = 0; - /* Allocate a prototype map so we have something to fork. */ uvmspace_init(&vmspace0, pmap_kernel(), round_page(VM_MIN_ADDRESS), trunc_page(VM_MAX_ADDRESS), TRUE, TRUE); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index b390dcdf2b5..ac6721c2a4c 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_fork.c,v 1.105 2009/11/27 20:05:50 guenther Exp $ */ +/* $OpenBSD: kern_fork.c,v 1.106 2009/12/23 07:40:31 guenther Exp $ */ /* $NetBSD: kern_fork.c,v 1.29 1996/02/09 18:59:34 christos Exp $ */ /* @@ -153,15 +153,19 @@ sys_rfork(struct proc *p, void *v, register_t *retval) * Allocate and initialize a new process. */ void -process_new(struct proc *newproc, struct proc *parent) +process_new(struct proc *newproc, struct proc *parentproc) { - struct process *pr; + struct process *pr, *parent; pr = pool_get(&process_pool, PR_WAITOK); pr->ps_mainproc = newproc; TAILQ_INIT(&pr->ps_threads); TAILQ_INSERT_TAIL(&pr->ps_threads, newproc, p_thr_link); pr->ps_refcnt = 1; + + parent = parentproc->p_p; + pr->ps_rdomain = parent->ps_rdomain; + newproc->p_p = pr; } @@ -265,8 +269,6 @@ fork1(struct proc *p1, int exitsig, int flags, void *stack, size_t stacksize, * Increase reference counts on shared objects. * The p_stats and p_sigacts substructs are set in vm_fork. */ - p2->p_emul = p1->p_emul; - p2->p_rdomain = p1->p_rdomain; if (p1->p_flag & P_PROFIL) startprofclock(p2); atomic_setbits_int(&p2->p_flag, p1->p_flag & (P_SUGID | P_SUGIDEXEC)); diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index d5c190b0336..912b3be61f6 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.73 2009/11/27 20:05:50 guenther Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.74 2009/12/23 07:40:31 guenther Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -1105,14 +1105,14 @@ sys_setrdomain(struct proc *p, void *v, register_t *retval) rdomain = SCARG(uap, rdomain); - if (p->p_rdomain == (u_int)rdomain) + if (p->p_p->ps_rdomain == (u_int)rdomain) return (0); - if (p->p_rdomain != 0 && (error = suser(p, 0)) != 0) + if (p->p_p->ps_rdomain != 0 && (error = suser(p, 0)) != 0) return (error); if (rdomain < 0 || !rtable_exists((u_int)rdomain)) return (EINVAL); - p->p_rdomain = (u_int)rdomain; + p->p_p->ps_rdomain = (u_int)rdomain; return (0); } @@ -1120,6 +1120,6 @@ sys_setrdomain(struct proc *p, void *v, register_t *retval) int sys_getrdomain(struct proc *p, void *v, register_t *retval) { - *retval = (int)p->p_rdomain; + *retval = (int)p->p_p->ps_rdomain; return (0); } diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 74247a92ac7..848ed63bcda 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.109 2009/11/27 20:05:50 guenther Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.110 2009/12/23 07:40:31 guenther Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -198,7 +198,7 @@ in_pcballoc(so, v) inp->inp_seclevel[SL_ESP_TRANS] = ipsec_esp_trans_default_level; inp->inp_seclevel[SL_ESP_NETWORK] = ipsec_esp_network_default_level; inp->inp_seclevel[SL_IPCOMP] = ipsec_ipcomp_default_level; - inp->inp_rdomain = curproc->p_rdomain; + inp->inp_rdomain = curproc->p_p->ps_rdomain; s = splnet(); CIRCLEQ_INSERT_HEAD(&table->inpt_queue, inp, inp_queue); LIST_INSERT_HEAD(INPCBLHASH(table, inp->inp_lport, diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 68f73f978e9..7a37d4016d7 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.201 2009/12/11 17:50:57 deraadt Exp $ */ +/* $OpenBSD: ip_output.c,v 1.202 2009/12/23 07:40:31 guenther Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -1423,7 +1423,8 @@ ip_ctloutput(op, so, level, optname, mp) break; } rtid = *mtod(m, u_int *); - if (p->p_rdomain != 0 && p->p_rdomain != rtid && + if (p->p_p->ps_rdomain != 0 && + p->p_p->ps_rdomain != rtid && (error = suser(p, 0)) != 0) { error = EACCES; break; diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 7484c8cc304..0c3b8d8413a 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.121 2009/12/20 23:36:04 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.122 2009/12/23 07:40:31 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -145,6 +145,8 @@ struct process { TAILQ_HEAD(,proc) ps_threads; /* Threads in this process. */ int ps_refcnt; /* Number of references. */ + + u_int ps_rdomain; /* Process routing domain. */ }; #else struct process; @@ -220,7 +222,6 @@ struct proc { struct vnode *p_textvp; /* Vnode of executable. */ - struct emul *p_emul; /* Emulation information */ void *p_emuldata; /* Per-process emulation data, or */ /* NULL. Malloc type M_EMULDATA */ struct klist p_klist; /* knotes attached to this process */ @@ -243,6 +244,7 @@ struct proc { char p_nice; /* Process "nice" value. */ char p_comm[MAXCOMLEN+1]; + struct emul *p_emul; /* Emulation information */ struct pgrp *p_pgrp; /* Pointer to process group. */ vaddr_t p_sigcode; /* user pointer to the signal code. */ @@ -255,8 +257,6 @@ struct proc { u_short p_xstat; /* Exit status for wait; also stop signal. */ u_short p_acflag; /* Accounting flags. */ struct rusage *p_ru; /* Exit information. XXX */ - - u_int p_rdomain; /* Process routing domain. */ }; #define p_session p_pgrp->pg_session |