X-Git-Url: https://git.kernelconcepts.de/?a=blobdiff_plain;f=security%2Fkeys%2Fkey.c;h=83da68d98b40b452a1c8b37121a6ca270387d4f6;hb=92347cfd62c174ab91ad97dd4bfbaa1d4aa28e67;hp=455c04d80bbbf27a7b20433708f35fde1ad26ffb;hpb=26c5eaa1326e9703effd01e7cc3cc0d4ad4b3c19;p=karo-tx-linux.git 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: goto error; found: - /* pretend it doesn't exist if it is awaiting deletion */ - if (refcount_read(&key->usage) == 0) - goto not_found; - - /* this races with key_put(), but that doesn't matter since key_put() - * doesn't actually change the key + /* A key is allowed to be looked up only if someone still owns a + * reference to it - otherwise it's awaiting the gc. */ - __key_get(key); + if (!refcount_inc_not_zero(&key->usage)) + goto not_found; error: spin_unlock(&key_serial_lock); @@ -966,12 +963,11 @@ int key_update(key_ref_t key_ref, const void *payload, size_t plen) /* the key must be writable */ ret = key_permission(key_ref, KEY_NEED_WRITE); if (ret < 0) - goto error; + return ret; /* attempt to update it if supported */ - ret = -EOPNOTSUPP; if (!key->type->update) - goto error; + return -EOPNOTSUPP; memset(&prep, 0, sizeof(prep)); prep.data = payload;