Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Preserve the LWP ID of the calling thread on (v)for...



details:   https://anonhg.NetBSD.org/src/rev/06d9270e1b83
branches:  trunk
changeset: 846260:06d9270e1b83
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Nov 07 19:45:18 2019 +0000

description:
Preserve the LWP ID of the calling thread on (v)fork. This ensures that
_lwp_self() remains invariant as necessary for the locking in the
dynamic linker. Otherwise if a process creates a thread and forks from
it, the main thread of the parent would share the LWP ID of the main
thread of the child, even though they have different origins.

Partial fix for pkg/54192.

diffstat:

 sys/kern/kern_lwp.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 218d7dbf1ac1 -r 06d9270e1b83 sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c       Thu Nov 07 18:35:41 2019 +0000
+++ b/sys/kern/kern_lwp.c       Thu Nov 07 19:45:18 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lwp.c,v 1.205 2019/10/06 15:11:17 uwe Exp $       */
+/*     $NetBSD: kern_lwp.c,v 1.206 2019/11/07 19:45:18 joerg Exp $     */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -211,7 +211,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.205 2019/10/06 15:11:17 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.206 2019/11/07 19:45:18 joerg Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -902,6 +902,8 @@
        if ((flags & LWP_PIDLID) != 0) {
                lid = proc_alloc_pid(p2);
                l2->l_pflag |= LP_PIDLID;
+       } else if (p2->p_nlwps == 0) {
+               lid = l1->l_lid;
        } else {
                lid = 0;
        }



Home | Main Index | Thread Index | Old Index