Browse code

gcc : Fix CVE-2017-11671.

Change-Id: Id59269a6eb53cc57155ab10b00a69f9238477c1c
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4079
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
Reviewed-by: Bo Gan <ganb@vmware.com>

xiaolin-vmware authored on 2017/10/20 06:01:24
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,69 @@
0
+Index: config/i386/i386.c
1
+===================================================================
2
+--- a/gcc/config/i386/i386.c	(revision 246473)
3
+@@ -37572,9 +37572,6 @@ ix86_expand_builtin (tree exp, rtx target, rtx sub
4
+       mode0 = DImode;
5
+ 
6
+ rdrand_step:
7
+-      op0 = gen_reg_rtx (mode0);
8
+-      emit_insn (GEN_FCN (icode) (op0));
9
+-
10
+       arg0 = CALL_EXPR_ARG (exp, 0);
11
+       op1 = expand_normal (arg0);
12
+       if (!address_operand (op1, VOIDmode))
13
+@@ -37582,6 +37579,10 @@ rdrand_step:
14
+ 	  op1 = convert_memory_address (Pmode, op1);
15
+ 	  op1 = copy_addr_to_reg (op1);
16
+ 	}
17
++
18
++      op0 = gen_reg_rtx (mode0);
19
++      emit_insn (GEN_FCN (icode) (op0));
20
++
21
+       emit_move_insn (gen_rtx_MEM (mode0, op1), op0);
22
+ 
23
+       op1 = gen_reg_rtx (SImode);
24
+@@ -37590,8 +37591,20 @@ rdrand_step:
25
+       /* Emit SImode conditional move.  */
26
+       if (mode0 == HImode)
27
+ 	{
28
+-	  op2 = gen_reg_rtx (SImode);
29
+-	  emit_insn (gen_zero_extendhisi2 (op2, op0));
30
++	  if (TARGET_ZERO_EXTEND_WITH_AND
31
++	      && optimize_function_for_speed_p (cfun))
32
++	    {
33
++	      op2 = force_reg (SImode, const0_rtx);
34
++
35
++	      emit_insn (gen_movstricthi
36
++			 (gen_lowpart (HImode, op2), op0));
37
++	    }
38
++	  else
39
++	    {
40
++	      op2 = gen_reg_rtx (SImode);
41
++
42
++	      emit_insn (gen_zero_extendhisi2 (op2, op0));
43
++	    }
44
+ 	}
45
+       else if (mode0 == SImode)
46
+ 	op2 = op0;
47
+@@ -37623,9 +37636,6 @@ rdrand_step:
48
+       mode0 = DImode;
49
+ 
50
+ rdseed_step:
51
+-      op0 = gen_reg_rtx (mode0);
52
+-      emit_insn (GEN_FCN (icode) (op0));
53
+-
54
+       arg0 = CALL_EXPR_ARG (exp, 0);
55
+       op1 = expand_normal (arg0);
56
+       if (!address_operand (op1, VOIDmode))
57
+@@ -37633,6 +37643,10 @@ rdseed_step:
58
+ 	  op1 = convert_memory_address (Pmode, op1);
59
+ 	  op1 = copy_addr_to_reg (op1);
60
+ 	}
61
++
62
++      op0 = gen_reg_rtx (mode0);
63
++      emit_insn (GEN_FCN (icode) (op0));
64
++
65
+       emit_move_insn (gen_rtx_MEM (mode0, op1), op0);
66
+ 
67
+       op2 = gen_reg_rtx (QImode);
... ...
@@ -1,27 +1,29 @@
1 1
 %define _use_internal_dependency_generator 0
