aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2011-11-16 06:15:54 -0500
committerJames Morris <jmorris@namei.org>2011-11-16 17:35:32 -0500
commit7845bc3964756240863ae453ffe4f7ee27ddc954 (patch)
tree3a3b9bf568184a3ae82bc581b63e1576ce99d7c8
parent24942c8e5cc8696064ee207ff29d4cf21f70dafc (diff)
KEYS: Give key types their own lockdep class for key->sem
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>
-rw-r--r--include/linux/key-type.h1
-rw-r--r--security/keys/key.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/key-type.h b/include/linux/key-type.h
index 9efd081bb31e..39e3c082c49d 100644
--- a/include/linux/key-type.h
+++ b/include/linux/key-type.h
@@ -92,6 +92,7 @@ struct key_type {
92 92
93 /* internal fields */ 93 /* internal fields */
94 struct list_head link; /* link in types list */ 94 struct list_head link; /* link in types list */
95 struct lock_class_key lock_class; /* key->sem lock class */
95}; 96};
96 97
97extern struct key_type key_type_keyring; 98extern struct key_type key_type_keyring;
diff --git a/security/keys/key.c b/security/keys/key.c
index 4414abddcb5b..4f64c7267afb 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -291,6 +291,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
291 291
292 atomic_set(&key->usage, 1); 292 atomic_set(&key->usage, 1);
293 init_rwsem(&key->sem); 293 init_rwsem(&key->sem);
294 lockdep_set_class(&key->sem, &type->lock_class);
294 key->type = type; 295 key->type = type;
295 key->user = user; 296 key->user = user;
296 key->quotalen = quotalen; 297 key->quotalen = quotalen;
@@ -946,6 +947,8 @@ int register_key_type(struct key_type *ktype)
946 struct key_type *p; 947 struct key_type *p;
947 int ret; 948 int ret;
948 949
950 memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
951
949 ret = -EEXIST; 952 ret = -EEXIST;
950 down_write(&key_types_sem); 953 down_write(&key_types_sem);
951 954