Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 553d603c authored by David Howells's avatar David Howells Committed by James Morris
Browse files

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: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 0ffbe269
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -705,13 +705,14 @@ int __key_link(struct key *keyring, struct key *key)
	if (keyring->type != &key_type_keyring)
		goto error;

	/* serialise link/link calls to prevent parallel calls causing a
	 * cycle when applied to two keyring in opposite orders */
	/* do some special keyring->keyring link checks */
	if (key->type == &key_type_keyring) {
		/* serialise link/link calls to prevent parallel calls causing
		 * a cycle when applied to two keyring in opposite orders */
		down_write(&keyring_serialise_link_sem);

	/* check that we aren't going to create a cycle adding one keyring to
	 * another */
	if (key->type == &key_type_keyring) {
		/* check that we aren't going to create a cycle adding one
		 * keyring to another */
		ret = keyring_detect_cycle(keyring, key);
		if (ret < 0)
			goto error2;
@@ -814,6 +815,7 @@ int __key_link(struct key *keyring, struct key *key)
done:
	ret = 0;
error2:
	if (key->type == &key_type_keyring)
		up_write(&keyring_serialise_link_sem);
error:
	return ret;