Re: [RFC PATCH] lib/asn1_decoder: add KUnit test suite

From: Jarkko Sakkinen

Date: Mon Nov 16 2026 - 22:24:12 EST


On Tue, Nov 17, 2026 at 05:09:57AM +0200, Jarkko Sakkinen wrote:
> On Tue, Nov 17, 2026 at 02:39:37AM +0000, William Chuang, Founder – Logarcheon wrote:
> > Fair questions.
> >
> > Why at all: asn1_ber_decoder() parses untrusted ASN.1 BER/DER input. X.509 certificates (keyrings) and PKCS#7 signatures (module signing) both go through it, and it has had a length-validation bug of this kind before — CVE-2016-0758, in asn1_find_indefinite_length().
> > Scope: the suite checks that malformed and truncated input is rejected rather than over-read, in the cases it exercises. It does not reproduce that CVE or prove the decoder memory-safe. That it isn’t vacuous: I weakened one bounds check in asn1_decoder.c to allow a short over-read. asn1_test_truncated_content then fails its return-value check — the decoder accepts a truncated SEQUENCE (returns 0 instead of -EBADMSG). The other 12 cases pass; reverting restores 13/13.
> >
> > Why KUnit: it exercises the in-kernel decoder directly, with no
> > userspace harness, and the cases can also run under KASAN/UBSAN
> > (verified in my config). It is deterministic and is not built into production kernels.
> >
> > Why in-kernel: the coverage travels with the code. An out-of-tree test does not run when someone changes lib/asn1_decoder.c.
> >
> > I agree the maintenance has to be justified by the coverage. If the current cases are too thin to carry, I’m happy to strengthen or narrow them on your feedback.
> >
> > Thanks,
> > William
>
> I'd start by learning to use the email client properly at first:
>
> https://docs.kernel.org/process/email-clients.html

Within past 17 years the total number of commits is 22. This includes
all the possible. Of these total six carry a Fixes tag.

That makes about 0.35 bug fixes annually. How do you explain this?

For me this looks whole a lot like LLM lottery i.e., sending random
and useless patches in the hopes that something might happen to get
in.

Your previous kunit supports this point of view given that it is
a possible "LLM remix" of a patch (kunit for assoc_array) that I
sent a month ago but we discarded the idea in favor of a better
solution.

Stop doing this.

Br, Jarkko