From: Eric Biggers <ebiggers@kernel.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org, dm-devel@lists.linux.dev
Subject: Re: A question about modifying the buffer under authenticated encryption
Date: Wed, 7 Feb 2024 20:36:10 -0800 [thread overview]
Message-ID: <20240208043610.GB85799@sol.localdomain> (raw)
In-Reply-To: <1a4713fc-62c7-4a8f-e28a-14fc5d04977@redhat.com>
On Wed, Feb 07, 2024 at 01:51:51PM +0100, Mikulas Patocka wrote:
>
>
> On Tue, 6 Feb 2024, Eric Biggers wrote:
>
> > On Tue, Feb 06, 2024 at 10:46:59PM +0100, Mikulas Patocka wrote:
> > > Hi
> > >
> > > I'm trying to fix some problems in dm-crypt that it may report
> > > authentication failures when the user reads data with O_DIRECT and
> > > modifies the read buffer while it is being read.
> > >
> > > I'd like to ask you:
> > >
> > > 1. If the authenticated encryption encrypts a message, reading from
> > > buffer1 and writing to buffer2 - and buffer1 changes while reading from
> > > it - is it possible that it generates invalid authentication tag?
> > >
> > > 2. If the authenticated encryption decrypts a message, reading from
> > > buffer1 and writing to buffer2 - and buffer2 changes while writing to
> > > it - is is possible that it reports authentication tag mismatch?
> > >
> >
> > Yes, both scenarios are possible. But it depends on the AEAD algorithm and how
> > it happens to be implemented, and on whether the data overlaps or not.
> >
> > This is very much a "don't do that" sort of thing.
> >
> > - Eric
>
> I see. So I will copy the data to a kernel buffer before encryption or
> decryption.
>
> I assume that authenticated encryption or decryption using the same buffer
> as a source and as a destination should be ok. Right?
>
The crypto_aead API allows the source and destination to overlap, yes.
- Eric
next prev parent reply other threads:[~2024-02-08 4:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 21:46 A question about modifying the buffer under authenticated encryption Mikulas Patocka
2024-02-07 0:47 ` Eric Biggers
2024-02-07 12:51 ` Mikulas Patocka
2024-02-08 3:42 ` Herbert Xu
2024-02-08 4:36 ` Eric Biggers [this message]
2024-02-08 4:40 ` Herbert Xu
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=20240208043610.GB85799@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=davem@davemloft.net \
--cc=dm-devel@lists.linux.dev \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=mpatocka@redhat.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