From: Herbert Xu <herbert@gondor.apana.org.au>
To: efecanicoz@gmail.com
Cc: lukas@wunner.de, ignat@linux.win, davem@davemloft.net,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
Efe Can Icoz <efe.canicoz@atlascopco.com>
Subject: Re: [PATCH] crypto: rsassa-pkcs1 - Allocate the RSA buffer separately
Date: Fri, 20 Nov 2026 17:14:39 +0800 [thread overview]
Message-ID: <awAPfzBPyJ-gdVSw@gondor.apana.org.au> (raw)
In-Reply-To: <20261111113022.2033191-1-efecanicoz@gmail.com>
On Wed, Nov 11, 2026 at 12:30:22PM +0100, efecanicoz@gmail.com wrote:
> From: Efe Can Icoz <efe.canicoz@atlascopco.com>
>
> rsassa_pkcs1_verify() allocates the akcipher request, its private
> context, and the RSA input/output buffer in a single allocation.
> The buffer starts immediately after the request context, whose size
> is not necessarily a multiple of ARCH_DMA_MINALIGN.
>
> Although kmalloc() aligns the allocation itself, this does not
> guarantee suitable alignment of the interior buffer. On systems with
> non-coherent DMA, the buffer can therefore share cache lines with
> CPU-accessed request state. Updates to that state after DMA mapping
> can interfere with the device-written result during cache maintenance.
>
> This is reproducible on i.MX7D with rsa-caam, whose request context is
> 48 bytes while the kernel DMA alignment is 64 bytes. CAAM reports
> successful completion, but the recovered output retains the original
> signature prefix and PKCS#1 verification fails. This prevents the
> shipped X.509 certificates and regulatory database signature from
> being verified.
>
> Allocate the RSA buffer separately with kmemdup() so that it benefits
> from kmalloc's DMA alignment guarantees and does not share cache lines
> with the request context. Keep a separate pointer to the allocation
> base for sensitive cleanup, since verification may advance out_buf
> past the leading zero byte.
>
> Fixes: 1e562deacecc ("crypto: rsassa-pkcs1 - Migrate to sig_alg backend")
> Signed-off-by: Efe Can Icoz <efe.canicoz@atlascopco.com>
> ---
> Tested on a custom board with i.MX7D and i.MX8QXP, running Linux
> 6.18.37 with:
>
> CONFIG_CRYPTO_DEV_FSL_CAAM_PKC_API=y
> CONFIG_CFG80211_REQUIRE_SIGNED_REGDB=y
> CONFIG_CFG80211_USE_KERNEL_REGDB_KEYS=y
>
> During diagnosis, the selected signature driver was
> pkcs1(rsa-caam,sha256), with a 256-byte RSA buffer and a 48-byte
> child request context.
>
> Before the change, hardware completion returned success, but
> verification rejected the recovered output because it lacked the
> expected leading zero byte. Its prefix matched the input signature.
>
> After the change, the sforshee and wens certificates load successfully
> and regulatory database signature verification succeeds.
>
> The cache-line interference described above is supported by the
> allocation layout and the runtime comparison; the exact corruption
> sequence has not been directly traced.
>
> crypto/rsassa-pkcs1.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
This issue is being addressed with patches to caam.
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
prev parent reply other threads:[~2026-11-20 9:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 11:30 efecanicoz
2026-11-20 9:14 ` 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=awAPfzBPyJ-gdVSw@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=davem@davemloft.net \
--cc=efe.canicoz@atlascopco.com \
--cc=efecanicoz@gmail.com \
--cc=ignat@linux.win \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®