]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/crypto-vmx-fix-copy-paste-error-in-ctr-mode.patch
a753ee198c16e1b28de1b173499050efa038304a
[thirdparty/kernel/stable-queue.git] / queue-4.4 / crypto-vmx-fix-copy-paste-error-in-ctr-mode.patch
1 From dcf7b48212c0fab7df69e84fab22d6cb7c8c0fb9 Mon Sep 17 00:00:00 2001
2 From: Daniel Axtens <dja@axtens.net>
3 Date: Fri, 15 Mar 2019 13:09:01 +1100
4 Subject: crypto: vmx - fix copy-paste error in CTR mode
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Daniel Axtens <dja@axtens.net>
10
11 commit dcf7b48212c0fab7df69e84fab22d6cb7c8c0fb9 upstream.
12
13 The original assembly imported from OpenSSL has two copy-paste
14 errors in handling CTR mode. When dealing with a 2 or 3 block tail,
15 the code branches to the CBC decryption exit path, rather than to
16 the CTR exit path.
17
18 This leads to corruption of the IV, which leads to subsequent blocks
19 being corrupted.
20
21 This can be detected with libkcapi test suite, which is available at
22 https://github.com/smuellerDD/libkcapi
23
24 Reported-by: Ondrej Mosnáček <omosnacek@gmail.com>
25 Fixes: 5c380d623ed3 ("crypto: vmx - Add support for VMS instructions by ASM")
26 Cc: stable@vger.kernel.org
27 Signed-off-by: Daniel Axtens <dja@axtens.net>
28 Tested-by: Michael Ellerman <mpe@ellerman.id.au>
29 Tested-by: Ondrej Mosnacek <omosnacek@gmail.com>
30 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
31 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32
33 ---
34 drivers/crypto/vmx/aesp8-ppc.pl | 4 ++--
35 1 file changed, 2 insertions(+), 2 deletions(-)
36
37 --- a/drivers/crypto/vmx/aesp8-ppc.pl
38 +++ b/drivers/crypto/vmx/aesp8-ppc.pl
39 @@ -1795,7 +1795,7 @@ Lctr32_enc8x_three:
40 stvx_u $out1,$x10,$out
41 stvx_u $out2,$x20,$out
42 addi $out,$out,0x30
43 - b Lcbc_dec8x_done
44 + b Lctr32_enc8x_done
45
46 .align 5
47 Lctr32_enc8x_two:
48 @@ -1807,7 +1807,7 @@ Lctr32_enc8x_two:
49 stvx_u $out0,$x00,$out
50 stvx_u $out1,$x10,$out
51 addi $out,$out,0x20
52 - b Lcbc_dec8x_done
53 + b Lctr32_enc8x_done
54
55 .align 5
56 Lctr32_enc8x_one: