diff options
author | Peter Zijlstra <[email protected]> | 2017-03-01 16:23:30 +0100 |
---|---|---|
committer | Ingo Molnar <[email protected]> | 2017-03-02 09:00:38 +0100 |
commit | 7fb4a2cea6b18dab56d609530d077f168169ed6b (patch) | |
tree | 4b0e6b73918486e175841c1deb6ff72811add002 | |
parent | 2b232e0c3b3a09f3e33750aa20e314f1b80e5361 (diff) |
locking/lockdep: Add nest_lock integrity test
Boqun reported that hlock->references can overflow. Add a debug test
for that to generate a clear error when this happens.
Without this, lockdep is likely to report a mysterious failure on
unlock.
Reported-by: Boqun Feng <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Chris Wilson <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Nicolai Hähnle <[email protected]>
Cc: Paul E. McKenney <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: [email protected]
Signed-off-by: Ingo Molnar <[email protected]>
-rw-r--r-- | kernel/locking/lockdep.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c index 9812e5dd409e..c0ee8607c11e 100644 --- a/kernel/locking/lockdep.c +++ b/kernel/locking/lockdep.c @@ -3260,10 +3260,17 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, if (depth) { hlock = curr->held_locks + depth - 1; if (hlock->class_idx == class_idx && nest_lock) { - if (hlock->references) + if (hlock->references) { + /* + * Check: unsigned int references:12, overflow. + */ + if (DEBUG_LOCKS_WARN_ON(hlock->references == (1 << 12)-1)) + return 0; + hlock->references++; - else + } else { hlock->references = 2; + } return 1; } |