aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2010-04-30 09:32:28 -0400
committerJames Morris <jmorris@namei.org>2010-05-05 20:56:52 -0400
commit553d603c8fce8cf727eb26e4bf6b9549cd4623f1 (patch)
tree137d9976ac663371d5f4f9ccf59ef4fb1ea9bc88 /security
parent0ffbe2699cda6afbe08501098dff8a8c2fe6ae09 (diff)
KEYS: keyring_serialise_link_sem is only needed for keyring->keyring links
keyring_serialise_link_sem is only needed for keyring->keyring links as it's used to prevent cycle detection from being avoided by parallel keyring additions. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
-rw-r--r--security/keys/keyring.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index 2fb2bc9712ae..29de5ee3457b 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -705,13 +705,14 @@ int __key_link(struct key *keyring, struct key *key)
705 if (keyring->type != &key_type_keyring) 705 if (keyring->type != &key_type_keyring)
706 goto error; 706 goto error;
707 707
708 /* serialise link/link calls to prevent parallel calls causing a 708 /* do some special keyring->keyring link checks */
709 * cycle when applied to two keyring in opposite orders */
710 down_write(&keyring_serialise_link_sem);
711
712 /* check that we aren't going to create a cycle adding one keyring to
713 * another */
714 if (key->type == &key_type_keyring) { 709 if (key->type == &key_type_keyring) {
710 /* serialise link/link calls to prevent parallel calls causing
711 * a cycle when applied to two keyring in opposite orders */
712 down_write(&keyring_serialise_link_sem);
713
714 /* check that we aren't going to create a cycle adding one
715 * keyring to another */
715 ret = keyring_detect_cycle(keyring, key); 716 ret = keyring_detect_cycle(keyring, key);
716 if (ret < 0) 717 if (ret < 0)
717 goto error2; 718 goto error2;
@@ -814,7 +815,8 @@ int __key_link(struct key *keyring, struct key *key)
814done: 815done:
815 ret = 0; 816 ret = 0;
816error2: 817error2:
817 up_write(&keyring_serialise_link_sem); 818 if (key->type == &key_type_keyring)
819 up_write(&keyring_serialise_link_sem);
818error: 820error:
819 return ret; 821 return ret;
820 822