Module Name:    src
Committed By:   kamil
Date:           Sun Oct 13 03:50:26 UTC 2019

Modified Files:
        src/sys/kern: kern_sig.c

Log Message:
Avoid double lwp_exit() in eventswitch()

For the PTRACE_LWP_EXIT event, the eventswitch() call is triggered from
lwp_exit(). In the case of setting the program status to PS_WEXIT, do not
try to demise in place, by calling lwp_exit() as it causes panic.

In this scenario bail out from the function and resume the lwp_exit()
procedure.


To generate a diff of this commit:
cvs rdiff -u -r1.371 -r1.372 src/sys/kern/kern_sig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.371 src/sys/kern/kern_sig.c:1.372
--- src/sys/kern/kern_sig.c:1.371	Sun Oct 13 03:19:57 2019
+++ src/sys/kern/kern_sig.c	Sun Oct 13 03:50:26 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.371 2019/10/13 03:19:57 kamil Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.372 2019/10/13 03:50:26 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.371 2019/10/13 03:19:57 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.372 2019/10/13 03:50:26 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1614,6 +1614,12 @@ repeat:
 	if (__predict_false(ISSET(p->p_sflag, PS_WEXIT))) {
 		mutex_exit(p->p_lock);
 		mutex_exit(proc_lock);
+
+		if (pe_report_event == PTRACE_LWP_EXIT) {
+			/* Avoid double lwp_exit() and panic. */
+			return;
+		}
+
 		lwp_exit(l);
 		panic("eventswitch");
 		/* NOTREACHED */

Reply via email to