]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
KEYS: return full count in keyring_read() if buffer is too small
authorEric Biggers <ebiggers@google.com>
Thu, 2 Nov 2017 00:47:03 +0000 (00:47 +0000)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Thu, 16 Nov 2017 13:23:32 +0000 (11:23 -0200)
commitc843fbd38eb4048d0e07ddcc9cebcf53320715b3
tree8d4911fa3337eb6afa5d46ed5e8410b398ca81bf
parentf4cdfef7ea1fcb9e4f5eed82768a011af9e2474b
KEYS: return full count in keyring_read() if buffer is too small

BugLink: http://bugs.launchpad.net/bugs/1731971
commit 3239b6f29bdfb4b0a2ba59df995fc9e6f4df7f1f upstream.

Commit e645016abc80 ("KEYS: fix writing past end of user-supplied buffer
in keyring_read()") made keyring_read() stop corrupting userspace memory
when the user-supplied buffer is too small.  However it also made the
return value in that case be the short buffer size rather than the size
required, yet keyctl_read() is actually documented to return the size
required.  Therefore, switch it over to the documented behavior.

Note that for now we continue to have it fill the short buffer, since it
did that before (pre-v3.13) and dump_key_tree_aux() in keyutils arguably
relies on it.

Fixes: e645016abc80 ("KEYS: fix writing past end of user-supplied buffer in keyring_read()")
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
security/keys/keyring.c