Browse code

Fix openssl OOB read CVE-2017-3735

Change-Id: I0ea1db71b382cc6a72a87564e5bdd1f8d534ee02
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4015
Reviewed-by: Sharath George
Tested-by: Sharath George

Vinay Kulkarni authored on 2017/10/11 08:39:57
Showing 4 changed files
1 1
deleted file mode 100644
... ...
@@ -1,34 +0,0 @@
1
-diff -ru openssl-1.0.2h/crypto/bn/bn_print.c openssl-1.0.2h-modified/crypto/bn/bn_print.c
2
-+++ openssl-1.0.2h-modified/crypto/bn/bn_print.c	2016-09-20 15:41:13.789132068 -0700
3
-@@ -111,6 +111,7 @@
4
-     char *p;
5
-     BIGNUM *t = NULL;
6
-     BN_ULONG *bn_data = NULL, *lp;
7
-+    int bn_data_num;
8
- 
9
-     /*-
10
-      * get an upper bound for the length of the decimal integer
11
-@@ -120,8 +121,8 @@
12
-      */
13
-     i = BN_num_bits(a) * 3;
14
-     num = (i / 10 + i / 1000 + 1) + 1;
15
--    bn_data =
16
--        (BN_ULONG *)OPENSSL_malloc((num / BN_DEC_NUM + 1) * sizeof(BN_ULONG));
17
-+    bn_data_num = num / BN_DEC_NUM + 1;
18
-+    bn_data = OPENSSL_malloc(bn_data_num * sizeof(BN_ULONG));
19
-     buf = (char *)OPENSSL_malloc(num + 3);
20
-     if ((buf == NULL) || (bn_data == NULL)) {
21
-         BNerr(BN_F_BN_BN2DEC, ERR_R_MALLOC_FAILURE);
22
-@@ -143,7 +144,11 @@
23
-         i = 0;
24
-         while (!BN_is_zero(t)) {
25
-             *lp = BN_div_word(t, BN_DEC_CONV);
26
-+            if (*lp == (BN_ULONG)-1)
27
-+                goto err;
28
-             lp++;
29
-+            if (lp - bn_data >= bn_data_num)
30
-+                goto err;
31
-         }
32
-         lp--;
33
-         /*
34 1
deleted file mode 100644
... ...
@@ -1,28 +0,0 @@
1
-From 2b4029e68fd7002d2307e6c3cde0f3784eef9c83 Mon Sep 17 00:00:00 2001
2
-From: "Dr. Stephen Henson" <steve@openssl.org>
3
-Date: Fri, 19 Aug 2016 23:28:29 +0100
4
-Subject: [PATCH] Avoid overflow in MDC2_Update()
5
-
6
-Thanks to Shi Lei for reporting this issue.
7
-
8
-CVE-2016-6303
9
-
10
-Reviewed-by: Matt Caswell <matt@openssl.org>
11
-(cherry picked from commit 55d83bf7c10c7b205fffa23fa7c3977491e56c07)
12
- crypto/mdc2/mdc2dgst.c | 2 +-
13
- 1 file changed, 1 insertion(+), 1 deletion(-)
14
-
15
-diff --git a/crypto/mdc2/mdc2dgst.c b/crypto/mdc2/mdc2dgst.c
16
-index 6615cf8..2dce493 100644
17
-+++ b/crypto/mdc2/mdc2dgst.c
18
-@@ -91,7 +91,7 @@ int MDC2_Update(MDC2_CTX *c, const unsigned char *in, size_t len)
19
- 
20
-     i = c->num;
21
-     if (i != 0) {
22
--        if (i + len < MDC2_BLOCK) {
23
-+        if (len < MDC2_BLOCK - i) {
24
-             /* partial block */
25
-             memcpy(&(c->data[i]), in, len);
26
-             c->num += (int)len;
27 1
new file mode 100644
... ...
@@ -0,0 +1,36 @@
0
+From 31c8b265591a0aaa462a1f3eb5770661aaac67db Mon Sep 17 00:00:00 2001
1
+From: Rich Salz <rsalz@openssl.org>
2
+Date: Tue, 22 Aug 2017 11:44:41 -0400
3
+Subject: [PATCH] Avoid out-of-bounds read
4
+
5
+Fixes CVE 2017-3735
6
+
7
+Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
8
+(Merged from https://github.com/openssl/openssl/pull/4276)
9
+
10
+(cherry picked from commit b23171744b01e473ebbfd6edad70c1c3825ffbcd)
11
+---
12
+ crypto/x509v3/v3_addr.c | 10 ++++++----
13
+ 1 file changed, 6 insertions(+), 4 deletions(-)
14
+
15
+diff --git a/crypto/x509v3/v3_addr.c b/crypto/x509v3/v3_addr.c
16
+index 1290dec9bb8..af080a04f2b 100644
17
+--- a/crypto/x509v3/v3_addr.c
18
+@@ -130,10 +130,12 @@ static int length_from_afi(const unsigned afi)
19
+  */
20
+ unsigned int v3_addr_get_afi(const IPAddressFamily *f)
21
+ {
22
+-    return ((f != NULL &&
23
+-             f->addressFamily != NULL && f->addressFamily->data != NULL)
24
+-            ? ((f->addressFamily->data[0] << 8) | (f->addressFamily->data[1]))
25
+-            : 0);
26
++    if (f == NULL
27
++            || f->addressFamily == NULL
28
++            || f->addressFamily->data == NULL
29
++            || f->addressFamily->length < 2)
30
++        return 0;
31
++    return (f->addressFamily->data[0] << 8) | f->addressFamily->data[1];
32
+ }
33
+ 
34
+ /*
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        Management tools and libraries relating to cryptography
2 2
 Name:           openssl
3 3
 Version:        1.0.2l
4
-Release:        1%{?dist}
4
+Release:        2%{?dist}
5 5
 License:        OpenSSL
6 6
 URL:            http://www.openssl.org
7 7
 Group:          System Environment/Security
... ...
@@ -13,6 +13,7 @@ Patch0:         c_rehash.patch
13 13
 Patch1:         openssl-1.0.2f-ipv6apps.patch
14 14
 Patch2:         openssl-init-conslidate.patch
15 15
 Patch3:         openssl-drbg-default-read-system-fips.patch
16
+Patch4:         openssl-CVE-2017-3735.patch
16 17
 %if %{with_check}
17 18
 BuildRequires: zlib-devel
18 19
 %endif
... ...
@@ -56,6 +57,7 @@ Perl scripts that convert certificates and keys to various formats.
56 56
 %patch1 -p1
57 57
 %patch2 -p1
58 58
 %patch3 -p1
59
+%patch4 -p1
59 60
 
60 61
 %build
61 62
 export CFLAGS="%{optflags}"
... ...
@@ -115,6 +117,8 @@ rm -rf %{buildroot}/*
115 115
 /%{_bindir}/c_rehash
116 116
 
117 117
 %changelog
118
+*   Tue Oct 10 2017 Vinay Kulkarni <kulkarniv@vmware.com> 1.0.2l-2
119
+-   Fix CVE-2017-3735 OOB read.
118 120
 *   Fri Aug 11 2017 Anish Swaminathan <anishs@vmware.com> 1.0.2l-1
119 121
 -   Upgrade to 1.0.2l
120 122
 *   Thu Aug 10 2017 Chang Lee <changlee@vmware.com> 1.0.2k-4