Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 89877e42827f16fa5f86b1df0c2860b1 > files > 2281

kernel-2.6.18-128.1.10.el5.src.rpm

From: Jeff Layton <jlayton@redhat.com>
Date: Tue, 26 Aug 2008 11:38:33 -0400
Subject: [security] key: fix lockdep warning when revoking auth
Message-id: 1219765117-21681-3-git-send-email-jlayton@redhat.com
O-Subject: [RHEL5.3 PATCH 2/6] BZ#453462: KEYS: fix lockdep warning when revoking auth key
Bugzilla: 453462
RH-Acked-by: David Howells <dhowells@redhat.com>

When we revoke an authorization key for a key that we've just instantiated
then we're usually holding the key sem for the newly instantiated key. This
can confuse lockdep, so tell it that we might nest.

This change was made upstream as part of a larger patch to change the
keys API to be asynchronous. That part really isn't needed for RHEL5, so
I just cherry-picked this delta.

diff --git a/security/keys/key.c b/security/keys/key.c
index 7b98397..d2e3535 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -901,9 +901,12 @@ void key_revoke(struct key *key)
 {
 	key_check(key);
 
-	/* make sure no one's trying to change or use the key when we mark
-	 * it */
-	down_write(&key->sem);
+	/* make sure no one's trying to change or use the key when we mark it
+	 * - we tell lockdep that we might nest because we might be revoking an
+	 *   authorisation key whilst holding the sem on a key we've just
+	 *   instantiated
+	 */
+	down_write_nested(&key->sem, 1);
 	set_bit(KEY_FLAG_REVOKED, &key->flags);
 
 	if (key->type->revoke)