Adjust KERNEL_ASSERT_UNLOCKED() to not assert during a panic.
authorclaudio <claudio@openbsd.org>
Mon, 30 Oct 2023 07:04:36 +0000 (07:04 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 30 Oct 2023 07:04:36 +0000 (07:04 +0000)
KERNEL_ASSERT_UNLOCKED calls _kernel_lock_held() which returns true
if panicstr || db_active which triggers this assert. Workaround this by
checking them before.

This will alter the following Syzkaller reports:
Reported-by: syzbot+169110a0815838ab5940@syzkaller.appspotmail.com
Reported-by: syzbot+3c2eced405b9de6f79c2@syzkaller.appspotmail.com
OK mpi@

sys/sys/systm.h

index dfea599..d831a46 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: systm.h,v 1.169 2023/10/17 00:04:02 cheloha Exp $     */
+/*     $OpenBSD: systm.h,v 1.170 2023/10/30 07:04:36 claudio Exp $     */
 /*     $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $        */
 
 /*-
@@ -420,7 +420,7 @@ int _kernel_lock_held(void);
 #define        KERNEL_LOCK()                   _kernel_lock()
 #define        KERNEL_UNLOCK()                 _kernel_unlock()
 #define        KERNEL_ASSERT_LOCKED()          KASSERT(_kernel_lock_held())
-#define        KERNEL_ASSERT_UNLOCKED()        KASSERT(!_kernel_lock_held())
+#define        KERNEL_ASSERT_UNLOCKED()        KASSERT(panicstr || db_active || !_kernel_lock_held())
 
 #else /* ! MULTIPROCESSOR */