Skip to content

Commit 81a7be2

Browse files
ebiggersdhowells
authored andcommitted
ASN.1: check for error from ASN1_OP_END__ACT actions
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: 42d5ec2 ("X.509: Add an ASN.1 decoder") Cc: <[email protected]> # v3.7+ Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: David Howells <[email protected]> Reviewed-by: James Morris <[email protected]>
1 parent e0058f3 commit 81a7be2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lib/asn1_decoder.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,8 @@ int asn1_ber_decoder(const struct asn1_decoder *decoder,
439439
else
440440
act = machine[pc + 1];
441441
ret = actions[act](context, hdr, 0, data + tdp, len);
442+
if (ret < 0)
443+
return ret;
442444
}
443445
pc += asn1_op_lengths[op];
444446
goto next_op;

0 commit comments

Comments
 (0)