diff options
author | Ingo Molnar <mingo@kernel.org> | 2017-06-22 10:57:28 +0200 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-06-22 10:57:28 +0200 |
commit | a4eb8b993554d374002663200bf5721f7f2ee259 (patch) | |
tree | e8934fdf72b4b09db9f514ae82bc81d03959b942 /security/keys/key.c | |
parent | 26179670a68b7b365fbfe38afb043dcd2e1a4678 (diff) | |
parent | 8d829b9bb878904f3419af8003176a12910b94e8 (diff) | |
download | blackbird-op-linux-a4eb8b993554d374002663200bf5721f7f2ee259.tar.gz blackbird-op-linux-a4eb8b993554d374002663200bf5721f7f2ee259.zip |
Merge branch 'linus' into x86/mm, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'security/keys/key.c')
-rw-r--r-- | security/keys/key.c | 16 |
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: 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; |