diff options
| author | Eric Biggers <ebiggers@google.com> | 2017-09-18 14:36:31 -0400 |
|---|---|---|
| committer | David Howells <dhowells@redhat.com> | 2017-09-25 10:19:57 -0400 |
| commit | 7fc0786d956d9e59b68d282be9b156179846ea3d (patch) | |
| tree | 0b652a2ec8836a6d101e48a0ba1e07472f636432 /security | |
| parent | 884bee0215fcc239b30c062c37ca29077005e064 (diff) | |
KEYS: fix key refcount leak in keyctl_read_key()
In keyctl_read_key(), if key_permission() were to return an error code
other than EACCES, we would leak a the reference to the key. This can't
actually happen currently because key_permission() can only return an
error code other than EACCES if security_key_permission() does, only
SELinux and Smack implement that hook, and neither can return an error
code other than EACCES. But it should still be fixed, as it is a bug
waiting to happen.
Fixes: 29db91906340 ("[PATCH] Keys: Add LSM hooks for key management [try #3]")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'security')
| -rw-r--r-- | security/keys/keyctl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index 562f7fe287a0..aa1d11a29136 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c | |||
| @@ -771,7 +771,7 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) | |||
| 771 | if (ret == 0) | 771 | if (ret == 0) |
| 772 | goto can_read_key; | 772 | goto can_read_key; |
| 773 | if (ret != -EACCES) | 773 | if (ret != -EACCES) |
| 774 | goto error; | 774 | goto error2; |
| 775 | 775 | ||
| 776 | /* we can't; see if it's searchable from this process's keyrings | 776 | /* we can't; see if it's searchable from this process's keyrings |
| 777 | * - we automatically take account of the fact that it may be | 777 | * - we automatically take account of the fact that it may be |
