]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
KEYS: Disallow keyrings beginning with '.' to be joined as session keyrings
authorDavid Howells <dhowells@redhat.com>
Tue, 18 Apr 2017 14:31:07 +0000 (15:31 +0100)
committerThadeu Lima de Souza Cascardo <cascardo@canonical.com>
Fri, 5 May 2017 13:13:46 +0000 (10:13 -0300)
commit3c193fec4d60b5e24774adc8819f3cd85dcb7e9e
treec1909705bf4ae7616b95fcfd42da3edd977bd4a3
parent0edc3578c734d95ae1beaa1340e8640afab2ac66
KEYS: Disallow keyrings beginning with '.' to be joined as session keyrings

BugLink: http://bugs.launchpad.net/bugs/1687638
commit ee8f844e3c5a73b999edf733df1c529d6503ec2f upstream.

This fixes CVE-2016-9604.

Keyrings whose name begin with a '.' are special internal keyrings and so
userspace isn't allowed to create keyrings by this name to prevent
shadowing.  However, the patch that added the guard didn't fix
KEYCTL_JOIN_SESSION_KEYRING.  Not only can that create dot-named keyrings,
it can also subscribe to them as a session keyring if they grant SEARCH
permission to the user.

This, for example, allows a root process to set .builtin_trusted_keys as
its session keyring, at which point it has full access because now the
possessor permissions are added.  This permits root to add extra public
keys, thereby bypassing module verification.

This also affects kexec and IMA.

This can be tested by (as root):

keyctl session .builtin_trusted_keys
keyctl add user a a @s
keyctl list @s

which on my test box gives me:

2 keys in keyring:
180010936: ---lswrv     0     0 asymmetric: Build time autogenerated kernel key: ae3d4a31b82daa8e1a75b49dc2bba949fd992a05
801382539: --alswrv     0     0 user: a

Fix this by rejecting names beginning with a '.' in the keyctl.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
cc: linux-ima-devel@lists.sourceforge.net
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/keyctl.c