]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KEYS: encrypted: fix buffer overread in valid_master_desc()
authorEric Biggers <ebiggers@google.com>
Thu, 8 Jun 2017 13:48:18 +0000 (14:48 +0100)
committerBrian Maly <brian.maly@oracle.com>
Tue, 16 Apr 2019 18:53:31 +0000 (14:53 -0400)
commit94089a48e5e30650514ca2785aed39fe0bc24912
treedc390c01799d20b57d6e9b5ef8851f7ea3ed8e49
parentae4d97d27141110eb3c54f16c0c15c9c07e3e5c3
KEYS: encrypted: fix buffer overread in valid_master_desc()

With the 'encrypted' key type it was possible for userspace to provide a
data blob ending with a master key description shorter than expected,
e.g. 'keyctl add encrypted desc "new x" @s'.  When validating such a
master key description, validate_master_desc() could read beyond the end
of the buffer.  Fix this by using strncmp() instead of memcmp().  [Also
clean up the code to deduplicate some logic.]

Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
(cherry picked from commit 794b4bc292f5d31739d89c0202c54e7dc9bc3add)

Orabug: 29591025
CVE: CVE-2017-13305

Reviewed-by: Somasundaram Krishnasamy <somasundaram.krishnasamy@oracle.com>
Signed-off-by: Allen Pais <allen.pais@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
security/keys/encrypted-keys/encrypted.c