diff options
| author | 2013-03-30 06:32:25 +0000 | |
|---|---|---|
| committer | 2013-03-30 06:32:25 +0000 | |
| commit | 7359b57a36e7484bf0d7e0dac4ae14ec848b6f3f (patch) | |
| tree | e59b4d5fb86db7dd15f5c98ff48114314c9c6ebc /sys/kern/kern_exit.c | |
| parent | Remove mentioning specific systems with embedded Ethernet chipsets or (diff) | |
| download | wireguard-openbsd-7359b57a36e7484bf0d7e0dac4ae14ec848b6f3f.tar.xz wireguard-openbsd-7359b57a36e7484bf0d7e0dac4ae14ec848b6f3f.zip | |
vrele() is a tricky beast. it can sleep if the refcount hits zero,
leaving us with a free type function that isn't atomic. deal with this
by erasing any reachable pointers to the vnode first, then free it.
ok deraadt guenther
Diffstat (limited to 'sys/kern/kern_exit.c')
| -rw-r--r-- | sys/kern/kern_exit.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index 2681876b848..c63330165ac 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.120 2013/03/28 16:55:25 deraadt Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.121 2013/03/30 06:32:25 tedu Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -120,6 +120,7 @@ exit1(struct proc *p, int rv, int flags) { struct process *pr, *qr, *nqr; struct rusage *rup; + struct vnode *ovp; if (p->p_pid == 1) panic("init died (signal %d, exit %d)", @@ -216,9 +217,10 @@ exit1(struct proc *p, int rv, int flags) VOP_REVOKE(sp->s_ttyvp, REVOKEALL); } - if (sp->s_ttyvp) - vrele(sp->s_ttyvp); + ovp = sp->s_ttyvp; sp->s_ttyvp = NULL; + if (ovp) + vrele(ovp); /* * s_ttyp is not zero'd; we use this to * indicate that the session once had a @@ -604,6 +606,7 @@ void proc_zap(struct proc *p) { struct process *pr = p->p_p; + struct vnode *otvp; /* * Finally finished with old proc entry. @@ -624,8 +627,10 @@ proc_zap(struct proc *p) /* * Release reference to text vnode */ - if (p->p_textvp) - vrele(p->p_textvp); + otvp = p->p_textvp; + p->p_textvp = NULL; + if (otvp) + vrele(otvp); /* * Remove us from our process list, possibly killing the process |
