linux/security/keys
Eric Biggers a3c812f7cf KEYS: trusted: fix writing past end of buffer in trusted_read()
When calling keyctl_read() on a key of type "trusted", if the
user-supplied buffer was too small, the kernel ignored the buffer length
and just wrote past the end of the buffer, potentially corrupting
userspace memory.  Fix it by instead returning the size required, as per
the documentation for keyctl_read().

We also don't even fill the buffer at all in this case, as this is
slightly easier to implement than doing a short read, and either
behavior appears to be permitted.  It also makes it match the behavior
of the "encrypted" key type.

Fixes: d00a1c72f7 ("keys: add new trusted key-type")
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Cc: <stable@vger.kernel.org> # v2.6.38+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Reviewed-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
2017-11-02 20:58:07 +11:00
..
encrypted-keys KEYS: Fix race between updating and finding a negative key 2017-10-18 09:12:40 +01:00
big_key.c KEYS: Fix race between updating and finding a negative key 2017-10-18 09:12:40 +01:00
compat_dh.c KEYS: DH: validate __spare field 2017-07-14 11:01:38 +10:00
compat.c KEYS: add SP800-56A KDF support for DH 2017-04-04 22:33:38 +01:00
dh.c KEYS: DH: validate __spare field 2017-07-14 11:01:38 +10:00
gc.c KEYS: Fix race between updating and finding a negative key 2017-10-18 09:12:40 +01:00
internal.h KEYS: prevent creating a different user's keyrings 2017-09-25 15:19:57 +01:00
Kconfig security/keys: BIG_KEY requires CONFIG_CRYPTO 2017-10-18 09:12:40 +01:00
key.c KEYS: don't let add_key() update an uninstantiated key 2017-10-18 09:12:40 +01:00
keyctl.c KEYS: Fix race between updating and finding a negative key 2017-10-18 09:12:40 +01:00
keyring.c KEYS: return full count in keyring_read() if buffer is too small 2017-11-02 20:58:05 +11:00
Makefile KEYS: add SP800-56A KDF support for DH 2017-04-04 22:33:38 +01:00
permission.c KEYS: load key flags and expiry time atomically in key_validate() 2017-10-18 09:12:41 +01:00
persistent.c sched/headers: Prepare to remove <linux/cred.h> inclusion from <linux/sched.h> 2017-03-02 08:42:31 +01:00
proc.c KEYS: load key flags and expiry time atomically in proc_keys_show() 2017-10-18 09:12:41 +01:00
process_keys.c KEYS: Fix race between updating and finding a negative key 2017-10-18 09:12:40 +01:00
request_key_auth.c KEYS: Fix race between updating and finding a negative key 2017-10-18 09:12:40 +01:00
request_key.c KEYS: Fix race between updating and finding a negative key 2017-10-18 09:12:40 +01:00
sysctl.c security: Convert use of typedef ctl_table to struct ctl_table 2014-04-15 13:39:58 +10:00
trusted.c KEYS: trusted: fix writing past end of buffer in trusted_read() 2017-11-02 20:58:07 +11:00
trusted.h keys, trusted: move struct trusted_key_options to trusted-type.h 2015-10-19 01:01:21 +02:00
user_defined.c KEYS: Fix race between updating and finding a negative key 2017-10-18 09:12:40 +01:00