Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Jeff Barnes <jeffbarnes@linux.microsoft.com>
To: herbert@gondor.apana.org.au
Cc: horia.geanta@nxp.com, pankaj.gupta@nxp.com,
	sahil.malhotra@oss.nxp.com, changwei.zou@canonical.com,
	gaurav.jain@nxp.com, davem@davemloft.net,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 1/1] crypto: caam - fix in-place RSA payload DMA mapping
Date: Thu, 19 Nov 2026 14:53:50 -0500	[thread overview]
Message-ID: <20261119195350.812246-1-jeffbarnes@linux.microsoft.com> (raw)
In-Reply-To: <avRJW9494fF7Pyf4@gondor.apana.org.au>

Hi Herbert,

> Sashiko has some comments on this patch:

Thanks for pointing me to the review, and sorry for the delayed response.
The prepared v2 addresses two concerns, but the short-input SEC4/PDB
accounting concern remains. Here is the disposition of each finding:

1. PVF1: rejection of multi-segment in-place requests

   Agreed. The RFC's -EOPNOTSUPP containment is not suitable as the final
   fix. V2 removes it. An aligned exact alias retains one bidirectional
   mapping only when dma_map_sg() returns a single DMA segment.

   If it returns multiple segments, v2 releases that mapping using the
   original entry count, then maps the source DMA_TO_DEVICE and a separate
   destination bounce buffer DMA_FROM_DEVICE. This follows Sahil's
   recommendation and reuses Changwei's destination-bounce infrastructure.

   The padding/layout observations also included in PVF1 overlap PVF2
   below; I am not claiming those are fixed by destination bouncing.

2. PVF2: short-input padding and PDB source/table selection

   The source shows the accounting mismatch described in the review.
   The allocator reserves an extra SEC4 entry when diff_size is nonzero,
   but edesc->mapped_src_nents does not include that entry. The private
   PDB setters select a source S/G table only when that stored count is
   greater than one. Their destination-table offset also uses that count.

   I checked the unpatched baseline used by Sashiko,
   178aff4cf425b3fc51ff09c571fa1bfbc1eb8ea4. It already contains these
   allocation/count/selection rules, before applying this RFC. The issue
   is therefore not introduced by the shared-mapping change, but it
   remains present in the prepared v2 and needs separate treatment.

   In particular, fixing the private padded-input view and auditing the
   public input-length/table handling must not be conflated with simply
   changing payload DMA ownership. I have not hardware-reproduced or
   fixed this finding, and do not claim the public-operation tests below
   validate private signing or decryption.

3. PVF3: zero-length source passing the RFC's negative-only check

   Agreed. V2 patch 1 rejects src_nents <= 0 before payload mapping or
   SEC4 construction, returning -EINVAL for zero and propagating negative
   extent errors. It applies the same checks to the destination extent.
   A zero-length source therefore cannot reach the shared-mapping path
   merely because the destination extent is nonempty.

> Please also explain how your patch interacts with the other
> patches on caam:

The prepared v2 is based on both patches of Changwei's v6:

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

His error-path fix provides the operation-appropriate unmap dispatch.
His alignment fix provides fixup_dst, destination allocation, and
copy-back/free handling. V2 reuses that infrastructure rather than
adding another destination-buffer implementation or modifying req->dst.
The payload is unmapped before destination copy-back.

The ordering is Changwei's two patches, then the separate SG-extent
validation patch, then the in-place DMA ownership patch. The latter also
records req->src == req->dst before leading-zero stripping and forces a
destination bounce if the effective source advances.

A backport of that combination 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, with no DMA-API, ARM-LPAE/IOMMU, or scatterlist-iterator
warnings observed.

Those tests used direct and backlog-enabled submission; they did not
establish that requests entered the backlog, test private operations, or
cover noncoherent/dma-direct hardware.

The test run also included the independent iterator-boundary correction
now submitted separately:

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

On the maintenance concern, Sahil has provided substantive review and
offered noncoherent/dma-direct testing. I have copied the CAAM maintainers,
but cannot speak for them regarding ongoing maintenance.

GitHub Copilot assisted with the implementation, regression tests,
source comparison, and drafting this response.

Thanks,
Jeff

  reply	other threads:[~2026-11-19 19:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 19:25 [RFC PATCH 0/1] crypto: caam - fix in-place RSA payload DMA mapping Jeff Barnes
2026-10-20 19:25 ` [RFC PATCH 1/1] " Jeff Barnes
2026-11-11 10:54   ` Herbert Xu
2026-11-19 19:53     ` Jeff Barnes [this message]
2026-11-12  8:15   ` Sahil Malhotra
2026-11-13 20:46     ` Jeff Barnes
2026-11-13 22:58       ` Changwei Zou
2026-11-10 23:19 ` [RFC PATCH 0/1] " Jeff Barnes

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=20261119195350.812246-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=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pankaj.gupta@nxp.com \
    --cc=sahil.malhotra@oss.nxp.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