]> git.baikalelectronics.ru Git - kernel.git/commit
KEYS: Fix the size of the key description passed to/from userspace
authorDavid Howells <dhowells@redhat.com>
Mon, 1 Dec 2014 22:52:45 +0000 (22:52 +0000)
committerDavid Howells <dhowells@redhat.com>
Mon, 1 Dec 2014 22:52:45 +0000 (22:52 +0000)
commit0b1718e6cdb075d0552590d0d2c5c5f03e7dca5b
tree40cb7d4a6ff0b231a10cf7e51c8a8b24a7f3cd45
parent40407ab9c7030192d9d5dc25ea3e5e4b3b1010ec
KEYS: Fix the size of the key description passed to/from userspace

When a key description argument is imported into the kernel from userspace, as
happens in add_key(), request_key(), KEYCTL_JOIN_SESSION_KEYRING,
KEYCTL_SEARCH, the description is copied into a buffer up to PAGE_SIZE in size.
PAGE_SIZE, however, is a variable quantity, depending on the arch.  Fix this at
4096 instead (ie. 4095 plus a NUL termination) and define a constant
(KEY_MAX_DESC_SIZE) to this end.

When reading the description back with KEYCTL_DESCRIBE, a PAGE_SIZE internal
buffer is allocated into which the information and description will be
rendered.  This means that the description will get truncated if an extremely
long description it has to be crammed into the buffer with the stringified
information.  There is no particular need to copy the description into the
buffer, so just copy it directly to userspace in a separate operation.

Reported-by: Christian Kastner <debian@kvr.at>
Signed-off-by: David Howells <dhowells@redhat.com>
Tested-by: Christian Kastner <debian@kvr.at>
security/keys/keyctl.c