lkml.org 
[lkml]   [2011]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 4/4] lockdep: fix race condition in __lock_set_class()
Date
When someone call lock_set_class() with valid key, nothing
protect the initializing of 'lockdep_map'; thus could lead
to flase positive warning from lockdep (such as "key not in
.data!"). This patch cure that potential issue.

Signed-off-by: Yong Zhang <yong.zhang0@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
---
kernel/lockdep.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 3af87ad..fd4d816 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -3290,8 +3290,12 @@ __lock_set_class(struct lockdep_map *lock, const char *name,
found_it:
/* optimizing for lock_set_subclass() */
if (key) {
- lockdep_init_map(lock, name, key, 0);
- register_lock_class(lock, subclass, 0, 0);
+ if (!graph_lock())
+ return 0;
+
+ __lockdep_init_map(lock, name, key, 0);
+ /* will release graph_lock() there */
+ register_lock_class(lock, subclass, 0, 1);
}

curr->lockdep_depth = i;
--
1.7.5.4


\
 
 \ /
  Last update: 2011-11-04 10:31    [W:0.141 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site