2
-Summary:	Contains the GNU compiler collection
3
-Name:		gcc
4
-Version:	5.3.0
5
-Release:	4%{?dist}
6
-License:	GPLv2+
7
-URL:		http://gcc.gnu.org
8
-Group:		Development/Tools
9
-Vendor:		VMware, Inc.
10
-Distribution:	Photon
11
-Source0:	http://ftp.gnu.org/gnu/gcc/%{name}-%{version}/%{name}-%{version}.tar.bz2
12
-%define sha1 gcc=0612270b103941da08376df4d0ef4e5662a2e9eb
13
-Requires:	libstdc++-devel = %{version}-%{release}
14
-Requires:	libgcc-devel = %{version}-%{release}
15
-Requires:	libgomp-devel = %{version}-%{release}
16
-Requires:	libgcc-atomic = %{version}-%{release}
17
-Requires:	gmp
2
+Summary:        Contains the GNU compiler collection
3
+Name:           gcc
4
+Version:        5.3.0
5
+Release:        5%{?dist}
6
+License:        GPLv2+
7
+URL:            http://gcc.gnu.org
8
+Group:          Development/Tools
9
+Vendor:         VMware, Inc.
10
+Distribution:   Photon
11
+Source0:        http://ftp.gnu.org/gnu/gcc/%{name}-%{version}/%{name}-%{version}.tar.bz2
12
+%define sha1    gcc=0612270b103941da08376df4d0ef4e5662a2e9eb
13
+#https://gcc.gnu.org/ml/gcc-patches/2017-03/msg01349.html
14
+Patch0:         gcc-CVE-2017-11671.patch
15
+Requires:       libstdc++-devel = %{version}-%{release}
16
+Requires:       libgcc-devel = %{version}-%{release}
17
+Requires:       libgomp-devel = %{version}-%{release}
18
+Requires:       libgcc-atomic = %{version}-%{release}
19
+Requires:       gmp
18 20
 %description
19 21
 The GCC package contains the GNU compiler collection,
20 22
 which includes the C and C++ compilers.
21 23
 
22
-%package -n	libgcc
23
-Summary:	GNU C Library
24
-Group:         	System Environment/Libraries
24
+%package -n     libgcc
25
+Summary:        GNU C Library
26
+Group:          System Environment/Libraries
25 27
 %description -n libgcc
26 28
 The libgcc package contains GCC shared libraries for gcc .
27 29
 
... ...
@@ -32,36 +34,36 @@ Requires:       libgcc = %{version}-%{release}
32 32
 %description -n libgcc-atomic
33 33
 The libgcc package contains GCC shared libraries for atomic counter updates.
34 34
 
35
-%package -n	libgcc-devel
36
-Summary:	GNU C Library
37
-Group:         	Development/Libraries
35
+%package -n     libgcc-devel
36
+Summary:        GNU C Library
37
+Group:          Development/Libraries
38 38
 Requires:       libgcc = %{version}-%{release}
39 39
 %description -n libgcc-devel
40 40
 The libgcc package contains GCC shared libraries for gcc .
41 41
 This package contains development headers and static library for libgcc.
42 42
 
43
-%package -n	libstdc++
44
-Summary:       	GNU C Library
45
-Group:         	System Environment/Libraries
46
-Requires:	libgcc = %{version}-%{release}
43
+%package -n libstdc++
44
+Summary:        GNU C Library
45
+Group:          System Environment/Libraries
46
+Requires:   libgcc = %{version}-%{release}
47 47
 %description -n libstdc++
48 48
 This package contains the GCC Standard C++ Library v3, an ongoing project to implement the ISO/IEC 14882:1998 Standard C++ library.
49 49
 
50
-%package -n	libstdc++-devel
51
-Summary:       	GNU C Library
52
-Group:         	Development/Libraries
50
+%package -n libstdc++-devel
51
+Summary:        GNU C Library
52
+Group:          Development/Libraries
53 53
 Requires:       libstdc++ = %{version}-%{release}
54 54
 %description -n libstdc++-devel
55 55
 This is the GNU implementation of the standard C++ libraries.
56 56
 This package includes the headers files and libraries needed for C++ development.
57 57
 
58
-%package -n	libgomp
59
-Summary:       	GNU C Library
60
-Group:         	System Environment/Libraries
58
+%package -n libgomp
59
+Summary:        GNU C Library
60
+Group:          System Environment/Libraries
61 61
 %description -n libgomp
62 62
 An implementation of OpenMP for the C, C++, and Fortran 95 compilers in the GNU Compiler Collection.
63 63
 
64
-%package -n	libgomp-devel
64
+%package -n libgomp-devel
65 65
 Summary:        Development headers and static library for libgomp
66 66
 Group:          Development/Libraries
67 67
 Requires:       libgomp = %{version}-%{release}
... ...
@@ -71,6 +73,7 @@ This package contains development headers and static library for libgomp
71 71
 
72 72
 %prep
73 73
 %setup -q
74
+%patch0 -p1
74 75
 sed -i '/*cpp:/s/^/# /' `dirname $(gcc --print-libgcc-file-name)`/../specs
