summaryrefslogtreecommitdiffstats
path: root/sys/kern/init_main.c
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2008-10-09 06:31:53 +0000
committerguenther <guenther@openbsd.org>2008-10-09 06:31:53 +0000
commit5de831d5975031cedc04a30f1f47cd7c4c9b119f (patch)
treec0eb31105d3fe896ea9f21a93003523c50b38365 /sys/kern/init_main.c
parentsupport setting PermitEmptyPasswords in a Match block (diff)
downloadwireguard-openbsd-5de831d5975031cedc04a30f1f47cd7c4c9b119f.tar.xz
wireguard-openbsd-5de831d5975031cedc04a30f1f47cd7c4c9b119f.zip
Put a reference count in struct process to prevent use-after-free
if the main thread reaches the reaper ahead of some other thread in the process. ok art@ tedu@
Diffstat (limited to 'sys/kern/init_main.c')
-rw-r--r--sys/kern/init_main.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index d50617150d1..6c119c427c6 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init_main.c,v 1.150 2008/06/09 07:07:16 djm Exp $ */
+/* $OpenBSD: init_main.c,v 1.151 2008/10/09 06:31:53 guenther Exp $ */
/* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */
/*
@@ -256,6 +256,7 @@ main(void *framep)
process0.ps_mainproc = p;
TAILQ_INIT(&process0.ps_threads);
TAILQ_INSERT_TAIL(&process0.ps_threads, p, p_thr_link);
+ process0.ps_refcnt = 1;
p->p_p = &process0;
LIST_INSERT_HEAD(&allproc, p, p_list);