From: Antoine Tenart <antoine.tenart@bootlin.com>
To: herbert@gondor.apana.org.au, davem@davemloft.net
Cc: Antoine Tenart <antoine.tenart@bootlin.com>,
linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
thomas.petazzoni@bootlin.com, maxime.chevallier@bootlin.com,
gregory.clement@bootlin.com, miquel.raynal@bootlin.com,
nadavh@marvell.com, oferh@marvell.com, igall@marvell.com
Subject: [PATCH 08/12] crypto: inside-secure - do not access buffers mapped to the device
Date: Thu, 15 Mar 2018 16:38:47 +0100 [thread overview]
Message-ID: <20180315153851.9958-9-antoine.tenart@bootlin.com> (raw)
In-Reply-To: <20180315153851.9958-1-antoine.tenart@bootlin.com>
This patches update the way the digest is copied from the state buffer
to the result buffer, so that the copy only happen after the state
buffer was DMA unmapped, as otherwise the buffer would be owned by the
device.
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
---
drivers/crypto/inside-secure/safexcel_hash.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
index ef3e0c1c0f2c..b9ec82f3dee1 100644
--- a/drivers/crypto/inside-secure/safexcel_hash.c
+++ b/drivers/crypto/inside-secure/safexcel_hash.c
@@ -156,10 +156,6 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv, int rin
safexcel_complete(priv, ring);
spin_unlock_bh(&priv->ring[ring].egress_lock);
- if (sreq->finish)
- memcpy(areq->result, sreq->state,
- crypto_ahash_digestsize(ahash));
-
if (sreq->nents) {
dma_unmap_sg(priv->dev, areq->src, sreq->nents, DMA_TO_DEVICE);
sreq->nents = 0;
@@ -177,6 +173,10 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv, int rin
sreq->cache_dma = 0;
}
+ if (sreq->finish)
+ memcpy(areq->result, sreq->state,
+ crypto_ahash_digestsize(ahash));
+
cache_len = sreq->len - sreq->processed;
if (cache_len)
memcpy(sreq->cache, sreq->cache_next, cache_len);
--
2.14.3
next prev parent reply other threads:[~2018-03-15 15:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-15 15:38 [PATCH 00/12] crypto: inside-secure - hmac(sha256/sha224) support Antoine Tenart
2018-03-15 15:38 ` [PATCH 01/12] crypto: inside-secure - move hash result dma mapping to request Antoine Tenart
2018-03-15 15:38 ` [PATCH 02/12] crypto: inside-secure - move cache " Antoine Tenart
2018-03-15 15:38 ` [PATCH 03/12] crypto: inside-secure - wait for the request to complete if in the backlog Antoine Tenart
2018-03-15 15:38 ` [PATCH 04/12] crypto: inside-secure - move the digest to the request context Antoine Tenart
2018-03-15 15:38 ` [PATCH 05/12] crypto: inside-secure - fix typo s/allways/always/ in a define Antoine Tenart
2018-03-15 15:38 ` [PATCH 06/12] crypto: inside-secure - fix a typo in a register name Antoine Tenart
2018-03-15 15:38 ` [PATCH 07/12] crypto: inside-secure - improve the send error path Antoine Tenart
2018-03-15 15:38 ` Antoine Tenart [this message]
2018-03-15 15:38 ` [PATCH 09/12] crypto: inside-secure - improve the skcipher token Antoine Tenart
2018-03-15 15:38 ` [PATCH 10/12] crypto: inside-secure - the context ipad/opad should use the state sz Antoine Tenart
2018-03-15 15:38 ` [PATCH 11/12] crypto: inside-secure - hmac(sha256) support Antoine Tenart
2018-03-17 19:08 ` kbuild test robot
2018-03-15 15:38 ` [PATCH 12/12] crypto: inside-secure - hmac(sha224) support Antoine Tenart
2018-03-15 15:45 ` [PATCH 00/12] crypto: inside-secure - hmac(sha256/sha224) support Antoine Tenart
2018-03-16 8:37 ` 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=20180315153851.9958-9-antoine.tenart@bootlin.com \
--to=antoine.tenart@bootlin.com \
--cc=davem@davemloft.net \
--cc=gregory.clement@bootlin.com \
--cc=herbert@gondor.apana.org.au \
--cc=igall@marvell.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.chevallier@bootlin.com \
--cc=miquel.raynal@bootlin.com \
--cc=nadavh@marvell.com \
--cc=oferh@marvell.com \
--cc=thomas.petazzoni@bootlin.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