Commit 44acfcb6 authored by Eric Biggers's avatar Eric Biggers Committed by Greg Kroah-Hartman
Browse files

ASN.1: check for error from ASN1_OP_END__ACT actions

commit 81a7be2c upstream.

asn1_ber_decoder() was ignoring errors from actions associated with the
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: 42d5ec27

 ("X.509: Add an ASN.1 decoder")
Signed-off-by: default avatarEric Biggers <>
Signed-off-by: default avatarDavid Howells <>
Reviewed-by: default avatarJames Morris <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 608845ad
......@@ -439,6 +439,8 @@ next_op:
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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment