All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: zzz <abc0eichs@qq.com>
Cc: linux-kernel@vger.kernel.org,
	James.Bottomley@HansenPartnership.com,
	Jarkko Sakkinen <jarkko@kernel.org>,
	David Howells <dhowells@redhat.com>,
	keyrings@vger.kernel.org, linux-integrity@vger.kernel.org
Subject: Re: [PATCH] lib/asn1_encoder: fix encoding of zero OID components
Date: Mon, 23 Nov 2026 22:03:11 -0800	[thread overview]
Message-ID: <20261123220311.9ee34b6c33545185d41d09ce@linux-foundation.org> (raw)
In-Reply-To: <tencent_AFE15D698FFD4F18E16A6EF7CDA002D69806@qq.com>

On Fri, 20 Nov 2026 21:00:55 +0800 zzz <abc0eichs@qq.com> wrote:
>

Sorry, "zzz" isn't usable.  See
Documentation/process/submitting-patches.rst under "Sign your
work":"using a known identity (sorry, no anonymous contributions.)".

So for now I'll rewrite this as From:me and Reported-by:zzz.  Please
send a 

	Signed-off-by: Your Real Name <email@address>

as a reply-to-all to this message and I shall alter the attributions
appropriately.

> asn1_encode_oid_digit() encodes a zero component as 0x80, setting the
> continuation bit on its only octet. A trailing zero therefore produces
> an unterminated subidentifier, while an interior zero produces an
> overlong encoding of the following component.
> 
> For example, 1.2.0 is encoded as 06 02 2a 80 instead of 06 02 2a 00.
> Emit zero without the continuation bit, as required for the final
> octet of a base-128 subidentifier.

Super-slim bug and it appears that nothing in the current tree uses
this code path.  But a bug is a bug.

> Validation:
> - A local UML KUnit suite called the actual encoder with six OID
>   vectors and short buffers. The original failed the zero-component
>   vectors; the fixed kernel passed both subtests.

Feel free to send along a patch which adds a KUint test for the
asn1_decoder code.

> The sole current in-tree caller uses a fixed, nonzero TPM OID whose
> encoding is unchanged. This fixes the exported encoder's handling of
> valid zero components; it does not claim an observed TPM failure.

yup.

> --- a/lib/asn1_encoder.c
> +++ b/lib/asn1_encoder.c
> @@ -97,7 +97,7 @@ static int asn1_encode_oid_digit(unsigned char **_data, int *data_len, u32 oid)
>  
>  	/* quick case */
>  	if (oid == 0) {
> -		*data++ = 0x80;
> +		*data++ = 0;
>  		(*data_len)--;
>  		goto out;
>  	}

Thanks,  Added to the pile!

  reply	other threads:[~2026-11-24  6:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 13:00 [PATCH] lib/asn1_encoder: fix encoding of zero OID components zzz
2026-11-24  6:03 ` Andrew Morton [this message]
2026-11-24  9:21   ` Jarkko Sakkinen
2026-11-24 13:56   ` James Bottomley
2026-11-27 15:32   ` Chenshuo Zhang
2026-11-27 15:59   ` Chenshuo Zhang
2026-11-24  6:03 ` + lib-asn1_encoder-fix-encoding-of-zero-oid-components.patch added to mm-nonmm-unstable branch Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261123220311.9ee34b6c33545185d41d09ce@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=abc0eichs@qq.com \
    --cc=dhowells@redhat.com \
    --cc=jarkko@kernel.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.