From: Herbert Xu <herbert@gondor.apana.org.au>
To: Changwei Zou <changwei.zou@canonical.com>
Cc: sahil.malhotra@nxp.com, davem@davemloft.net,
horia.geanta@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com,
jeffbarnes@linux.microsoft.com, stephane.debusne@cynove.com,
iuliana.prodan@nxp.com,
martin.kepplinger-novakovic@ginzinger.com, lukas@wunner.de,
sahil.malhotra@oss.nxp.com, linux-crypto@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] crypto: caam - Use bounce buffer for unaligned RSA destination buffers
Date: Wed, 11 Nov 2026 18:50:10 +0800 [thread overview]
Message-ID: <avRIYjWB6AUbeLUS@gondor.apana.org.au> (raw)
In-Reply-To: <20261020025426.955531-3-changwei.zou@canonical.com>
On Tue, Oct 20, 2026 at 01:54:26PM +1100, Changwei Zou wrote:
> The rsa-caam driver directly DMA-maps the destination buffer supplied by
> the caller via req->dst without checking whether it meets the cacheline
> alignment requirements of DMA-incoherent hardware such as i.MX8.
>
> On CPUs with non-coherent DMA caches, if the destination buffer shares a
> cacheline with other data (i.e. it is not cacheline-aligned), cache
> writeback/invalidation during DMA can corrupt adjacent memory or cause
> stale data to be read back. This manifests as intermittent -EKEYREJECTED
> errors when loading signed kernel modules.
>
> When any segment of req->dst is not cacheline-aligned in either its
> start offset or length, allocate a single contiguous aligned bounce
> buffer covering the full dst_len rounded up to a cacheline multiple,
> redirect the operation to it, and copy the result back to the original
> destination once the hardware has completed successfully.
>
> Introduce a helper sg_is_dma_aligned() that checks both sg->offset and
> sg->length for cacheline alignment. Checking sg->offset suffices for
> the start address since physical pages are always page-aligned and
> PAGE_SIZE is a multiple of dma_get_cache_alignment(). sg->length is
> also checked to ensure the buffer end does not share a cacheline with
> adjacent memory.
>
> The intermittent error 'Key was rejected by service' on i.MX8 with CAAM
> can be triggered when loading signed kernel modules:
>
> for i in $(seq 1 100); do
> sudo modprobe xfs 2>&1 && echo "SUCCESS on attempt $i" \
> && sudo rmmod xfs || echo "FAILED on attempt $i"
> done
>
> Reported-by: Martin Kepplinger-Novakovic <Martin.Kepplinger-Novakovic@ginzinger.com>
> Closes: https://lore.kernel.org/r/6029acc0f0ddfe25e2537c2866d54fd7f54bc182.camel@ginzinger.com
> Signed-off-by: Changwei Zou <changwei.zou@canonical.com>
> Assisted-by: OpenCode:claude-sonnet-4.6
> Tested-by: Martin Kepplinger-Novakovic <martin.kepplinger-novakovic@ginzinger.com>
> Tested-by: Stephane Debusne <stephane.debusne@cynove.com>
> ---
> drivers/crypto/caam/caampkc.c | 87 ++++++++++++++++++++++++++++++++++-
> drivers/crypto/caam/caampkc.h | 6 +++
> 2 files changed, 92 insertions(+), 1 deletion(-)
Please respond to the Sashiko comments:
https://sashiko.dev/#/patchset/20261020025426.955531-1-changwei.zou%40canonical.com
I'm also disappointed with the lack of response from the caam
maintainers. Unless active maintainence can be demonstrated
for this driver, I'm going to have it removed again.
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-11 10:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 2:54 [PATCH v3 0/2] crypto: caam - Fix RSA error-path unmap and unaligned dst buffers Changwei Zou
2026-10-20 2:54 ` [PATCH v3 1/2] crypto: caam - Fix wrong unmap operations Changwei Zou
2026-10-20 2:54 ` [PATCH v3 2/2] crypto: caam - Use bounce buffer for unaligned RSA destination buffers Changwei Zou
2026-11-11 10:50 ` 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=avRIYjWB6AUbeLUS@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=changwei.zou@canonical.com \
--cc=davem@davemloft.net \
--cc=gaurav.jain@nxp.com \
--cc=horia.geanta@nxp.com \
--cc=iuliana.prodan@nxp.com \
--cc=jeffbarnes@linux.microsoft.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=martin.kepplinger-novakovic@ginzinger.com \
--cc=pankaj.gupta@nxp.com \
--cc=sahil.malhotra@nxp.com \
--cc=sahil.malhotra@oss.nxp.com \
--cc=stephane.debusne@cynove.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 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®