From: Jeff Barnes <jeffbarnes@linux.microsoft.com>
To: stephane.debusne@cynove.com
Cc: herbert@gondor.apana.org.au, lukas@wunner.de,
changwei.zou@canonical.com, ignat@cloudflare.com,
davem@davemloft.net, horia.geanta@nxp.com, pankaj.gupta@nxp.com,
gaurav.jain@nxp.com, sahil.malhotra@nxp.com,
sahil.malhotra@oss.nxp.com,
martin.kepplinger-novakovic@ginzinger.com,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/2] crypto: fix RSA results corrupted by non-coherent DMA
Date: Fri, 16 Oct 2026 18:14:14 -0400 [thread overview]
Message-ID: <20261016221414.4139377-1-jeffbarnes@linux.microsoft.com> (raw)
In-Reply-To: <20261016090333.2247764-1-stephane.debusne@cynove.com>
Hi Stephane,
Thanks for posting this. While investigating CAAM RSA on another arm64
non-coherent system, I found a separate DMA issue affecting the same
in-place request shape.
Your patches move the synchronous-helper and RSASSA-PKCS1 buffers into
separate allocations, while intentionally retaining src == dst. That
addresses cache-line sharing between the payload and mutable request
context. The issue I observed is in rsa-caam's ownership of that
exact-alias SG.
On an NXP LX2160A with CAAM Era 10 behind an ARM SMMUv2 translated DMA
domain, rsa-caam mapped the same effective SG twice:
- first with DMA_TO_DEVICE, producing mapping A;
- then with DMA_FROM_DEVICE, producing a different mapping B.
Because dma_map_sg() writes DMA metadata into the SG, the second map
replaced the metadata describing A. Completion subsequently unmapped B
as the destination and then consumed the same overwritten metadata when
unmapping the source. The second teardown attempted to remove B again,
while the SG no longer retained the metadata needed to release A.
The public completion warning included:
__arm_lpae_unmap
arm_lpae_unmap_pages
arm_smmu_unmap_pages
__iommu_unmap
iommu_unmap_fast
__iommu_dma_unmap
iommu_dma_unmap_sg
dma_unmap_sg_attrs
rsa_io_unmap
rsa_pub_done
caam_jr_dequeue
A corresponding private RSA case reached rsa_io_unmap() through
rsa_priv_f_done(). Certificate verification reproduced the public path
with a 512-byte operand.
I tested a narrow downstream prototype that, after source normalization,
maps an exact effective-head alias once with DMA_BIDIRECTIONAL over the
larger of the source and destination extents. The observed public 256/256
and certificate-verification 512/512 requests each had one original SG
entry and returned one DMA segment. They then used one BIDIRECTIONAL map
and one matching unmap with the original entry count.
With that prototype, the system booted successfully and the tested logs
contained no matches for __arm_lpae_unmap, __arm_lpae_map,
__iommu_dma_unmap, RSA algorithm failures, invalid output, RSA self-test
failures, or rsa-caam failures. These are downstream results for the
observed one-entry mappings, not validation of arbitrary multi-entry
exact aliases or a current upstream patch.
Changwei's pending unaligned-destination bounce-buffer patch appears
complementary:
https://lore.kernel.org/linux-crypto/20261004210200.290119-3-changwei.zou@canonical.com/
For an unaligned destination, bounce substitution would make the
effective source and destination distinct, allowing separate TO/FROM
ownership. For an aligned exact alias, the original SG would remain
shared and would still need one BIDIRECTIONAL mapping. If combined,
destination substitution appears to need to happen before effective-head
alias classification.
The unresolved case is a shared mapping that returns more than one DMA
segment. Using the union mapping's returned count for both logical
hardware views can change existing SEC4 source-table selection,
particularly for a shorter source. I do not yet have hardware evidence
for that case.
Would the preferred direction be:
1. an initial narrowly bounded CAAM RFC demonstrating the one-owner
BIDIRECTIONAL correction and explicitly rejecting unresolved
multi-segment aliases;
2. coordination with the pending destination-bounce work for problematic
aliases; or
3. constructing separately bounded source and destination SEC4 views
over one shared mapping?
I wanted to raise this here before posting a separate RFC because your
series confirms that exact-alias requests remain intentional, and the two
DMA issues are independent but affect the same callers.
Thanks,
Jeff
prev parent reply other threads:[~2026-10-16 22:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 9:03 [PATCH 0/2] crypto: fix RSA results corrupted by non-coherent DMA Stephane Debusne
2026-10-16 9:03 ` [PATCH 1/2] crypto: akcipher - use a separate buffer in the sync helpers Stephane Debusne
2026-10-16 9:03 ` [PATCH 2/2] crypto: rsassa-pkcs1 - use a separate buffer for the RSA output Stephane Debusne
2026-10-16 22:14 ` Jeff Barnes [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=20261016221414.4139377-1-jeffbarnes@linux.microsoft.com \
--to=jeffbarnes@linux.microsoft.com \
--cc=changwei.zou@canonical.com \
--cc=davem@davemloft.net \
--cc=gaurav.jain@nxp.com \
--cc=herbert@gondor.apana.org.au \
--cc=horia.geanta@nxp.com \
--cc=ignat@cloudflare.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