Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>
Cc: David Howells <dhowells@redhat.com>,
	Lukas Wunner <lukas@wunner.de>, Ignat Korchagin <ignat@linux.win>,
	"David S. Miller" <davem@davemloft.net>,
	keyrings@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH] crypto: asymmetric_keys: copy X.509 TBS for data signature algorithms
Date: Wed, 23 Sep 2026 18:46:45 +1000	[thread overview]
Message-ID: <arOR9UZ4_5mtD7RC@gondor.apana.org.au> (raw)
In-Reply-To: <20260821192502.3942767-2-Jeremy.Jean@oss.cyber.gouv.fr>

On Fri, Aug 21, 2026 at 07:25:03PM +0000, Jérémy Jean wrote:
> For signature algorithms operating on a message rather than a digest,
> x509_get_sig_params() points sig->m directly into cert->tbs.
> cert->tbs is the preparsed add_key() payload.  The syscall wipes and frees
> it on return, while the instantiated key retains public_key_signature.
> 
> A later KEYCTL_LINK into an asymmetric restricted keyring therefore passes
> a dangling message pointer to ML-DSA.  KASAN reports a slab-use-after-free
> in mldsa_verify(), with allocation and free provenance both leading to
> __do_sys_add_key().  Reuse is also an integrity issue: bytes occupying the
> freed object become the authenticated message instead of the certificate's
> own TBSCertificate.
> 
> Give the signature object its own copy of the TBS, as is already done for
> a precomputed digest, and release it through the existing m_free contract.
> 
> Fixes: f3eccecd782d ("pkcs7: Allow the signing algo to do whatever digestion it wants itself")
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> Assisted-by: Codex:gpt-5
> ---
>  crypto/asymmetric_keys/x509_public_key.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2026-09-23  8:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21 19:25 [PATCH] crypto: asymmetric_keys: copy X.509 TBS for data signature algorithms Jérémy Jean
2026-09-23  8:46 ` Herbert Xu [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=arOR9UZ4_5mtD7RC@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=Jeremy.Jean@oss.cyber.gouv.fr \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=ignat@linux.win \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=lukas@wunner.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox