aesv8-armx.pl: Avoid buffer overrread in AES-XTS decryption
authorTomas Mraz <tomas@openssl.org>
Mon, 17 Apr 2023 14:51:20 +0000 (16:51 +0200)
committerTomas Mraz <tomas@openssl.org>
Thu, 20 Apr 2023 15:50:09 +0000 (17:50 +0200)
Original author: Nevine Ebeid (Amazon)
Fixes: CVE-2023-1255
The buffer overread happens on decrypts of 4 mod 5 sizes.
Unless the memory just after the buffer is unmapped this is harmless.

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/20759)

(cherry picked from commit 72dfe46550ee1f1bbfacd49f071419365bc23304)

CHANGES.md
NEWS.md
crypto/aes/asm/aesv8-armx.pl

index a19b87bf70182cbecbba6458e9e8ae90eb201deb..7784b4966fbcf7a26ed8179f47793423c1005d79 100644 (file)
@@ -24,6 +24,15 @@ OpenSSL 3.1
 
 ### Changes between 3.1.0 and 3.1.1 [xx XXX xxxx]
 
+ * Fixed buffer overread in AES-XTS decryption on ARM 64 bit platforms which
+   happens if the buffer size is 4 mod 5. This can trigger a crash of an
+   application using AES-XTS decryption if the memory just after the buffer
+   being decrypted is not mapped.
+   Thanks to Anton Romanov (Amazon) for discovering the issue.
+   ([CVE-2023-1255])
+
+   *Nevine Ebeid*
+
  * Reworked the Fix for the Timing Oracle in RSA Decryption ([CVE-2022-4304]).
    The previous fix for this timing side channel turned out to cause
    a severe 2-3x performance regression in the typical use case
@@ -19724,6 +19733,7 @@ ndif
 
 <!-- Links -->
 
+[CVE-2023-1255]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-1255
 [CVE-2023-0466]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-0466
 [CVE-2023-0465]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-0465
 [CVE-2023-0464]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-0464
diff --git a/NEWS.md b/NEWS.md
index 9477662c822dec5d0feb7fa1f5b925d85d3b670b..f2a80be7b3093b0831adc3b655921df3c6b51599 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -21,6 +21,8 @@ OpenSSL 3.1
 
 ### Major changes between OpenSSL 3.1.0 and OpenSSL 3.1.1 [under development]
 
+  * Fixed buffer overread in AES-XTS decryption on ARM 64 bit platforms
+    ([CVE-2023-1255])
   * Fixed documentation of X509_VERIFY_PARAM_add0_policy() ([CVE-2023-0466])
   * Fixed handling of invalid certificate policies in leaf certificates
     ([CVE-2023-0465])
@@ -1449,6 +1451,7 @@ OpenSSL 0.9.x
   * Support for various new platforms
 
 <!-- Links -->
+[CVE-2023-1255]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-1255
 [CVE-2023-0466]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-0466
 [CVE-2023-0465]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-0465
 [CVE-2023-0464]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-0464
index ea74217317d614ee03831b8860013885370c8e1c..efd3ccd1a4f4c7aaef4c2da4b619a28c046f34ed 100755 (executable)
@@ -3367,7 +3367,7 @@ $code.=<<___      if ($flavour =~ /64/);
 .align 4
 .Lxts_dec_tail4x:
        add     $inp,$inp,#16
-       vld1.32 {$dat0},[$inp],#16
+       tst     $tailcnt,#0xf
        veor    $tmp1,$dat1,$tmp0
        vst1.8  {$tmp1},[$out],#16
        veor    $tmp2,$dat2,$tmp2
@@ -3376,6 +3376,8 @@ $code.=<<___      if ($flavour =~ /64/);
        veor    $tmp4,$dat4,$tmp4
        vst1.8  {$tmp3-$tmp4},[$out],#32
 
+       b.eq    .Lxts_dec_abort
+       vld1.32 {$dat0},[$inp],#16
        b       .Lxts_done
 .align 4
 .Lxts_outer_dec_tail: