diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2011-07-30 10:26:04 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2011-07-30 10:26:04 +0000 |
commit | d5fa7e95862129f0133067252d6ea0dd787ffc09 (patch) | |
tree | e5337e2b03084a7df5dd183d81ed27c8a41c2f51 /sys/kern | |
parent | 7b6ca3a55d729b86d3cdf5c5d244e51dbfa14b16 (diff) |
When using rthreads, the thread that calls exit will be the last one to
actually exit. This means that the main thread will exit and free the
process group, which results in the thread dereferencing a null pointer
when it is woken back up. Avoid this by checking that the ps_pgrp is not
null before deferefencing it. Also expand the ps_session macro to avoid
hiding the dereference.
ok tedu@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/spec_vnops.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/spec_vnops.c b/sys/kern/spec_vnops.c index 8467ed72c45..29f6993b700 100644 --- a/sys/kern/spec_vnops.c +++ b/sys/kern/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.67 2011/07/05 05:37:07 deraadt Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.68 2011/07/30 10:26:03 jsing Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -489,10 +489,10 @@ spec_close(void *v) * if the reference count is 2 (this last descriptor * plus the session), release the reference from the session. */ - if (vcount(vp) == 2 && ap->a_p && - vp == ap->a_p->p_p->ps_session->s_ttyvp) { + if (vcount(vp) == 2 && ap->a_p && ap->a_p->p_p->ps_pgrp && + vp == ap->a_p->p_p->ps_pgrp->pg_session->s_ttyvp) { vrele(vp); - ap->a_p->p_p->ps_session->s_ttyvp = NULL; + ap->a_p->p_p->ps_pgrp->pg_session->s_ttyvp = NULL; } if (cdevsw[major(dev)].d_flags & D_CLONE) return (spec_close_clone(ap)); |