* crypto: lrw - Fix atomic sleep when walking skcipher
@ 2019-04-14 12:07 Herbert Xu
2019-04-15 6:37 ` [v2 PATCH] " Herbert Xu
0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2019-04-14 12:07 UTC (permalink / raw)
To: linux-crypto, Ondrej Mosnacek
When we perform a walk in the completion function, we need to ensure
that it is atomic.
Fixes: ac3c8f36c31d ("crypto: lrw - Do not use auxiliary buffer")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/crypto/lrw.c b/crypto/lrw.c
index 0430ccd08728..aef3588e1550 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -143,7 +143,8 @@ static int next_index(u32 *counter)
* mutliple calls to the 'ecb(..)' instance, which usually would be slower than
* just doing the next_index() calls again.
*/
-static int xor_tweak(struct skcipher_request *req, bool second_pass)
+static int xor_tweak(struct skcipher_request *req, bool second_pass,
+ bool atomic)
{
const int bs = LRW_BLOCK_SIZE;
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
@@ -161,7 +162,7 @@ static int xor_tweak(struct skcipher_request *req, bool second_pass)
skcipher_request_set_tfm(req, tfm);
}
- err = skcipher_walk_virt(&w, req, false);
+ err = skcipher_walk_virt(&w, req, atomic);
iv = (__be32 *)w.iv;
counter[0] = be32_to_cpu(iv[3]);
@@ -200,12 +201,12 @@ static int xor_tweak(struct skcipher_request *req, bool second_pass)
static int xor_tweak_pre(struct skcipher_request *req)
{
- return xor_tweak(req, false);
+ return xor_tweak(req, false, false);
}
-static int xor_tweak_post(struct skcipher_request *req)
+static int xor_tweak_post(struct skcipher_request *req, bool atomic)
{
- return xor_tweak(req, true);
+ return xor_tweak(req, true, atomic);
}
static void crypt_done(struct crypto_async_request *areq, int err)
@@ -213,7 +214,7 @@ static void crypt_done(struct crypto_async_request *areq, int err)
struct skcipher_request *req = areq->data;
if (!err)
- err = xor_tweak_post(req);
+ err = xor_tweak_post(req, true);
skcipher_request_complete(req, err);
}
@@ -245,7 +246,7 @@ static int encrypt(struct skcipher_request *req)
init_crypt(req);
return xor_tweak_pre(req) ?:
crypto_skcipher_encrypt(subreq) ?:
- xor_tweak_post(req);
+ xor_tweak_post(req, false);
}
static int decrypt(struct skcipher_request *req)
@@ -256,7 +257,7 @@ static int decrypt(struct skcipher_request *req)
init_crypt(req);
return xor_tweak_pre(req) ?:
crypto_skcipher_decrypt(subreq) ?:
- xor_tweak_post(req);
+ xor_tweak_post(req, false);
}
static int init_tfm(struct crypto_skcipher *tfm)
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [v2 PATCH] crypto: lrw - Fix atomic sleep when walking skcipher
2019-04-14 12:07 crypto: lrw - Fix atomic sleep when walking skcipher Herbert Xu
@ 2019-04-15 6:37 ` Herbert Xu
2019-04-15 8:55 ` Ondrej Mosnacek
0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2019-04-15 6:37 UTC (permalink / raw)
To: linux-crypto, Ondrej Mosnacek; +Cc: Eric Biggers
When we perform a walk in the completion function, we need to ensure
that it is atomic.
Fixes: ac3c8f36c31d ("crypto: lrw - Do not use auxiliary buffer")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
diff --git a/crypto/lrw.c b/crypto/lrw.c
index 0430ccd08728..08a0e458bc3e 100644
--- a/crypto/lrw.c
+++ b/crypto/lrw.c
@@ -212,8 +212,12 @@ static void crypt_done(struct crypto_async_request *areq, int err)
{
struct skcipher_request *req = areq->data;
- if (!err)
+ if (!err) {
+ struct rctx *rctx = skcipher_request_ctx(req);
+
+ rctx->subreq.base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
err = xor_tweak_post(req);
+ }
skcipher_request_complete(req, err);
}
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [v2 PATCH] crypto: lrw - Fix atomic sleep when walking skcipher
2019-04-15 6:37 ` [v2 PATCH] " Herbert Xu
@ 2019-04-15 8:55 ` Ondrej Mosnacek
0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Mosnacek @ 2019-04-15 8:55 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-crypto, Eric Biggers
On Mon, Apr 15, 2019 at 8:37 AM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> When we perform a walk in the completion function, we need to ensure
> that it is atomic.
>
> Fixes: ac3c8f36c31d ("crypto: lrw - Do not use auxiliary buffer")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: Ondrej Mosnacek <omosnace@redhat.com>
>
> diff --git a/crypto/lrw.c b/crypto/lrw.c
> index 0430ccd08728..08a0e458bc3e 100644
> --- a/crypto/lrw.c
> +++ b/crypto/lrw.c
> @@ -212,8 +212,12 @@ static void crypt_done(struct crypto_async_request *areq, int err)
> {
> struct skcipher_request *req = areq->data;
>
> - if (!err)
> + if (!err) {
> + struct rctx *rctx = skcipher_request_ctx(req);
> +
> + rctx->subreq.base.flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
> err = xor_tweak_post(req);
> + }
>
> skcipher_request_complete(req, err);
> }
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-15 8:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-14 12:07 crypto: lrw - Fix atomic sleep when walking skcipher Herbert Xu
2019-04-15 6:37 ` [v2 PATCH] " Herbert Xu
2019-04-15 8:55 ` Ondrej Mosnacek
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.