From: Thomas Fourier <fourier.thomas@gmail.com>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: stable@vger.kernel.org, Antoine Tenart <atenart@kernel.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Richard van Schagen <vschagen@icloud.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: eip93 - Fix dma_unmap_single() direction in eip93_hash_handle_result()
Date: Mon, 30 Mar 2026 16:38:50 +0200 [thread overview]
Message-ID: <6c016af0-718c-4986-b707-c4ce74b72739@gmail.com> (raw)
In-Reply-To: <69ca4458.050a0220.3569e7.2980@mx.google.com>
Hi,
On 30/03/2026 11:37, Christian Marangi wrote:
> On Mon, Mar 30, 2026 at 11:18:14AM +0200, Thomas Fourier wrote:
>
> Hi,
>
> was this tested with the crypto self test?
This was only compile tested. The change is based on the documentation which
states that dma_map_single() and dma_unmap_single() should take all the same
parameters. From what I understand, it could cause issues with bounce buffers
and IOMMU permission if it is activated.
>
> I need to check the code again but in theory with handle result, we should
> get the data from device in sa_state and cache should be invalidated. If we
> want to use matching maybe we should change to BIDIRECTIONAL?
Yes, sa_state is set before the mapping for the device and read after the
unmapping so I think the BIDIRECTIONAL tag is required.
Should I split the changes between eip93-common.c which seem good regarding that
as is, and eip93-hash.c and change the direction to BIDIRECTIONNAL?
>
> The mismatched flag was to invalidate relevant cache on tramissing to device and
> then invalidate relevant cache when reading it.
>
>> ---
>> drivers/crypto/inside-secure/eip93/eip93-common.c | 4 ++--
>> drivers/crypto/inside-secure/eip93/eip93-hash.c | 2 +-
>> 2 files changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/crypto/inside-secure/eip93/eip93-common.c b/drivers/crypto/inside-secure/eip93/eip93-common.c
>> index f4ad6beff15e..75659a45ea5a 100644
>> --- a/drivers/crypto/inside-secure/eip93/eip93-common.c
>> +++ b/drivers/crypto/inside-secure/eip93/eip93-common.c
>> @@ -687,12 +687,12 @@ void eip93_handle_result(struct eip93_device *eip93, struct eip93_cipher_reqctx
>> if (rctx->sa_state_ctr)
>> dma_unmap_single(eip93->dev, rctx->sa_state_ctr_base,
>> sizeof(*rctx->sa_state_ctr),
>> - DMA_FROM_DEVICE);
>> + DMA_TO_DEVICE);
>>
>> if (rctx->sa_state)
>> dma_unmap_single(eip93->dev, rctx->sa_state_base,
>> sizeof(*rctx->sa_state),
>> - DMA_FROM_DEVICE);
>> + DMA_TO_DEVICE);
>>
>> if (!IS_ECB(rctx->flags))
>> memcpy(reqiv, rctx->sa_state->state_iv, rctx->ivsize);
>> diff --git a/drivers/crypto/inside-secure/eip93/eip93-hash.c b/drivers/crypto/inside-secure/eip93/eip93-hash.c
>> index 2705855475b2..19a41a0db667 100644
>> --- a/drivers/crypto/inside-secure/eip93/eip93-hash.c
>> +++ b/drivers/crypto/inside-secure/eip93/eip93-hash.c
>> @@ -67,7 +67,7 @@ void eip93_hash_handle_result(struct crypto_async_request *async, int err)
>> int i;
>>
>> dma_unmap_single(eip93->dev, rctx->sa_state_base,
>> - sizeof(*sa_state), DMA_FROM_DEVICE);
>> + sizeof(*sa_state), DMA_TO_DEVICE);
>>
>> /*
>> * With partial_hash assume SHA256_DIGEST_SIZE buffer is passed.
>> --
>> 2.43.0
>>
>
prev parent reply other threads:[~2026-03-30 14:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-30 9:18 Thomas Fourier
2026-03-30 9:37 ` Christian Marangi
2026-03-30 14:38 ` Thomas Fourier [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=6c016af0-718c-4986-b707-c4ce74b72739@gmail.com \
--to=fourier.thomas@gmail.com \
--cc=ansuelsmth@gmail.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 \
--cc=stable@vger.kernel.org \
--cc=vschagen@icloud.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
Powered by JetHome