summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormiod <>2014-04-22 21:52:21 +0000
committermiod <>2014-04-22 21:52:21 +0000
commit6e952462788feb4cbe1eb9130fc742e698bb76f0 (patch)
treeda1742df8528640216f927a9907fe4e7c55bf9ec /src
parent71b791a2ff679463d6ef915490232cfa037f02b2 (diff)
downloadopenbsd-6e952462788feb4cbe1eb9130fc742e698bb76f0.tar.gz
openbsd-6e952462788feb4cbe1eb9130fc742e698bb76f0.tar.bz2
openbsd-6e952462788feb4cbe1eb9130fc742e698bb76f0.zip
So it turns out that libcrypto on i386 platforms, unconditionaly compiles this
little gem called OPENSSL_indirect_call(), supposedly to be ``handy under Win32''. In my view, this is a free-win ROP entry point. Why try and return to libc when you can return to libcrypto with an easy to use interface? Better not give that much attack surface, and remove this undocumented entry point. ok beck@ tedu@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/x86cpuid.pl39
-rw-r--r--src/lib/libssl/src/crypto/x86cpuid.pl39
2 files changed, 0 insertions, 78 deletions
diff --git a/src/lib/libcrypto/x86cpuid.pl b/src/lib/libcrypto/x86cpuid.pl
index c7a57a3465..169036d53d 100644
--- a/src/lib/libcrypto/x86cpuid.pl
+++ b/src/lib/libcrypto/x86cpuid.pl
@@ -257,45 +257,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
257 &ret (); 257 &ret ();
258&function_end_B("OPENSSL_atomic_add"); 258&function_end_B("OPENSSL_atomic_add");
259 259
260# This function can become handy under Win32 in situations when
261# we don't know which calling convention, __stdcall or __cdecl(*),
262# indirect callee is using. In C it can be deployed as
263#
264#ifdef OPENSSL_CPUID_OBJ
265# type OPENSSL_indirect_call(void *f,...);
266# ...
267# OPENSSL_indirect_call(func,[up to $max arguments]);
268#endif
269#
270# (*) it's designed to work even for __fastcall if number of
271# arguments is 1 or 2!
272&function_begin_B("OPENSSL_indirect_call");
273 {
274 my ($max,$i)=(7,); # $max has to be chosen as 4*n-1
275 # in order to preserve eventual
276 # stack alignment
277 &push ("ebp");
278 &mov ("ebp","esp");
279 &sub ("esp",$max*4);
280 &mov ("ecx",&DWP(12,"ebp"));
281 &mov (&DWP(0,"esp"),"ecx");
282 &mov ("edx",&DWP(16,"ebp"));
283 &mov (&DWP(4,"esp"),"edx");
284 for($i=2;$i<$max;$i++)
285 {
286 # Some copies will be redundant/bogus...
287 &mov ("eax",&DWP(12+$i*4,"ebp"));
288 &mov (&DWP(0+$i*4,"esp"),"eax");
289 }
290 &call_ptr (&DWP(8,"ebp"));# make the call...
291 &mov ("esp","ebp"); # ... and just restore the stack pointer
292 # without paying attention to what we called,
293 # (__cdecl *func) or (__stdcall *one).
294 &pop ("ebp");
295 &ret ();
296 }
297&function_end_B("OPENSSL_indirect_call");
298
299&function_begin_B("OPENSSL_ia32_rdrand"); 260&function_begin_B("OPENSSL_ia32_rdrand");
300 &mov ("ecx",8); 261 &mov ("ecx",8);
301&set_label("loop"); 262&set_label("loop");
diff --git a/src/lib/libssl/src/crypto/x86cpuid.pl b/src/lib/libssl/src/crypto/x86cpuid.pl
index c7a57a3465..169036d53d 100644
--- a/src/lib/libssl/src/crypto/x86cpuid.pl
+++ b/src/lib/libssl/src/crypto/x86cpuid.pl
@@ -257,45 +257,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
257 &ret (); 257 &ret ();
258&function_end_B("OPENSSL_atomic_add"); 258&function_end_B("OPENSSL_atomic_add");
259 259
260# This function can become handy under Win32 in situations when
261# we don't know which calling convention, __stdcall or __cdecl(*),
262# indirect callee is using. In C it can be deployed as
263#
264#ifdef OPENSSL_CPUID_OBJ
265# type OPENSSL_indirect_call(void *f,...);
266# ...
267# OPENSSL_indirect_call(func,[up to $max arguments]);
268#endif
269#
270# (*) it's designed to work even for __fastcall if number of
271# arguments is 1 or 2!
272&function_begin_B("OPENSSL_indirect_call");
273 {
274 my ($max,$i)=(7,); # $max has to be chosen as 4*n-1
275 # in order to preserve eventual
276 # stack alignment
277 &push ("ebp");
278 &mov ("ebp","esp");
279 &sub ("esp",$max*4);
280 &mov ("ecx",&DWP(12,"ebp"));
281 &mov (&DWP(0,"esp"),"ecx");
282 &mov ("edx",&DWP(16,"ebp"));
283 &mov (&DWP(4,"esp"),"edx");
284 for($i=2;$i<$max;$i++)
285 {
286 # Some copies will be redundant/bogus...
287 &mov ("eax",&DWP(12+$i*4,"ebp"));
288 &mov (&DWP(0+$i*4,"esp"),"eax");
289 }
290 &call_ptr (&DWP(8,"ebp"));# make the call...
291 &mov ("esp","ebp"); # ... and just restore the stack pointer
292 # without paying attention to what we called,
293 # (__cdecl *func) or (__stdcall *one).
294 &pop ("ebp");
295 &ret ();
296 }
297&function_end_B("OPENSSL_indirect_call");
298
299&function_begin_B("OPENSSL_ia32_rdrand"); 260&function_begin_B("OPENSSL_ia32_rdrand");
300 &mov ("ecx",8); 261 &mov ("ecx",8);
301&set_label("loop"); 262&set_label("loop");