From: Dan Carpenter <dan@pereq.eu>
To: sashiko-reviews@lists.linux.dev
Cc: "Lukas Wunner" <lukas@wunner.de>,
"Ignat Korchagin" <ignat@linux.win>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
"Joy Latten" <latten@austin.ibm.com>,
"David Howells" <dhowells@redhat.com>,
"Robbie Harwood" <rharwood@redhat.com>,
"Vivek Goyal" <vgoyal@redhat.com>,
"Karthik Bhargavan" <karthik@pereq.eu>,
"Clément Blaudeau" <clement@cryspen.com>,
linux-crypto@vger.kernel.org, keyrings@vger.kernel.org
Subject: Re: [PATCH 4/4] crypto: asymmetric_keys - Print the correct offset in a debug message
Date: Fri, 4 Dec 2026 14:36:24 +0300 [thread overview]
Message-ID: <axKluHb6KbEVHZre@stanley.mountain> (raw)
In-Reply-To: <sashiko-outbox-249439@kernel.org>
On Fri, Dec 04, 2026 at 08:52:20AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Low] crypto: off-by-hdrlen debug offset in pkcs7_extract_cert()
> --
>
> commit f0faf0419a12880593a89a85374f99bb1edc3463
> Author: Dan Carpenter <dan@pereq.eu>
>
> crypto: asymmetric_keys - Print the correct offset in a debug message
>
> This commit updates a pr_debug() call in pkcs7_extract_cert() to compute
> the logged offset from value instead of ctx.
>
> > diff --git a/crypto/asymmetric_keys/pkcs7_parser.c b/crypto/asymmetric_keys/pkcs7_parser.c
> > index 7f00e45a33cf6..c5dd638a50fe4 100644
> > --- a/crypto/asymmetric_keys/pkcs7_parser.c
> > +++ b/crypto/asymmetric_keys/pkcs7_parser.c
> > @@ -445,7 +445,7 @@ int pkcs7_extract_cert(void *context, size_t hdrlen,
> >
> > if (tag != ((ASN1_UNIV << 6) | ASN1_CONS_BIT | ASN1_SEQ)) {
> > pr_debug("Cert began with tag %02x at %lu\n",
> > - tag, (unsigned long)ctx - ctx->data);
> > + tag, (unsigned long)value - ctx->data);
> > return -EBADMSG;
> > }
>
> [Severity: Low]
> Should this subtract hdrlen from value when computing the offset?
>
> asn1_ber_decoder() advances past the tag and length header before invoking
> the action, so value points to the payload rather than the tag byte, as
> shown right below where value is adjusted by hdrlen for x509_cert_parse().
> The debug message therefore logs an offset hdrlen bytes past the tag.
>
Sashiko is correct. It should be
"(unsigned long)value - hdrlen - ctx->data". I copy and pasted bad code.
I'll fix the other code too:
Old: PKCS7: Unknown OID: [39] 1.2.3.4
PKCS7: Cert began with tag 04 at 311626400
New: PKCS7: Unknown OID: [37] 1.2.3.4
PKCS7: Cert began with tag 04 at 57
regards,
dan carpenter
prev parent reply other threads:[~2026-12-04 11:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 8:37 [PATCH 0/4] crypto: miscellaneous small fixes Dan Carpenter
2026-12-04 8:37 ` [PATCH 1/4] crypto: rsassa-pkcs1 - Fix check for no hash prefix Dan Carpenter
2026-12-04 8:37 ` [PATCH 2/4] crypto: ccm - Fix off-by-one in set_msg_len() Dan Carpenter
2026-12-04 8:37 ` [PATCH 3/4] crypto: asymmetric_keys - Fix warning in pefile_strip_sig_wrapper() Dan Carpenter
2026-12-04 8:37 ` [PATCH 4/4] crypto: asymmetric_keys - Print the correct offset in a debug message Dan Carpenter
2026-12-04 8:52 ` sashiko-bot
2026-12-04 11:36 ` Dan Carpenter [this message]
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=axKluHb6KbEVHZre@stanley.mountain \
--to=dan@pereq.eu \
--cc=clement@cryspen.com \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=herbert@gondor.apana.org.au \
--cc=ignat@linux.win \
--cc=karthik@pereq.eu \
--cc=keyrings@vger.kernel.org \
--cc=latten@austin.ibm.com \
--cc=linux-crypto@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=rharwood@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vgoyal@redhat.com \
/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.