lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1320398790-21663-3-git-send-email-yong.zhang0@gmail.com>
Date:	Fri,  4 Nov 2011 17:26:28 +0800
From:	Yong Zhang <yong.zhang0@...il.com>
To:	linux-kernel@...r.kernel.org
Cc:	sergey.senozhatsky@...il.com, bp@...en8.de,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Ingo Molnar <mingo@...e.hu>
Subject: [RFC PATCH 2/4] lockdep: Let register_lock_class() can be called with/without graph_lock

Will be used in later patch which fix some race condition in
lock_set_class().

Signed-off-by: Yong Zhang <yong.zhang0@...il.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Ingo Molnar <mingo@...e.hu>
---
 kernel/lockdep.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 4a16b0a..e7d38fa 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -711,9 +711,13 @@ look_up_lock_class(struct lockdep_map *lock, unsigned int subclass)
  * Register a lock's class in the hash-table, if the class is not present
  * yet. Otherwise we look it up. We cache the result in the lock object
  * itself, so actual lookup of the hash should be once per lock object.
+ *
+ * NOTE: register_lock_class() can be called with/without graph_lock hold
+ *	 depending on @locked. But it will release graph_lock before return.
  */
 static inline struct lock_class *
-register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
+register_lock_class(struct lockdep_map *lock, unsigned int subclass,
+		    int force, int locked)
 {
 	struct lockdep_subclass_key *key;
 	struct list_head *hash_head;
@@ -741,7 +745,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
 	hash_head = classhashentry(key);
 
 	raw_local_irq_save(flags);
-	if (!graph_lock()) {
+	if (!locked && !graph_lock()) {
 		raw_local_irq_restore(flags);
 		return NULL;
 	}
@@ -2986,7 +2990,7 @@ void lockdep_init_map(struct lockdep_map *lock, const char *name,
 		return;
 
 	if (subclass)
-		register_lock_class(lock, subclass, 1);
+		register_lock_class(lock, subclass, 1, 0);
 }
 EXPORT_SYMBOL_GPL(lockdep_init_map);
 
@@ -3032,7 +3036,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
 	 * Not cached?
 	 */
 	if (unlikely(!class)) {
-		class = register_lock_class(lock, subclass, 0);
+		class = register_lock_class(lock, subclass, 0, 0);
 		if (!class)
 			return 0;
 	}
@@ -3276,7 +3280,7 @@ found_it:
 	/* optimizing for lock_set_subclass() */
 	if (key) {
 		lockdep_init_map(lock, name, key, 0);
-		register_lock_class(lock, subclass, 0);
+		register_lock_class(lock, subclass, 0, 0);
 	}
 
 	curr->lockdep_depth = i;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