Skip to content

crypto: caam - fix in-place RSA DMA mapping

Jeff Barnes linux-crypto lkml 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v1 RFC1 patch 6 repliesSuperseded

Changes since the RFC from the cover letter

- 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.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2crypto: caam - validate RSA scatterlist extents before mappingdrivers/crypto/caam/caampkc.c+5 -00 replies
2/2crypto: caam - fix in-place RSA payload DMA mappingdrivers/crypto/caam/caampkc.c drivers/crypto/caam/caampkc.h+65 -220 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/2] crypto: caam - fix in-place RSA DMA mapping

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/[email protected]/

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/[email protected]/

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.

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/[email protected]/

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

Signature · 1 line
2.43.0