]> git.karo-electronics.de Git - linux-beck.git/commitdiff
KEYS: Give key types their own lockdep class for key->sem
authorDavid Howells <dhowells@redhat.com>
Wed, 16 Nov 2011 11:15:54 +0000 (11:15 +0000)
committerJames Morris <jmorris@namei.org>
Wed, 16 Nov 2011 22:35:32 +0000 (09:35 +1100)
Give keys their own lockdep class to differentiate them from each other in case
a key of one type has to refer to a key of another type.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
include/linux/key-type.h
security/keys/key.c

index 9efd081bb31e19b23f98935b9673dd89b53924af..39e3c082c49d489a32ab781e080b28236661877f 100644 (file)
@@ -92,6 +92,7 @@ struct key_type {
 
        /* internal fields */
        struct list_head        link;           /* link in types list */
+       struct lock_class_key   lock_class;     /* key->sem lock class */
 };
 
 extern struct key_type key_type_keyring;
index 4414abddcb5bfd6951d168018990c6df2567b901..4f64c7267afb64332db0e6218754a8d17190c870 100644 (file)
@@ -291,6 +291,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
 
        atomic_set(&key->usage, 1);
        init_rwsem(&key->sem);
+       lockdep_set_class(&key->sem, &type->lock_class);
        key->type = type;
        key->user = user;
        key->quotalen = quotalen;
@@ -946,6 +947,8 @@ int register_key_type(struct key_type *ktype)
        struct key_type *p;
        int ret;
 
+       memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
+
        ret = -EEXIST;
        down_write(&key_types_sem);