* [PATCH 4.9,4.4] crypto: x86/chacha20 - avoid sleeping with preemption disabled
@ 2019-01-07 23:15 Eric Biggers
2019-01-08 8:21 ` Ard Biesheuvel
2019-01-10 19:11 ` Greg Kroah-Hartman
0 siblings, 2 replies; 4+ messages in thread
From: Eric Biggers @ 2019-01-07 23:15 UTC (permalink / raw)
To: stable, Greg Kroah-Hartman; +Cc: linux-crypto, Martin Willi, Ard Biesheuvel
From: Eric Biggers <ebiggers@google.com>
Hi Greg, please consider applying this to 4.9-stable and 4.4-stable.
It's a minimal fix for a bug that was fixed incidentally by a large
refactoring in v4.11.
>8------------------------------------------------------8<
In chacha20-simd, clear the MAY_SLEEP flag in the blkcipher_desc to
prevent sleeping with preemption disabled, under kernel_fpu_begin().
This was fixed upstream incidentally by a large refactoring,
commit 9ae433bc79f9 ("crypto: chacha20 - convert generic and x86
versions to skcipher"). But syzkaller easily trips over this when
running on older kernels, as it's easily reachable via AF_ALG.
Therefore, this patch makes the minimal fix for older kernels.
Fixes: c9320b6dcb89 ("crypto: chacha20 - Add a SSSE3 SIMD variant for x86_64")
Cc: linux-crypto@vger.kernel.org
Cc: Martin Willi <martin@strongswan.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
arch/x86/crypto/chacha20_glue.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/crypto/chacha20_glue.c b/arch/x86/crypto/chacha20_glue.c
index f910d1d449f00..0a5fedf43bdc8 100644
--- a/arch/x86/crypto/chacha20_glue.c
+++ b/arch/x86/crypto/chacha20_glue.c
@@ -77,6 +77,7 @@ static int chacha20_simd(struct blkcipher_desc *desc, struct scatterlist *dst,
blkcipher_walk_init(&walk, dst, src, nbytes);
err = blkcipher_walk_virt_block(desc, &walk, CHACHA20_BLOCK_SIZE);
+ desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
crypto_chacha20_init(state, crypto_blkcipher_ctx(desc->tfm), walk.iv);
--
2.20.1.97.g81188d93c3-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 4.9,4.4] crypto: x86/chacha20 - avoid sleeping with preemption disabled
2019-01-07 23:15 [PATCH 4.9,4.4] crypto: x86/chacha20 - avoid sleeping with preemption disabled Eric Biggers
@ 2019-01-08 8:21 ` Ard Biesheuvel
2019-01-08 8:21 ` Ard Biesheuvel
2019-01-10 19:11 ` Greg Kroah-Hartman
1 sibling, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2019-01-08 8:21 UTC (permalink / raw)
To: Eric Biggers
Cc: stable, Greg Kroah-Hartman,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Martin Willi
On Tue, 8 Jan 2019 at 00:16, Eric Biggers <ebiggers@kernel.org> wrote:
>
> From: Eric Biggers <ebiggers@google.com>
>
> Hi Greg, please consider applying this to 4.9-stable and 4.4-stable.
> It's a minimal fix for a bug that was fixed incidentally by a large
> refactoring in v4.11.
>
> >8------------------------------------------------------8<
>
> In chacha20-simd, clear the MAY_SLEEP flag in the blkcipher_desc to
> prevent sleeping with preemption disabled, under kernel_fpu_begin().
>
> This was fixed upstream incidentally by a large refactoring,
> commit 9ae433bc79f9 ("crypto: chacha20 - convert generic and x86
> versions to skcipher"). But syzkaller easily trips over this when
> running on older kernels, as it's easily reachable via AF_ALG.
> Therefore, this patch makes the minimal fix for older kernels.
>
> Fixes: c9320b6dcb89 ("crypto: chacha20 - Add a SSSE3 SIMD variant for x86_64")
> Cc: linux-crypto@vger.kernel.org
> Cc: Martin Willi <martin@strongswan.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> arch/x86/crypto/chacha20_glue.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/crypto/chacha20_glue.c b/arch/x86/crypto/chacha20_glue.c
> index f910d1d449f00..0a5fedf43bdc8 100644
> --- a/arch/x86/crypto/chacha20_glue.c
> +++ b/arch/x86/crypto/chacha20_glue.c
> @@ -77,6 +77,7 @@ static int chacha20_simd(struct blkcipher_desc *desc, struct scatterlist *dst,
>
> blkcipher_walk_init(&walk, dst, src, nbytes);
> err = blkcipher_walk_virt_block(desc, &walk, CHACHA20_BLOCK_SIZE);
> + desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
>
> crypto_chacha20_init(state, crypto_blkcipher_ctx(desc->tfm), walk.iv);
>
> --
> 2.20.1.97.g81188d93c3-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 4.9,4.4] crypto: x86/chacha20 - avoid sleeping with preemption disabled
2019-01-08 8:21 ` Ard Biesheuvel
@ 2019-01-08 8:21 ` Ard Biesheuvel
0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2019-01-08 8:21 UTC (permalink / raw)
To: Eric Biggers
Cc: stable, Greg Kroah-Hartman,
open list:HARDWARE RANDOM NUMBER GENERATOR CORE, Martin Willi
On Tue, 8 Jan 2019 at 00:16, Eric Biggers <ebiggers@kernel.org> wrote:
>
> From: Eric Biggers <ebiggers@google.com>
>
> Hi Greg, please consider applying this to 4.9-stable and 4.4-stable.
> It's a minimal fix for a bug that was fixed incidentally by a large
> refactoring in v4.11.
>
> >8------------------------------------------------------8<
>
> In chacha20-simd, clear the MAY_SLEEP flag in the blkcipher_desc to
> prevent sleeping with preemption disabled, under kernel_fpu_begin().
>
> This was fixed upstream incidentally by a large refactoring,
> commit 9ae433bc79f9 ("crypto: chacha20 - convert generic and x86
> versions to skcipher"). But syzkaller easily trips over this when
> running on older kernels, as it's easily reachable via AF_ALG.
> Therefore, this patch makes the minimal fix for older kernels.
>
> Fixes: c9320b6dcb89 ("crypto: chacha20 - Add a SSSE3 SIMD variant for x86_64")
> Cc: linux-crypto@vger.kernel.org
> Cc: Martin Willi <martin@strongswan.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> arch/x86/crypto/chacha20_glue.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/crypto/chacha20_glue.c b/arch/x86/crypto/chacha20_glue.c
> index f910d1d449f00..0a5fedf43bdc8 100644
> --- a/arch/x86/crypto/chacha20_glue.c
> +++ b/arch/x86/crypto/chacha20_glue.c
> @@ -77,6 +77,7 @@ static int chacha20_simd(struct blkcipher_desc *desc, struct scatterlist *dst,
>
> blkcipher_walk_init(&walk, dst, src, nbytes);
> err = blkcipher_walk_virt_block(desc, &walk, CHACHA20_BLOCK_SIZE);
> + desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
>
> crypto_chacha20_init(state, crypto_blkcipher_ctx(desc->tfm), walk.iv);
>
> --
> 2.20.1.97.g81188d93c3-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 4.9,4.4] crypto: x86/chacha20 - avoid sleeping with preemption disabled
2019-01-07 23:15 [PATCH 4.9,4.4] crypto: x86/chacha20 - avoid sleeping with preemption disabled Eric Biggers
2019-01-08 8:21 ` Ard Biesheuvel
@ 2019-01-10 19:11 ` Greg Kroah-Hartman
1 sibling, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-01-10 19:11 UTC (permalink / raw)
To: Eric Biggers; +Cc: stable, linux-crypto, Martin Willi, Ard Biesheuvel
On Mon, Jan 07, 2019 at 03:15:59PM -0800, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> Hi Greg, please consider applying this to 4.9-stable and 4.4-stable.
> It's a minimal fix for a bug that was fixed incidentally by a large
> refactoring in v4.11.
>
> >8------------------------------------------------------8<
>
> In chacha20-simd, clear the MAY_SLEEP flag in the blkcipher_desc to
> prevent sleeping with preemption disabled, under kernel_fpu_begin().
>
> This was fixed upstream incidentally by a large refactoring,
> commit 9ae433bc79f9 ("crypto: chacha20 - convert generic and x86
> versions to skcipher"). But syzkaller easily trips over this when
> running on older kernels, as it's easily reachable via AF_ALG.
> Therefore, this patch makes the minimal fix for older kernels.
>
> Fixes: c9320b6dcb89 ("crypto: chacha20 - Add a SSSE3 SIMD variant for x86_64")
> Cc: linux-crypto@vger.kernel.org
> Cc: Martin Willi <martin@strongswan.org>
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> arch/x86/crypto/chacha20_glue.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/crypto/chacha20_glue.c b/arch/x86/crypto/chacha20_glue.c
> index f910d1d449f00..0a5fedf43bdc8 100644
> --- a/arch/x86/crypto/chacha20_glue.c
> +++ b/arch/x86/crypto/chacha20_glue.c
> @@ -77,6 +77,7 @@ static int chacha20_simd(struct blkcipher_desc *desc, struct scatterlist *dst,
>
> blkcipher_walk_init(&walk, dst, src, nbytes);
> err = blkcipher_walk_virt_block(desc, &walk, CHACHA20_BLOCK_SIZE);
> + desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP;
>
> crypto_chacha20_init(state, crypto_blkcipher_ctx(desc->tfm), walk.iv);
>
> --
> 2.20.1.97.g81188d93c3-goog
>
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-10 19:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-07 23:15 [PATCH 4.9,4.4] crypto: x86/chacha20 - avoid sleeping with preemption disabled Eric Biggers
2019-01-08 8:21 ` Ard Biesheuvel
2019-01-08 8:21 ` Ard Biesheuvel
2019-01-10 19:11 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).