75 76
 sed -i '/Ofast:-D_FORTIFY_SOURCE=2/s/^/# /' `dirname $(gcc --print-libgcc-file-name)`/../specs
76 77
 
... ...
@@ -79,16 +82,16 @@ install -vdm 755 ../gcc-build
79 79
 cd ../gcc-build
80 80
 SED=sed \
81 81
 ../%{name}-%{version}/configure \
82
-	--prefix=%{_prefix} \
83
-	--enable-shared \
84
-	--enable-threads=posix \
85
-	--enable-__cxa_atexit \
86
-	--enable-clocale=gnu \
87
-	--enable-languages=c,c++ \
88
-	--disable-multilib \
89
-	--disable-bootstrap \
90
-	--with-system-zlib
91
-#	--disable-silent-rules
82
+    --prefix=%{_prefix} \
83
+    --enable-shared \
84
+    --enable-threads=posix \
85
+    --enable-__cxa_atexit \
86
+    --enable-clocale=gnu \
87
+    --enable-languages=c,c++ \
88
+    --disable-multilib \
89
+    --disable-bootstrap \
90
+    --with-system-zlib
91
+#   --disable-silent-rules
92 92
 #sed -i '/-D_FORTIFY_SOURCE=2 for preprocessor/,+2d' `dirname $(gcc --print-libgcc-file-name)`/../specs
93 93
 make
94 94
 %install
... ...
@@ -99,9 +102,9 @@ ln -sv %{_bindir}/cpp %{buildroot}/%{_lib}
99 99
 ln -sv gcc %{buildroot}%{_bindir}/cc
100 100
 install -vdm 755 %{buildroot}%{_datarootdir}/gdb/auto-load%{_lib}
101 101
 %ifarch x86_64
102
-	mv -v %{buildroot}%{_lib64dir}/*gdb.py %{buildroot}%{_datarootdir}/gdb/auto-load%{_lib}
102
+    mv -v %{buildroot}%{_lib64dir}/*gdb.py %{buildroot}%{_datarootdir}/gdb/auto-load%{_lib}
103 103
 %else
104
-	mv -v %{buildroot}%{_libdir}/*gdb.py %{buildroot}%{_datarootdir}/gdb/auto-load%{_lib}
104
+    mv -v %{buildroot}%{_libdir}/*gdb.py %{buildroot}%{_datarootdir}/gdb/auto-load%{_lib}
105 105
 %endif
106 106
 rm -rf %{buildroot}%{_infodir}
107 107
 popd
... ...
@@ -111,22 +114,22 @@ popd
111 111
 cd ../gcc-build
112 112
 ulimit -s 32768
113 113
 make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
114
-%post	-p /sbin/ldconfig
115
-%postun	-p /sbin/ldconfig
114
+%post   -p /sbin/ldconfig
115
+%postun -p /sbin/ldconfig
116 116
 
117 117
 %files -f %{name}.lang
118 118
 %defattr(-,root,root)
119 119
 %{_lib}/cpp
120
-#	Executables
120
+#   Executables
121 121
 %{_bindir}/*
122
-#	Libraries
122
+#   Libraries
123 123
 %ifarch x86_64
124 124
 %{_lib64dir}/*
125 125
 %endif
126 126
 %{_libdir}/gcc/*
127
-#	Library executables
127
+#   Library executables
128 128
 %{_libexecdir}/gcc/*
129
-#	Man pages
129
+#   Man pages
130 130
 %{_mandir}/man1/*.gz
131 131
 %{_mandir}/man7/*.gz
132 132
 %{_datadir}/gdb/*
... ...
@@ -211,6 +214,8 @@ make -k check |& tee %{_specdir}/%{name}-check-log || %{nocheck}
211 211
 %endif
212 212
 
213 213
 %changelog
214
+*   Thu Oct 19 2017 Xiaolin Li <xiaolinl@vmware.com> 5.3.0-5
215
+-   Fix CVE-2017-11671.
214 216
 *   Thu Jun 29 2017 Divya Thaluru <dthaluru@vmware.com> 5.3.0-4
215 217
 -   Bump release to built with latest toolchain
216 218
 *   Tue May 24 2016 Priyesh Padmavilasom <ppadmavilasom@vmware.com> 5.3.0-3