Make rw_exit() always succeed after a panic.
authormpi <mpi@openbsd.org>
Mon, 18 Dec 2017 10:05:43 +0000 (10:05 +0000)
committermpi <mpi@openbsd.org>
Mon, 18 Dec 2017 10:05:43 +0000 (10:05 +0000)
Prevents a deadlock in if_downall() when rw_enter() succeed without
really grabbing the lock.

Reported by and ok phessler@

sys/kern/kern_rwlock.c

index 399c352..88228a2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: kern_rwlock.c,v 1.32 2017/10/24 08:53:15 mpi Exp $    */
+/*     $OpenBSD: kern_rwlock.c,v 1.33 2017/12/18 10:05:43 mpi Exp $    */
 
 /*
  * Copyright (c) 2002, 2003 Artur Grabowski <art@openbsd.org>
@@ -287,6 +287,10 @@ _rw_exit(struct rwlock *rwl LOCK_FL_VARS)
        int wrlock = owner & RWLOCK_WRLOCK;
        unsigned long set;
 
+       /* Avoid deadlocks after panic */
+       if (panicstr)
+               return;
+
        if (wrlock)
                rw_assert_wrlock(rwl);
        else