aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/key.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/keys/key.c')
-rw-r--r--security/keys/key.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/security/keys/key.c b/security/keys/key.c
index 455c04d80bbb..83da68d98b40 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -660,14 +660,11 @@ not_found:
660 goto error; 660 goto error;
661 661
662found: 662found:
663 /* pretend it doesn't exist if it is awaiting deletion */ 663 /* A key is allowed to be looked up only if someone still owns a
664 if (refcount_read(&key->usage) == 0) 664 * reference to it - otherwise it's awaiting the gc.
665 goto not_found;
666
667 /* this races with key_put(), but that doesn't matter since key_put()
668 * doesn't actually change the key
669 */ 665 */
670 __key_get(key); 666 if (!refcount_inc_not_zero(&key->usage))
667 goto not_found;
671 668
672error: 669error:
673 spin_unlock(&key_serial_lock); 670 spin_unlock(&key_serial_lock);
@@ -966,12 +963,11 @@ int key_update(key_ref_t key_ref, const void *payload, size_t plen)
966 /* the key must be writable */ 963 /* the key must be writable */
967 ret = key_permission(key_ref, KEY_NEED_WRITE); 964 ret = key_permission(key_ref, KEY_NEED_WRITE);
968 if (ret < 0) 965 if (ret < 0)
969 goto error; 966 return ret;
970 967
971 /* attempt to update it if supported */ 968 /* attempt to update it if supported */
972 ret = -EOPNOTSUPP;
973 if (!key->type->update) 969 if (!key->type->update)
974 goto error; 970 return -EOPNOTSUPP;
975 971
976 memset(&prep, 0, sizeof(prep)); 972 memset(&prep, 0, sizeof(prep));
977 prep.data = payload; 973 prep.data = payload;