summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2017-12-08 15:13:27 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-12-16 10:32:26 +0100
commit602a1c77f9f3466fb7d7fd4e2454b27008ccac83 (patch)
tree8025c253bdbd0f6e3226ab1ac11d3bf18c4d46f8 /lib
parent25ea12ec0370ad88d356e84bca5a2a0f65b1bac6 (diff)
downloadlinux-stable-602a1c77f9f3466fb7d7fd4e2454b27008ccac83.tar.gz
linux-stable-602a1c77f9f3466fb7d7fd4e2454b27008ccac83.tar.bz2
linux-stable-602a1c77f9f3466fb7d7fd4e2454b27008ccac83.zip
ASN.1: check for error from ASN1_OP_END__ACT actions
commit 81a7be2cd69b412ab6aeacfe5ebf1bb6e5bce955 upstream. asn1_ber_decoder() was ignoring errors from actions associated with the opcodes ASN1_OP_END_SEQ_ACT, ASN1_OP_END_SET_ACT, ASN1_OP_END_SEQ_OF_ACT, and ASN1_OP_END_SET_OF_ACT. In practice, this meant the pkcs7_note_signed_info() action (since that was the only user of those opcodes). Fix it by checking for the error, just like the decoder does for actions associated with the other opcodes. This bug allowed users to leak slab memory by repeatedly trying to add a specially crafted "pkcs7_test" key (requires CONFIG_PKCS7_TEST_KEY). In theory, this bug could also be used to bypass module signature verification, by providing a PKCS#7 message that is misparsed such that a signature's ->authattrs do not contain its ->msgdigest. But it doesn't seem practical in normal cases, due to restrictions on the format of the ->authattrs. Fixes: 42d5ec27f873 ("X.509: Add an ASN.1 decoder") 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/asn1_decoder.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/asn1_decoder.c b/lib/asn1_decoder.c
index 162b6d290622..7f453b6ff0d0 100644
--- a/lib/asn1_decoder.c
+++ b/lib/asn1_decoder.c
@@ -422,6 +422,8 @@ next_op:
else
act = machine[pc + 1];
ret = actions[act](context, hdr, 0, data + tdp, len);
+ if (ret < 0)
+ return ret;
}
pc += asn1_op_lengths[op];
goto next_op;