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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 11 Apr 2019 10:26:12 -0700
From:   Bart Van Assche <bvanassche@....org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org, Bart Van Assche <bvanassche@....org>,
        Will Deacon <will.deacon@....com>,
        Waiman Long <longman@...hat.com>, shenghui <shhuiw@...mail.com>
Subject: [PATCH] locking/lockdep: Make lockdep_register_key() ignore 'debug_locks'

If lockdep_register_key() and lockdep_unregister_key() are called with
debug_locks == false then the following warning is reported:

WARNING: CPU: 2 PID: 15145 at kernel/locking/lockdep.c:4920 lockdep_unregister_key+0x1ad/0x240

That warning is reported because lockdep_unregister_key() ignores the
value of 'debug_locks' and because the behavior of lockdep_register_key()
depends on whether or not 'debug_locks' is set. Fix this inconsistency
by making lockdep_register_key() unconditionally register lock keys.

Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Will Deacon <will.deacon@....com>
Cc: Waiman Long <longman@...hat.com>
Cc: shenghui <shhuiw@...mail.com>
Reported-by: shenghui <shhuiw@...mail.com>
Fixes: a0b0fd53e1e6 ("locking/lockdep: Free lock classes that are no longer in use") # v5.1-rc1.
Signed-off-by: Bart Van Assche <bvanassche@....org>
---
 kernel/locking/lockdep.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/locking/lockdep.c b/kernel/locking/lockdep.c
index d2d65bbfae01..a228509b62f1 100644
--- a/kernel/locking/lockdep.c
+++ b/kernel/locking/lockdep.c
@@ -1027,15 +1027,16 @@ void lockdep_register_key(struct lock_class_key *key)
 	hash_head = keyhashentry(key);
 
 	raw_local_irq_save(flags);
-	if (!graph_lock())
-		goto restore_irqs;
+	arch_spin_lock(&lockdep_lock);
+	current->lockdep_recursion = 1;
 	hlist_for_each_entry_rcu(k, hash_head, hash_entry) {
 		if (WARN_ON_ONCE(k == key))
 			goto out_unlock;
 	}
 	hlist_add_head_rcu(&key->hash_entry, hash_head);
 out_unlock:
-	graph_unlock();
+	current->lockdep_recursion = 0;
+	arch_spin_unlock(&lockdep_lock);
 restore_irqs:
 	raw_local_irq_restore(flags);
 }
-- 
2.21.0.196.g041f5ea1cf98

Powered by blists - more mailing lists