Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1639333 > unrolled thread

[PATCH 0/4] crypto: async crypto op fixes

Started byGilad Ben-Yossef <gilad@benyossef.com>
First post2017-05-11 14:00 +0200
Last post2017-05-11 14:00 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/4] crypto: async crypto op fixes Gilad Ben-Yossef <gilad@benyossef.com> - 2017-05-11 14:00 +0200
    [PATCH 2/4] crypto: drbg wait for crypto op not signal safe Gilad Ben-Yossef <gilad@benyossef.com> - 2017-05-11 14:00 +0200
    [PATCH 1/4] crypto: handle EBUSY due to backlog correctly Gilad Ben-Yossef <gilad@benyossef.com> - 2017-05-11 14:00 +0200

#1639333 — [PATCH 0/4] crypto: async crypto op fixes

FromGilad Ben-Yossef <gilad@benyossef.com>
Date2017-05-11 14:00 +0200
Subject[PATCH 0/4] crypto: async crypto op fixes
Message-ID<tFUVb-5Qu-3@gated-at.bofh.it>
This patch set fixes various usage and documentation errors
in waiting for async crypto op to complete which can result
in data corruption.

Note: these were discovered in the process of working on a
patch set that replaces these call sites and more with a
generic implementation that will prevent these problems
going forward. These are just the fix ups for current code.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
CC: stable@vger.kernel.org
CC: Eric Biggers <ebiggers3@gmail.com>

Gilad Ben-Yossef (4):
  crypto: handle EBUSY due to backlog correctly
  crypto: drbg wait for crypto op not signal safe
  crypto: gcm wait for crypto op not signal safe
  crypto: Documentation: fix none signal safe sample

 Documentation/crypto/api-samples.rst | 2 +-
 crypto/asymmetric_keys/public_key.c  | 2 +-
 crypto/drbg.c                        | 5 ++---
 crypto/gcm.c                         | 6 ++----
 4 files changed, 6 insertions(+), 9 deletions(-)

-- 
2.1.4

[toc] | [next] | [standalone]


#1639336 — [PATCH 2/4] crypto: drbg wait for crypto op not signal safe

FromGilad Ben-Yossef <gilad@benyossef.com>
Date2017-05-11 14:00 +0200
Subject[PATCH 2/4] crypto: drbg wait for crypto op not signal safe
Message-ID<tFUVc-5Qu-15@gated-at.bofh.it>
In reply to#1639333
drbg_kcapi_sym_ctr() was using wait_for_completion_interruptible() to
wait for completion of async crypto op but if a signal occurs it
may return before DMA ops of HW crypto provider finish, thus
corrupting the output buffer.

Resolve this by using wait_for_completion() instead.

Reported-by: Eric Biggers <ebiggers3@gmail.com>
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
CC: stable@vger.kernel.org
---
 crypto/drbg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/crypto/drbg.c b/crypto/drbg.c
index fa749f4..fa9054d 100644
--- a/crypto/drbg.c
+++ b/crypto/drbg.c
@@ -1767,8 +1767,7 @@ static int drbg_kcapi_sym_ctr(struct drbg_state *drbg,
 			break;
 		case -EINPROGRESS:
 		case -EBUSY:
-			ret = wait_for_completion_interruptible(
-				&drbg->ctr_completion);
+			ret = wait_for_completion(&drbg->ctr_completion);
 			if (!ret && !drbg->ctr_async_err) {
 				reinit_completion(&drbg->ctr_completion);
 				break;
-- 
2.1.4

[toc] | [prev] | [next] | [standalone]


#1639337 — [PATCH 1/4] crypto: handle EBUSY due to backlog correctly

FromGilad Ben-Yossef <gilad@benyossef.com>
Date2017-05-11 14:00 +0200
Subject[PATCH 1/4] crypto: handle EBUSY due to backlog correctly
Message-ID<tFUVc-5Qu-23@gated-at.bofh.it>
In reply to#1639333
public_key_verify_signature() was passing the CRYPTO_TFM_REQ_MAY_BACKLOG
flag to akcipher_request_set_callback() but was not handling correctly
the case where a -EBUSY error could be returned from the call to
crypto_akcipher_verify() if backlog was used, possibly casuing
data corruption due to use-after-free of buffers.

Resolve this by handling -EBUSY correctly.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
CC: stable@vger.kernel.org
---
 crypto/asymmetric_keys/public_key.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c
index d3a989e..3cd6e12 100644
--- a/crypto/asymmetric_keys/public_key.c
+++ b/crypto/asymmetric_keys/public_key.c
@@ -141,7 +141,7 @@ int public_key_verify_signature(const struct public_key *pkey,
 	 * signature and returns that to us.
 	 */
 	ret = crypto_akcipher_verify(req);
-	if (ret == -EINPROGRESS) {
+	if ((ret == -EINPROGRESS) || (ret == -EBUSY)) {
 		wait_for_completion(&compl.completion);
 		ret = compl.err;
 	}
-- 
2.1.4

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web