Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

David Howells and committed by
James Morris
7845bc39 24942c8e

+4
+1
include/linux/key-type.h
··· 92 92 93 93 /* internal fields */ 94 94 struct list_head link; /* link in types list */ 95 + struct lock_class_key lock_class; /* key->sem lock class */ 95 96 }; 96 97 97 98 extern struct key_type key_type_keyring;
+3
security/keys/key.c
··· 291 291 292 292 atomic_set(&key->usage, 1); 293 293 init_rwsem(&key->sem); 294 + lockdep_set_class(&key->sem, &type->lock_class); 294 295 key->type = type; 295 296 key->user = user; 296 297 key->quotalen = quotalen; ··· 946 945 { 947 946 struct key_type *p; 948 947 int ret; 948 + 949 + memset(&ktype->lock_class, 0, sizeof(ktype->lock_class)); 949 950 950 951 ret = -EEXIST; 951 952 down_write(&key_types_sem);