Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/rump/librump/rumpkern rump: don't touch p_nlwps without ...
details: https://anonhg.NetBSD.org/src/rev/e6c910e4279c
branches: trunk
changeset: 372236:e6c910e4279c
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Wed Nov 02 09:01:42 2022 +0000
description:
rump: don't touch p_nlwps without holding p_lock
There was a race condition on p_nlwps. Heavy thread switching could
cause a kernel panic like:
panic: kernel diagnostic assertion "LIST_EMPTY(&p->p_lwps)" failed:
file "(hidden)/src/lib/librump/../../sys/rump/librump/rumpkern/lwproc.c", line 177
diffstat:
sys/rump/librump/rumpkern/lwproc.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diffs (48 lines):
diff -r a7caf16cd4b5 -r e6c910e4279c sys/rump/librump/rumpkern/lwproc.c
--- a/sys/rump/librump/rumpkern/lwproc.c Wed Nov 02 08:37:32 2022 +0000
+++ b/sys/rump/librump/rumpkern/lwproc.c Wed Nov 02 09:01:42 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lwproc.c,v 1.51 2020/05/30 19:16:53 ad Exp $ */
+/* $NetBSD: lwproc.c,v 1.52 2022/11/02 09:01:42 ozaki-r Exp $ */
/*
* Copyright (c) 2010, 2011 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#define RUMP__CURLWP_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.51 2020/05/30 19:16:53 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lwproc.c,v 1.52 2022/11/02 09:01:42 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -348,6 +348,14 @@
{
struct lwp *l = kmem_zalloc(sizeof(*l), KM_SLEEP);
+ l->l_refcnt = 1;
+ l->l_proc = p;
+ l->l_stat = LSIDL;
+ l->l_mutex = &unruntime_lock;
+
+ proc_alloc_lwpid(p, l);
+
+ mutex_enter(p->p_lock);
/*
* Account the new lwp to the owner of the process.
* For some reason, NetBSD doesn't count the first lwp
@@ -357,14 +365,6 @@
chglwpcnt(kauth_cred_getuid(p->p_cred), 1);
}
- l->l_refcnt = 1;
- l->l_proc = p;
- l->l_stat = LSIDL;
- l->l_mutex = &unruntime_lock;
-
- proc_alloc_lwpid(p, l);
-
- mutex_enter(p->p_lock);
KASSERT((p->p_sflag & PS_RUMP_LWPEXIT) == 0);
LIST_INSERT_HEAD(&p->p_lwps, l, l_sibling);
Home |
Main Index |
Thread Index |
Old Index