openssl: fix low-severity CVE-2023-1255
[openwrt/staging/dedeckeh.git] / package / libs / openssl / patches / 220-aesv8-armx.pl-Avoid-buffer-overrread-in-AES-XTS-decr.patch
1 From 02ac9c9420275868472f33b01def01218742b8bb Mon Sep 17 00:00:00 2001
2 From: Tomas Mraz <tomas@openssl.org>
3 Date: Mon, 17 Apr 2023 16:51:20 +0200
4 Subject: [PATCH] aesv8-armx.pl: Avoid buffer overrread in AES-XTS decryption
5
6 Original author: Nevine Ebeid (Amazon)
7 Fixes: CVE-2023-1255
8
9 The buffer overread happens on decrypts of 4 mod 5 sizes.
10 Unless the memory just after the buffer is unmapped this is harmless.
11
12 Reviewed-by: Paul Dale <pauli@openssl.org>
13 Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
14 (Merged from https://github.com/openssl/openssl/pull/20759)
15
16 (cherry picked from commit 72dfe46550ee1f1bbfacd49f071419365bc23304)
17
18 diff --git a/crypto/aes/asm/aesv8-armx.pl b/crypto/aes/asm/aesv8-armx.pl
19 index 6a7bf05d1b..bd583e2c89 100755
20 --- a/crypto/aes/asm/aesv8-armx.pl
21 +++ b/crypto/aes/asm/aesv8-armx.pl
22 @@ -3353,7 +3353,7 @@ $code.=<<___ if ($flavour =~ /64/);
23 .align 4
24 .Lxts_dec_tail4x:
25 add $inp,$inp,#16
26 - vld1.32 {$dat0},[$inp],#16
27 + tst $tailcnt,#0xf
28 veor $tmp1,$dat1,$tmp0
29 vst1.8 {$tmp1},[$out],#16
30 veor $tmp2,$dat2,$tmp2
31 @@ -3362,6 +3362,8 @@ $code.=<<___ if ($flavour =~ /64/);
32 veor $tmp4,$dat4,$tmp4
33 vst1.8 {$tmp3-$tmp4},[$out],#32
34
35 + b.eq .Lxts_dec_abort
36 + vld1.32 {$dat0},[$inp],#16
37 b .Lxts_done
38 .align 4
39 .Lxts_outer_dec_tail: