]> git.pld-linux.org Git - packages/openssl.git/blob - pic.patch
up to 3.3.0 (fixes CVE-2024-2511)
[packages/openssl.git] / pic.patch
1 From: Debian OpenSSL Team <pkg-openssl-devel@lists.alioth.debian.org>
2 Date: Sun, 5 Nov 2017 15:09:09 +0100
3 Subject: pic
4
5 ---
6  crypto/des/asm/desboth.pl | 17 ++++++++++++++---
7  crypto/perlasm/cbc.pl     | 24 ++++++++++++++++++++----
8  crypto/perlasm/x86gas.pl  | 16 ++++++++++++++++
9  crypto/x86cpuid.pl        | 10 +++++-----
10  4 files changed, 55 insertions(+), 12 deletions(-)
11
12 diff --git a/crypto/des/asm/desboth.pl b/crypto/des/asm/desboth.pl
13 index afffd20d84cd..b50e85ce24f8 100644
14 --- a/crypto/des/asm/desboth.pl
15 +++ b/crypto/des/asm/desboth.pl
16 @@ -23,6 +23,11 @@ sub DES_encrypt3
17  
18         &push("edi");
19  
20 +       &call   (&label("pic_point0"));
21 +       &set_label("pic_point0");
22 +       &blindpop("ebp");
23 +       &add    ("ebp", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point0") . "]");
24 +
25         &comment("");
26         &comment("Load the data words");
27         &mov($L,&DWP(0,"ebx","",0));
28 @@ -54,15 +59,21 @@ sub DES_encrypt3
29         &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
30         &mov(&swtmp(1), "eax");
31         &mov(&swtmp(0), "ebx");
32 -       &call("DES_encrypt2");
33 +       &exch("ebx", "ebp");
34 +       &call("DES_encrypt2\@PLT");
35 +       &exch("ebx", "ebp");
36         &mov(&swtmp(2), (DWC(($enc)?"0":"1")));
37         &mov(&swtmp(1), "edi");
38         &mov(&swtmp(0), "ebx");
39 -       &call("DES_encrypt2");
40 +       &exch("ebx", "ebp");
41 +       &call("DES_encrypt2\@PLT");
42 +       &exch("ebx", "ebp");
43         &mov(&swtmp(2), (DWC(($enc)?"1":"0")));
44         &mov(&swtmp(1), "esi");
45         &mov(&swtmp(0), "ebx");
46 -       &call("DES_encrypt2");
47 +       &exch("ebx", "ebp");
48 +       &call("DES_encrypt2\@PLT");
49 +       &exch("ebx", "ebp");
50  
51         &stack_pop(3);
52         &mov($L,&DWP(0,"ebx","",0));
53 diff --git a/crypto/perlasm/cbc.pl b/crypto/perlasm/cbc.pl
54 index ef09e0fd297a..fe6ff45d1804 100644
55 --- a/crypto/perlasm/cbc.pl
56 +++ b/crypto/perlasm/cbc.pl
57 @@ -129,7 +129,11 @@ sub cbc
58         &mov(&DWP($data_off,"esp","",0),        "eax"); # put in array for call
59         &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
60  
61 -       &call($enc_func);
62 +       &call   (&label("pic_point0"));
63 +       &set_label("pic_point0");
64 +       &blindpop("ebx");
65 +       &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point0") . "]");
66 +       &call("$enc_func\@PLT");
67  
68         &mov("eax",     &DWP($data_off,"esp","",0));
69         &mov("ebx",     &DWP($data_off+4,"esp","",0));
70 @@ -199,7 +203,11 @@ sub cbc
71         &mov(&DWP($data_off,"esp","",0),        "eax"); # put in array for call
72         &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
73  
74 -       &call($enc_func);
75 +       &call   (&label("pic_point1"));
76 +       &set_label("pic_point1");
77 +       &blindpop("ebx");
78 +       &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point1") . "]");
79 +       &call("$enc_func\@PLT");
80  
81         &mov("eax",     &DWP($data_off,"esp","",0));
82         &mov("ebx",     &DWP($data_off+4,"esp","",0));
83 @@ -232,7 +240,11 @@ sub cbc
84         &mov(&DWP($data_off,"esp","",0),        "eax"); # put back
85         &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
86  
87 -       &call($dec_func);
88 +       &call   (&label("pic_point2"));
89 +       &set_label("pic_point2");
90 +       &blindpop("ebx");
91 +       &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point2") . "]");
92 +       &call("$dec_func\@PLT");
93  
94         &mov("eax",     &DWP($data_off,"esp","",0));    # get return
95         &mov("ebx",     &DWP($data_off+4,"esp","",0));  #
96 @@ -275,7 +287,11 @@ sub cbc
97         &mov(&DWP($data_off,"esp","",0),        "eax"); # put back
98         &mov(&DWP($data_off+4,"esp","",0),      "ebx"); #
99  
100 -       &call($dec_func);
101 +       &call   (&label("pic_point3"));
102 +       &set_label("pic_point3");
103 +       &blindpop("ebx");
104 +       &add    ("ebx", "\$_GLOBAL_OFFSET_TABLE_+[.-" . &label("pic_point3") . "]");
105 +       &call("$dec_func\@PLT");
106  
107         &mov("eax",     &DWP($data_off,"esp","",0));    # get return
108         &mov("ebx",     &DWP($data_off+4,"esp","",0));  #
109 diff --git a/crypto/perlasm/x86gas.pl b/crypto/perlasm/x86gas.pl
110 index 1b2b27c02286..a62c01b175a2 100644
111 --- a/crypto/perlasm/x86gas.pl
112 +++ b/crypto/perlasm/x86gas.pl
113 @@ -171,6 +171,7 @@ sub ::file_end
114         if ($::macosx)  { push (@out,"$tmp,2\n"); }
115         elsif ($::elf)  { push (@out,"$tmp,4\n"); }
116         else            { push (@out,"$tmp\n"); }
117 +       if ($::elf)     { push (@out,".hidden\tOPENSSL_ia32cap_P\n"); }
118      }
119      push(@out,$initseg) if ($initseg);
120      if ($::elf) {
121 @@ -249,8 +250,23 @@ ___
122      elsif ($::elf)
123      {  $initseg.=<<___;
124  .section       .init
125 +___
126 +        if ($::pic)
127 +       {   $initseg.=<<___;
128 +       pushl   %ebx
129 +       call    .pic_point0
130 +.pic_point0:
131 +       popl    %ebx
132 +       addl    \$_GLOBAL_OFFSET_TABLE_+[.-.pic_point0],%ebx
133 +       call    $f\@PLT
134 +       popl    %ebx
135 +___
136 +       }
137 +       else
138 +       {   $initseg.=<<___;
139         call    $f
140  ___
141 +       }
142      }
143      elsif ($::coff)
144      {   $initseg.=<<___;       # applies to both Cygwin and Mingw
145 diff --git a/crypto/x86cpuid.pl b/crypto/x86cpuid.pl
146 index a7bcb27e262d..6688a1fc4464 100644
147 --- a/crypto/x86cpuid.pl
148 +++ b/crypto/x86cpuid.pl
149 @@ -16,6 +16,8 @@ $output = pop and open STDOUT,">$output";
150  
151  for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
152  
153 +push(@out, ".hidden OPENSSL_ia32cap_P\n");
154 +
155  &function_begin("OPENSSL_ia32_cpuid");
156         &xor    ("edx","edx");
157         &pushf  ();
158 @@ -161,9 +163,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
159  &set_label("nocpuid");
160  &function_end("OPENSSL_ia32_cpuid");
161  
162 -&external_label("OPENSSL_ia32cap_P");
163 -
164 -&function_begin_B("OPENSSL_rdtsc","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
165 +&function_begin_B("OPENSSL_rdtsc");
166         &xor    ("eax","eax");
167         &xor    ("edx","edx");
168         &picmeup("ecx","OPENSSL_ia32cap_P");
169 @@ -177,7 +177,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
170  # This works in Ring 0 only [read DJGPP+MS-DOS+privileged DPMI host],
171  # but it's safe to call it on any [supported] 32-bit platform...
172  # Just check for [non-]zero return value...
173 -&function_begin_B("OPENSSL_instrument_halt","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
174 +&function_begin_B("OPENSSL_instrument_halt");
175         &picmeup("ecx","OPENSSL_ia32cap_P");
176         &bt     (&DWP(0,"ecx"),4);
177         &jnc    (&label("nohalt"));     # no TSC
178 @@ -244,7 +244,7 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
179         &ret    ();
180  &function_end_B("OPENSSL_far_spin");
181  
182 -&function_begin_B("OPENSSL_wipe_cpu","EXTRN\t_OPENSSL_ia32cap_P:DWORD");
183 +&function_begin_B("OPENSSL_wipe_cpu");
184         &xor    ("eax","eax");
185         &xor    ("edx","edx");
186         &picmeup("ecx","OPENSSL_ia32cap_P");
This page took 0.06089 seconds and 3 git commands to generate.