diff options
| author | 2018-03-27 08:32:29 +0000 | |
|---|---|---|
| committer | 2018-03-27 08:32:29 +0000 | |
| commit | 1bb039c847b6dea01b519a8eea6248ec332aedae (patch) | |
| tree | 3db9a7923de3356b51be2a605881eef15f506df2 /sys/kern/kern_lock.c | |
| parent | Use a goto to merge multiple error blocks in sosplice(). (diff) | |
| download | wireguard-openbsd-1bb039c847b6dea01b519a8eea6248ec332aedae.tar.xz wireguard-openbsd-1bb039c847b6dea01b519a8eea6248ec332aedae.zip | |
Try harder to execute code protected by mutexes after entering ddb(4).
Should prevent a panic after panic reported by mlarkin@.
ok mlarkin@, visa@
Diffstat (limited to 'sys/kern/kern_lock.c')
| -rw-r--r-- | sys/kern/kern_lock.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index f108c7393e9..01e0a567b82 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_lock.c,v 1.60 2018/03/20 15:45:32 mpi Exp $ */ +/* $OpenBSD: kern_lock.c,v 1.61 2018/03/27 08:32:29 mpi Exp $ */ /* * Copyright (c) 2017 Visa Hankala @@ -262,6 +262,10 @@ __mtx_enter(struct mutex *mtx) int nticks = __mp_lock_spinout; #endif + /* Avoid deadlocks after panic or in DDB */ + if (panicstr || db_active) + return; + while (__mtx_enter_try(mtx) == 0) { CPU_BUSY_CYCLE(); @@ -310,6 +314,10 @@ __mtx_enter(struct mutex *mtx) { struct cpu_info *ci = curcpu(); + /* Avoid deadlocks after panic or in DDB */ + if (panicstr || db_active) + return; + #ifdef DIAGNOSTIC if (__predict_false(mtx->mtx_owner == ci)) panic("mtx %p: locking against myself", mtx); @@ -338,6 +346,10 @@ __mtx_leave(struct mutex *mtx) { int s; + /* Avoid deadlocks after panic or in DDB */ + if (panicstr || db_active) + return; + MUTEX_ASSERT_LOCKED(mtx); #ifdef DIAGNOSTIC |
