Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Correct inversed condition for dying process in sig...



details:   https://anonhg.NetBSD.org/src/rev/7b3ed23c02d1
branches:  trunk
changeset: 451958:7b3ed23c02d1
user:      kamil <kamil%NetBSD.org@localhost>
date:      Thu Jun 13 00:07:19 2019 +0000

description:
Correct inversed condition for dying process in sigswitch()

If a process is exiting and it was not asked to relock proc_lock, do not
free the mutex as it causes panic. This bug is a timing bug as the faulty
condition is not deterministic and fires only somtimes, but is quickly
triggerable when executed in an infinite loop.

Detected and reported with LLDB test-suite by <mgorny>

diffstat:

 sys/kern/kern_sig.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 5ecb2ef5d9a5 -r 7b3ed23c02d1 sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Wed Jun 12 23:17:40 2019 +0000
+++ b/sys/kern/kern_sig.c       Thu Jun 13 00:07:19 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.359 2019/06/04 11:54:03 kamil Exp $     */
+/*     $NetBSD: kern_sig.c,v 1.360 2019/06/13 00:07:19 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.359 2019/06/04 11:54:03 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.360 2019/06/13 00:07:19 kamil Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1654,7 +1654,7 @@
         */
        if (__predict_false(ISSET(p->p_sflag, PS_WEXIT))) {
                mutex_exit(p->p_lock);
-               if (relock) {
+               if (!relock) {
                        mutex_exit(proc_lock);
                }
                lwp_exit(l);



Home | Main Index | Thread Index | Old Index