mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] crypto: caam - fix in-place RSA DMA mapping
@ 2026-11-19 19:59 Jeff Barnes
  2026-11-19 19:59 ` [PATCH v2 1/2] crypto: caam - validate RSA scatterlist extents before mapping Jeff Barnes
  2026-11-19 19:59 ` [PATCH v2 2/2] crypto: caam - fix in-place RSA payload DMA mapping Jeff Barnes
  0 siblings, 2 replies; 3+ messages in thread
From: Jeff Barnes @ 2026-11-19 19:59 UTC (permalink / raw)
  To: linux-crypto
  Cc: herbert, davem, horia.geanta, pankaj.gupta, sahil.malhotra,
	changwei.zou, meenakshi.aggarwal, tudor-dan.ambarus,
	linux-kernel

This series fixes DMA ownership for in-place RSA requests in rsa-caam.
Mapping the same scatterlist independently for source and destination
can overwrite DMA metadata and cause ARM-LPAE/IOMMU unmap warnings.

The series is based on Changwei Zou's v6 error-path and destination
bounce-buffer fixes:

https://lore.kernel.org/linux-crypto/20261114060032.872141-1-changwei.zou@canonical.com/

Patch 1 validates source and destination scatterlist extents before
walking or mapping them. It is separate so it can be backported
independently.

Patch 2 maps an aligned, exact source/destination alias once with
DMA_BIDIRECTIONAL when the mapping produces a single DMA segment.
Multi-segment aliases use Changwei's destination bounce-buffer
infrastructure instead of being rejected.

The original alias relationship is recorded before stripping leading
zeros. Requests whose effective source advances also use destination
bouncing, avoiding overlapping streaming mappings through different
scatterlist metadata.

Changes since the RFC:
- Split scatterlist extent validation into a separate patch.
- Build on Changwei's fixup_dst and bounce-buffer infrastructure.
- Replace multi-segment -EOPNOTSUPP rejection with destination bouncing.
- Handle aliases whose effective source advances during zero stripping.
- Add Fixes and stable CC tags.

Previous RFC:

https://lore.kernel.org/linux-crypto/20261020192511.3389133-1-jeffbarnes@linux.microsoft.com/

Testing:

A backport of the prerequisites and this series was tested on an
arm64 system with CAAM behind an SMMUv2, a translated IOMMU domain,
and DMA-API debugging enabled, running kernel 6.6.160.4.

All 12 RSA-2048 public-operation alias tests passed. These covered
single-entry shared mapping, two- and three-entry bounce fallback,
leading-zero stripping within and across entries, and unaligned
buffers, each with direct and backlog-enabled submission.

No DMA-API, ARM-LPAE/IOMMU, or scatterlist-iterator warnings were
observed. The test run also included an independent leading-zero
iterator boundary fix, which is not included in this series.

Backlog-enabled submission does not establish that requests actually
entered the backlog. Private RSA operations and noncoherent/dma-direct
hardware were not covered by this test run.

GitHub Copilot assisted with implementing the agreed DMA/bounce-buffer
design, developing regression tests, and drafting commit messages.

Link: https://lore.kernel.org/linux-crypto/20261119192007.786827-1-jeffbarnes@linux.microsoft.com/

Review follow-up:
The multi-segment rejection and zero-length-input concerns raised by
Sashiko are addressed by this series. The short-input SEC4/PDB padding
accounting issue exists in the unpatched baseline and remains unfixed
by this series. The detailed response to Herbert is here:

https://lore.kernel.org/linux-crypto/20261119195350.812246-1-jeffbarnes@linux.microsoft.com/

Jeff Barnes (2):
  crypto: caam - validate RSA scatterlist extents before mapping
  crypto: caam - fix in-place RSA payload DMA mapping

 drivers/crypto/caam/caampkc.c | 89 ++++++++++++++++++++++++++---------
 drivers/crypto/caam/caampkc.h |  3 ++
 2 files changed, 70 insertions(+), 22 deletions(-)


base-commit: 7e1392a42ea288d70a266f6553fe06f57f8647ea
prerequisite-patch-id: de99c6374460d838f0474066325d03bea7a4f979
prerequisite-patch-id: 33fe41f9cfd4a8ee1afa1fc6e915a9747acd2f37
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-19 20:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 19:59 [PATCH v2 0/2] crypto: caam - fix in-place RSA DMA mapping Jeff Barnes
2026-11-19 19:59 ` [PATCH v2 1/2] crypto: caam - validate RSA scatterlist extents before mapping Jeff Barnes
2026-11-19 19:59 ` [PATCH v2 2/2] crypto: caam - fix in-place RSA payload DMA mapping Jeff Barnes

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®