KEYS: reject NULL restriction string when type is specified
authorEric Biggers <ebiggers@google.com>
Fri, 8 Dec 2017 15:13:29 +0000 (15:13 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Dec 2017 08:52:53 +0000 (09:52 +0100)
commit28e7c9a8e548c8c7e839f6ae1e21d61dc92308b0
tree8bcaa193ac1cc2e3ddedb2171a2342404ff8560d
parent69d5894ce0a67d37f900d2597fc0b2b8cef6c863
KEYS: reject NULL restriction string when type is specified

commit 18026d866801d0c52e5550210563222bd6c7191d upstream.

keyctl_restrict_keyring() allows through a NULL restriction when the
"type" is non-NULL, which causes a NULL pointer dereference in
asymmetric_lookup_restriction() when it calls strcmp() on the
restriction string.

But no key types actually use a "NULL restriction" to mean anything, so
update keyctl_restrict_keyring() to reject it with EINVAL.

Reported-by: syzbot <syzkaller@googlegroups.com>
Fixes: 97d3aa0f3134 ("KEYS: Add a lookup_restriction function for the asymmetric key type")
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>
security/keys/keyctl.c