svn commit: r243900 - head/sys/kern
Attilio Rao
attilio at FreeBSD.org
Wed Dec 5 15:11:02 UTC 2012
Author: attilio
Date: Wed Dec 5 15:11:01 2012
New Revision: 243900
URL: http://svnweb.freebsd.org/changeset/base/243900
Log:
Check for lockmgr recursion in case of disown and downgrade and panic
also in !debugging kernel rather than having "undefined" behaviour.
Tested by: avg
MFC after: 1 week
Modified:
head/sys/kern/kern_lock.c
Modified: head/sys/kern/kern_lock.c
==============================================================================
--- head/sys/kern/kern_lock.c Wed Dec 5 13:57:00 2012 (r243899)
+++ head/sys/kern/kern_lock.c Wed Dec 5 15:11:01 2012 (r243900)
@@ -934,9 +934,19 @@ __lockmgr_args(struct lock *lk, u_int fl
}
break;
case LK_DOWNGRADE:
- _lockmgr_assert(lk, KA_XLOCKED | KA_NOTRECURSED, file, line);
+ _lockmgr_assert(lk, KA_XLOCKED, file, line);
LOCK_LOG_LOCK("XDOWNGRADE", &lk->lock_object, 0, 0, file, line);
WITNESS_DOWNGRADE(&lk->lock_object, 0, file, line);
+
+ /*
+ * Panic if the lock is recursed.
+ */
+ if (lockmgr_xlocked(lk) && lockmgr_recursed(lk)) {
+ if (flags & LK_INTERLOCK)
+ class->lc_unlock(ilk);
+ panic("%s: downgrade a recursed lockmgr %s @ %s:%d\n",
+ __func__, iwmesg, file, line);
+ }
TD_SLOCKS_INC(curthread);
/*
@@ -1254,7 +1264,14 @@ _lockmgr_disown(struct lock *lk, const c
return;
tid = (uintptr_t)curthread;
- _lockmgr_assert(lk, KA_XLOCKED | KA_NOTRECURSED, file, line);
+ _lockmgr_assert(lk, KA_XLOCKED, file, line);
+
+ /*
+ * Panic if the lock is recursed.
+ */
+ if (lockmgr_xlocked(lk) && lockmgr_recursed(lk))
+ panic("%s: disown a recursed lockmgr @ %s:%d\n",
+ __func__, file, line);
/*
* If the owner is already LK_KERNPROC just skip the whole operation.
More information about the svn-src-head
mailing list