Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Ralf Lici <ralf@mandelbit.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, Antoine Tenart <atenart@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH crypto 2/2] crypto: safexcel - Map AEAD buffers with accurate DMA directions
Date: Thu,  8 Oct 2026 10:21:44 +0200	[thread overview]
Message-ID: <20261008082145.125762-1-ralf@mandelbit.com> (raw)
In-Reply-To: <asdL7rQTM5nSTIH5@gondor.apana.org.au>

On Thu, 08 Oct 2026 18:53:18 +1100, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Mon, Sep 28, 2026 at 12:25:00PM +0200, Ralf Lici wrote:
> >
> > For an out-of-place request, the caller may have already populated the
> > reserved destination AAD area. The AEAD API says that this area will not
> > be written by the cipher operation:
>
> That's what I was asking.  Which caller is doing this and thus
> would be broken without your patch?
>

The caller which exposed this is the ovpn UDP-GSO transmit path [1],
part of a series currently under review and not in mainline yet. It
builds an out-of-place AEAD request and explicitly copies the
authenticated header into the reserved destination prefix before
submitting it:

  ovpn_aead_encrypt_header(..., aad);
  skb_store_bits(gso_skb, offset, aad, aad_size);

The source AAD then points to the temporary aad buffer, while the
destination AAD points into gso_skb (they are separate storage). The
accelerator skips the destination prefix as required by the AEAD API,
but safexcel maps it as DMA_FROM_DEVICE, so SWIOTLB may copy untouched
bounce-buffer contents over the header during unmap. This is the
out-of-place case in which I reproduced the corruption.

Technically, the in-tree ESP out-of-place path also constructs its
destination around an already initialized header, but my ESP tests did
not reproduce the corruption, so ovpn is the concrete demonstrated case
here.

[1] https://lore.kernel.org/openvpn-devel/f075b9782b14d64756c84e132c138482f08287b9.1790843153.git.ralf@mandelbit.com/

-- 
Ralf Lici
Mandelbit Srl

      reply	other threads:[~2026-10-08  8:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 11:32 [PATCH crypto 0/2] crypto: safexcel: fix AEAD DMA mapping and cleanup Ralf Lici
2026-09-15 11:32 ` [PATCH crypto 1/2] crypto: safexcel - Avoid unmapping failed DMA mappings Ralf Lici
2026-09-15 11:32 ` [PATCH crypto 2/2] crypto: safexcel - Map AEAD buffers with accurate DMA directions Ralf Lici
2026-09-23  5:30   ` Herbert Xu
2026-09-23  7:26     ` Ralf Lici
2026-09-23  8:32       ` Herbert Xu
2026-09-23  9:13         ` Ralf Lici
2026-09-28  5:12           ` Herbert Xu
2026-09-28 10:25             ` Ralf Lici
2026-10-08  7:53               ` Herbert Xu
2026-10-08  8:21                 ` Ralf Lici [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=20261008082145.125762-1-ralf@mandelbit.com \
    --to=ralf@mandelbit.com \
    --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 \
    /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