diff options
author | David Howells <dhowells@redhat.com> | 2019-06-19 16:10:15 +0100 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2019-06-19 16:10:15 +0100 |
commit | 504b69eb3c95180bc59f1ae9096ad4b10bbbf254 (patch) | |
tree | f5d752709a378e608c13e3c517fa57fc49ad2fe9 /security/keys | |
parent | 45e0f30c30bb131663fbe1752974d6f2e39611e2 (diff) | |
download | linux-stable-504b69eb3c95180bc59f1ae9096ad4b10bbbf254.tar.gz linux-stable-504b69eb3c95180bc59f1ae9096ad4b10bbbf254.tar.bz2 linux-stable-504b69eb3c95180bc59f1ae9096ad4b10bbbf254.zip |
keys: Fix request_key() lack of Link perm check on found key
The request_key() syscall allows a process to gain access to the 'possessor'
permits of any key that grants it Search permission by virtue of request_key()
not checking whether a key it finds grants Link permission to the caller.
Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'security/keys')
-rw-r--r-- | security/keys/request_key.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 857da65e1940..a6543ed98b1f 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c @@ -564,6 +564,16 @@ struct key *request_key_and_link(struct key_type *type, key_ref = search_process_keyrings(&ctx); if (!IS_ERR(key_ref)) { + if (dest_keyring) { + ret = key_task_permission(key_ref, current_cred(), + KEY_NEED_LINK); + if (ret < 0) { + key_ref_put(key_ref); + key = ERR_PTR(ret); + goto error_free; + } + } + key = key_ref_to_ptr(key_ref); if (dest_keyring) { ret = key_link(dest_keyring, key); |