Browse code

binutils : Fix CVE-2018-7643, CVE-2018-7208

Change-Id: I245303fba9643e8b86a9a32e3271f5dd26de8ef6
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/5012
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

Xiaolin Li authored on 2018/04/18 09:10:24
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,30 @@
0
+From eb77f6a4621795367a39cdd30957903af9dbb815 Mon Sep 17 00:00:00 2001
1
+From: Alan Modra <amodra@gmail.com>
2
+Date: Sat, 27 Jan 2018 08:19:33 +1030
3
+Subject: [PATCH] PR22741, objcopy segfault on fuzzed COFF object
4
+
5
+	PR 22741
6
+	* coffgen.c (coff_pointerize_aux): Ensure auxent tagndx is in
7
+	range before converting to a symbol table pointer.
8
+---
9
+ bfd/ChangeLog | 6 ++++++
10
+ bfd/coffgen.c | 3 ++-
11
+ 2 files changed, 8 insertions(+), 1 deletion(-)
12
+
13
+diff --git a/bfd/coffgen.c b/bfd/coffgen.c
14
+index b241087..4f90ead 100644
15
+--- a/bfd/coffgen.c
16
+@@ -1555,7 +1555,8 @@ coff_pointerize_aux (bfd *abfd,
17
+     }
18
+   /* A negative tagndx is meaningless, but the SCO 3.2v4 cc can
19
+      generate one, so we must be careful to ignore it.  */
20
+-  if (auxent->u.auxent.x_sym.x_tagndx.l > 0)
21
++  if ((unsigned long) auxent->u.auxent.x_sym.x_tagndx.l
22
++      < obj_raw_syment_count (abfd))
23
+     {
24
+       auxent->u.auxent.x_sym.x_tagndx.p =
25
+ 	table_base + auxent->u.auxent.x_sym.x_tagndx.l;
26
+-- 
27
+2.9.3
28
+
0 29
new file mode 100644
... ...
@@ -0,0 +1,85 @@
0
+From d11ae95ea3403559f052903ab053f43ad7821e37 Mon Sep 17 00:00:00 2001
1
+From: Nick Clifton <nickc@redhat.com>
2
+Date: Thu, 1 Mar 2018 16:14:08 +0000
3
+Subject: [PATCH] Prevent illegal memory accesses triggerd by intger overflow
4
+ when parsing corrupt DWARF information on a 32-bit host.
5
+
6
+	PR 22905
7
+	* dwarf.c (display_debug_ranges): Check that the offset loaded
8
+	from the range_entry structure is valid.
9
+---
10
+ binutils/ChangeLog |  6 ++++++
11
+ binutils/dwarf.c   | 15 +++++++++++++++
12
+ 2 files changed, 21 insertions(+)
13
+
14
+diff --git a/binutils/dwarf.c b/binutils/dwarf.c
15
+index 6aca9b7..17896e6 100644
16
+--- a/binutils/dwarf.c
17
+@@ -387,6 +387,9 @@ read_uleb128 (unsigned char * data,
18
+     }								\
19
+   while (0)
20
+ 
21
++/* Read AMOUNT bytes from PTR and store them in VAL as an unsigned value.
22
++   Checks to make sure that the read will not reach or pass END
23
++   and that VAL is big enough to hold AMOUNT bytes.  */
24
+ #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END)	\
25
+   do						\
26
+     {						\
27
+@@ -415,6 +418,7 @@ read_uleb128 (unsigned char * data,
28
+     }						\
29
+   while (0)
30
+ 
31
++/* Like SAFE_BYTE_GET, but also increments PTR by AMOUNT.  */
32
+ #define SAFE_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END)	\
33
+   do							\
34
+     {							\
35
+@@ -423,6 +427,7 @@ read_uleb128 (unsigned char * data,
36
+     }							\
37
+   while (0)
38
+ 
39
++/* Like SAFE_BYTE_GET, but reads a signed value.  */
40
+ #define SAFE_SIGNED_BYTE_GET(VAL, PTR, AMOUNT, END)	\
41
+   do							\
42
+     {							\
43
+@@ -441,6 +446,7 @@ read_uleb128 (unsigned char * data,
44
+     }							\
45
+   while (0)
46
+ 
47
++/* Like SAFE_SIGNED_BYTE_GET, but also increments PTR by AMOUNT.  */
48
+ #define SAFE_SIGNED_BYTE_GET_AND_INC(VAL, PTR, AMOUNT, END)	\
49
+   do								\
50
+     {								\
51
+@@ -6543,6 +6549,7 @@ display_debug_ranges_list (unsigned char *start, unsigned char *finish,
52
+ 	break;
53
+       SAFE_SIGNED_BYTE_GET_AND_INC (end, start, pointer_size, finish);
54
+ 
55
++      
56
+       printf ("    %8.8lx ", offset);
57
+ 
58
+       if (begin == 0 && end == 0)
59
+@@ -6810,6 +6817,13 @@ display_debug_ranges (struct dwarf_section *section,
60
+ 	  continue;
61
+ 	}
62
+ 
63
++      if (next < section_begin || next >= finish)
64
++	{
65
++	  warn (_("Corrupt offset (%#8.8lx) in range entry %u\n"),
66
++		(unsigned long) offset, i);
67
++	  continue;
68
++	}
69
++
70
+       if (dwarf_check != 0 && i > 0)
71
+ 	{
72
+ 	  if (start < next)
73
+@@ -6825,6 +6839,7 @@ display_debug_ranges (struct dwarf_section *section,
74
+ 		    (unsigned long) (next - section_begin), section->name);
75
+ 	    }
76
+ 	}
77
++
78
+       start = next;
79
+       last_start = next;
80
+ 
81
+-- 
82
+2.9.3
83
+
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        Contains a linker, an assembler, and other tools
2 2
 Name:           binutils
3 3
 Version:        2.30
4
-Release:        3%{?dist}
4
+Release:        4%{?dist}
5 5
 License:        GPLv2+
6 6
 URL:            http://www.gnu.org/software/binutils
7 7
 Group:          System Environment/Base
... ...
@@ -10,6 +10,8 @@ Distribution:   Photon
10 10
 Source0:        http://ftp.gnu.org/gnu/binutils/%{name}-%{version}.tar.xz
11 11
 %define sha1    binutils=574d3b5650413d6ee65195a4f5ecbddc3a38f718
12 12
 Patch0:         binutils-2.30-CVE-2018-6543.patch
13
+Patch1:         binutils-2.30-CVE-2018-7643.patch
14
+Patch2:         binutils-2.30-CVE-2018-7208.patch
13 15
 %description
14 16
 The Binutils package contains a linker, an assembler,
15 17
 and other tools for handling object files.
... ...
@@ -22,6 +24,8 @@ for handling compiled objects.
22 22
 %prep
23 23
 %setup -q
24 24
 %patch0 -p1
25
+%patch1 -p1
26
+%patch2 -p1
25 27
 
26 28
 %build
27 29
 install -vdm 755 ../binutils-build
... ...
@@ -112,6 +116,8 @@ make %{?_smp_mflags} check
112 112
 %{_lib64dir}/libiberty.a
113 113
 
114 114
 %changelog
115
+*   Tue Apr 17 2018 Xiaolin Li <xiaolinl@vmware.com> 2.30-4
116
+-   Fix CVE-2018-7643, CVE-2018-7208
115 117
 *   Mon Mar 19 2018 Alexey Makhalov <amakhalov@vmware.com> 2.30-3
116 118
 -   Add libiberty to the -devel package
117 119
 *   Wed Feb 28 2018 Xiaolin Li <xiaolinl@vmware.com> 2.30-2