]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
KEYS: fix writing past end of user-supplied buffer in keyring_read()
authorEric Biggers <ebiggers@google.com>
Mon, 18 Sep 2017 18:36:45 +0000 (11:36 -0700)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 12 Oct 2017 21:20:20 +0000 (16:20 -0500)
commit8fc8160e57c5fe81d06c76e083b60bebcd4b8e9b
tree473f2d5b43a054d05f5c956f20ad865b30411e9c
parent820eccd916820b0e01a6021ddb821282d66cd28b
KEYS: fix writing past end of user-supplied buffer in keyring_read()

BugLink: http://bugs.launchpad.net/bugs/1721777
commit e645016abc803dafc75e4b8f6e4118f088900ffb upstream.

Userspace can call keyctl_read() on a keyring to get the list of IDs of
keys in the keyring.  But if the user-supplied buffer is too small, the
kernel would write the full list anyway --- which will corrupt whatever
userspace memory happened to be past the end of the buffer.  Fix it by
only filling the space that is available.

Fixes: b2a4df200d57 ("KEYS: Expand the capacity of a keyring")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
security/keys/keyring.c