Commit 3aa416b0 authored by Gregory Haskins's avatar Gregory Haskins Committed by Peter Zijlstra

lockdep: fix mismatched lockdep_depth/curr_chain_hash

It is possible for the current->curr_chain_key to become inconsistent with the
current index if the chain fails to validate.  The end result is that future
lock_acquire() operations may inadvertently fail to find a hit in the cache
resulting in a new node being added to the graph for every acquire.
Signed-off-by: default avatarGregory Haskins <ghaskins@novell.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 94c61c0a
...@@ -1521,7 +1521,7 @@ static inline int lookup_chain_cache(u64 chain_key, struct lock_class *class) ...@@ -1521,7 +1521,7 @@ static inline int lookup_chain_cache(u64 chain_key, struct lock_class *class)
} }
static int validate_chain(struct task_struct *curr, struct lockdep_map *lock, static int validate_chain(struct task_struct *curr, struct lockdep_map *lock,
struct held_lock *hlock, int chain_head) struct held_lock *hlock, int chain_head, u64 chain_key)
{ {
/* /*
* Trylock needs to maintain the stack of held locks, but it * Trylock needs to maintain the stack of held locks, but it
...@@ -1534,7 +1534,7 @@ static int validate_chain(struct task_struct *curr, struct lockdep_map *lock, ...@@ -1534,7 +1534,7 @@ static int validate_chain(struct task_struct *curr, struct lockdep_map *lock,
* graph_lock for us) * graph_lock for us)
*/ */
if (!hlock->trylock && (hlock->check == 2) && if (!hlock->trylock && (hlock->check == 2) &&
lookup_chain_cache(curr->curr_chain_key, hlock->class)) { lookup_chain_cache(chain_key, hlock->class)) {
/* /*
* Check whether last held lock: * Check whether last held lock:
* *
...@@ -1576,7 +1576,7 @@ static int validate_chain(struct task_struct *curr, struct lockdep_map *lock, ...@@ -1576,7 +1576,7 @@ static int validate_chain(struct task_struct *curr, struct lockdep_map *lock,
#else #else
static inline int validate_chain(struct task_struct *curr, static inline int validate_chain(struct task_struct *curr,
struct lockdep_map *lock, struct held_lock *hlock, struct lockdep_map *lock, struct held_lock *hlock,
int chain_head) int chain_head, u64 chain_key)
{ {
return 1; return 1;
} }
...@@ -2450,11 +2450,11 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass, ...@@ -2450,11 +2450,11 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
chain_head = 1; chain_head = 1;
} }
chain_key = iterate_chain_key(chain_key, id); chain_key = iterate_chain_key(chain_key, id);
curr->curr_chain_key = chain_key;
if (!validate_chain(curr, lock, hlock, chain_head)) if (!validate_chain(curr, lock, hlock, chain_head, chain_key))
return 0; return 0;
curr->curr_chain_key = chain_key;
curr->lockdep_depth++; curr->lockdep_depth++;
check_chain_key(curr); check_chain_key(curr);
#ifdef CONFIG_DEBUG_LOCKDEP #ifdef CONFIG_DEBUG_LOCKDEP
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment