[v2] crypto: xts - Fix atomic sleep when walking skcipher
diff mbox series

Message ID 20190415063519.fs3li4h5i6yiycm6@gondor.apana.org.au
State Accepted
Commit 44427c0fbc09b448b22410978a4ef6ee37599d25
Headers show
Series
  • [v2] crypto: xts - Fix atomic sleep when walking skcipher
Related show

Commit Message

Herbert Xu April 15, 2019, 6:35 a.m. UTC
When we perform a walk in the completion function, we need to ensure
that it is atomic.

Reported-by: syzbot+6f72c20560060c98b566@syzkaller.appspotmail.com
Fixes: 78105c7e769b ("crypto: xts - Drop use of auxiliary buffer")
Cc: <stable@vger.kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Comments

Ondrej Mosnacek April 15, 2019, 8:56 a.m. UTC | #1
On Mon, Apr 15, 2019 at 8:35 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.
>
> Reported-by: syzbot+6f72c20560060c98b566@syzkaller.appspotmail.com
> Fixes: 78105c7e769b ("crypto: xts - Drop use of 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/xts.c b/crypto/xts.c
> index 847f54f76789..2f948328cabb 100644
> --- a/crypto/xts.c
> +++ b/crypto/xts.c
> @@ -137,8 +137,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

Patch
diff mbox series

diff --git a/crypto/xts.c b/crypto/xts.c
index 847f54f76789..2f948328cabb 100644
--- a/crypto/xts.c
+++ b/crypto/xts.c
@@ -137,8 +137,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);
 }