From: Ralf Lici <ralf@mandelbit.com>
To: linux-crypto@vger.kernel.org
Cc: Antoine Tenart <atenart@kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Nikita Zhandarovich <n.zhandarovich@fintech.ru>,
Antonio Quartulli <antonio@openvpn.net>,
linux-kernel@vger.kernel.org
Subject: [PATCH crypto v2 0/2] crypto: safexcel: fix AEAD DMA mapping and cleanup
Date: Thu, 3 Dec 2026 09:40:05 +0100 [thread overview]
Message-ID: <cover.1796286347.git.ralf@mandelbit.com> (raw)
Hi,
This series fixes two DMA mapping bugs in the safexcel AEAD path. The
first avoids unmapping a destination list whose mapping failed. The
second maps each AEAD scatterlist entry with the direction its contents
need, which fixes silent output corruption on non-coherent systems.
In the v1 discussion, Herbert asked which caller is affected and whether
mapping the destination DMA_BIDIRECTIONAL would be enough. The caller is
in-tree ovpn: its in-place requests start with an 8-byte AAD entry that
shares a cache line with the payload. Mapping that entry
DMA_BIDIRECTIONAL, as the in-place path already does, is what corrupts
the output. The entry is bounced through SWIOTLB, and copying it back at
unmap dirties a stale cache line that the next unmap then writes over
the accelerator output. Patch 2 has the details. This also corrects my
earlier explanation: swiotlb fills the bounce buffer in every direction,
so the problem is the copy-back through a stale cache line, not
uninitialized bounce data.
I tested this on a GL.iNet GL-MT6000 (MT7986 EIP97, non-coherent
Cortex-A53) with a matrix of AES-GCM requests in the ovpn in-place and
fragmented out-of-place layouts plus linear ones, for encryption and
decryption, at three data offsets and queue depths up to 400. The stock
driver failed 27 of the 72 cases, all ovpn layouts, and this series
fixes all of them.
Unfortunately no choice of direction can fix the case where two adjacent
device-written entries share a cache line and the first is small enough
to be bounced. While I have not seen this with ovpn or ESP, it might
explain the kTLS failure noted in v1 (still unfixed by this series).
Changes since v1 https://lore.kernel.org/linux-crypto/cover.1789469436.git.ralf@mandelbit.com/
- Rebase onto crypto-2.6.
- Rewrite the commit message of patch 2 to explain why
DMA_BIDIRECTIONAL is not safe for small entries and to name the
in-tree caller. (Herbert)
Cheers!
Ralf Lici
Mandelbit Srl
---
Ralf Lici (2):
crypto: safexcel - Avoid unmapping failed DMA mappings
crypto: safexcel - Map AEAD buffers with accurate DMA directions
.../crypto/inside-secure/safexcel_cipher.c | 173 +++++++++++++++---
1 file changed, 150 insertions(+), 23 deletions(-)
base-commit: 26ca5f34841f0a86d0883664a1c13be89a01d351
--
2.56.1
next reply other threads:[~2026-12-03 8:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 8:40 Ralf Lici [this message]
2026-12-03 8:40 ` [PATCH crypto v2 1/2] crypto: safexcel - Avoid unmapping failed DMA mappings Ralf Lici
2026-12-03 8:40 ` [PATCH crypto v2 2/2] crypto: safexcel - Map AEAD buffers with accurate DMA directions Ralf Lici
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=cover.1796286347.git.ralf@mandelbit.com \
--to=ralf@mandelbit.com \
--cc=antonio@openvpn.net \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=n.zhandarovich@fintech.ru \
/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®