boringssl/crypto
David Benjamin def85b403d Revise OPENSSL_ia32cap_P strategy to avoid TEXTRELs.
OPENSSL_ia32cap_addr avoids any relocations within the module, at the
cost of a runtime TEXTREL, which causes problems in some cases.
(Notably, if someone links us into a binary which uses the GCC "ifunc"
attribute, the loader crashes.)

We add a OPENSSL_ia32cap_addr_delta symbol (which is reachable
relocation-free from the module) stores the difference between
OPENSSL_ia32cap_P and its own address.  Next, reference
OPENSSL_ia32cap_P in code as usual, but always doing LEAQ (or the
equivalent GOTPCREL MOVQ) into a register first. This pattern we can
then transform into a LEAQ and ADDQ on OPENSSL_ia32cap_addr_delta.

ADDQ modifies the FLAGS register, so this is only a safe transformation
if we safe and restore flags first. That, in turn, is only a safe
transformation if code always uses %rsp as a stack pointer (specifically
everything below the stack must be fair game for scribbling over). Linux
delivers signals on %rsp, so this should already be an ABI requirement.
Further, we must clear the red zone (using LEAQ to avoid touching FLAGS)
which signal handlers may not scribble over.

This also fixes the GOTTPOFF logic to clear the red zone.

Change-Id: I4ca6133ab936d5a13d5c8ef265a12ab6bd0073c9
Reviewed-on: https://boringssl-review.googlesource.com/15545
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Adam Langley <agl@google.com>
CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
2017-04-27 21:07:33 +00:00
..
asn1 Fix potential memory leak in ASN1_TIME_to_generalizedtime() 2017-03-21 18:10:51 +00:00
base64 Convert base64_test to GTest. 2017-04-17 14:14:17 +00:00
bio Convert bio_test to GTest. 2017-03-21 17:39:57 +00:00
bn Don't test quite so many primes. 2017-04-27 20:30:42 +00:00
buf Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
bytestring Convert bytestring_test to GTest. 2017-04-17 14:19:47 +00:00
chacha x86_64 assembly pack: Win64 SEH face-lift. 2017-02-16 21:55:04 +00:00
cipher Remove test vectors for old ChaCha20-Poly1305 AEAD. 2017-04-24 14:43:18 +00:00
cmac Convert cmac_test to GTest. 2017-04-24 20:25:22 +00:00
conf Fix out-of-memory condition in conf. 2017-03-21 16:19:22 +00:00
curve25519 Convert spake25519_test to GTest. 2017-04-24 20:26:02 +00:00
des Fix up macros. 2016-10-18 18:28:23 +00:00
dh Remove direct calls to BN_mod_exp. 2017-02-28 18:00:02 +00:00
digest_extra First part of the FIPS module. 2017-04-07 00:05:34 +00:00
dsa Add a common TestEventListener for the error queue. 2017-02-07 21:33:22 +00:00
ec Align BN_rand_range_ex with FIPS 186-4. 2017-04-14 19:49:49 +00:00
ecdh Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
ecdsa Fix ECDSA signing for FIPS compliance. 2017-04-13 16:43:52 +00:00
engine Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
err Update BN_enhanced_miller_rabin_primality_test to enforce preconditions and accept BN_prime_checks. 2017-04-21 22:24:01 +00:00
evp Unwind multiprime RSA support. 2017-04-12 23:14:57 +00:00
fipsmodule Revise OPENSSL_ia32cap_P strategy to avoid TEXTRELs. 2017-04-27 21:07:33 +00:00
hkdf Convert hkdf_test to C++. 2017-01-04 01:40:44 +00:00
hmac_extra First part of the FIPS module. 2017-04-07 00:05:34 +00:00
lhash Remove lh_new's default hash and comparator. 2017-01-04 01:44:10 +00:00
obj Teach crypto/x509 how to verify an Ed25519 signature. 2017-04-05 23:35:30 +00:00
pem Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
perlasm Gate assembly sources on !OPENSSL_NO_ASM. 2017-03-30 19:34:21 +00:00
pkcs7 Add PKCS7_get_raw_certificates. 2017-04-19 17:30:31 +00:00
pkcs8 First part of the FIPS module. 2017-04-07 00:05:34 +00:00
poly1305 Fix Android build. 2017-04-07 17:33:24 +00:00
pool Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
rand_extra Fix fuzzer build. 2017-04-25 16:42:28 +00:00
rc4 Simplify RC4 code and remove assembly. 2016-08-30 15:32:31 +00:00
rsa Add primality checking for RSA_check_fips. 2017-04-21 22:38:31 +00:00
stack Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
test Allow embedders to replace gtest_main.cc. 2017-04-26 15:47:02 +00:00
x509 Move PKCS#7 functions into their own directory. 2017-04-19 17:24:51 +00:00
x509v3 Fix a crash in print_notice. 2017-03-21 14:50:26 +00:00
CMakeLists.txt Convert spake25519_test to GTest. 2017-04-24 20:26:02 +00:00
compiler_test.cc Fix build on android_aarch64. 2017-04-21 22:52:10 +00:00
constant_time_test.cc Switch constant-time functions to using |crypto_word_t|. 2017-04-21 22:06:05 +00:00
cpu-aarch64-linux.c Rewrite ARM feature detection. 2016-03-26 04:54:44 +00:00
cpu-arm-linux.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
cpu-arm.c Rewrite ARM feature detection. 2016-03-26 04:54:44 +00:00
cpu-intel.c Wrap MSVC-only warning pragmas in a macro. 2016-06-09 21:29:36 +00:00
cpu-ppc64le.c Make the POWER hardware capability value a global in crypto.c. 2017-04-04 18:19:19 +00:00
crypto.c Revise OPENSSL_ia32cap_P strategy to avoid TEXTRELs. 2017-04-27 21:07:33 +00:00
ex_data.c Fix CRYPTO_dup_ex_data. 2017-04-04 18:21:49 +00:00
internal.h Switch constant-time functions to using |crypto_word_t|. 2017-04-21 22:06:05 +00:00
mem.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
refcount_c11.c
refcount_lock.c Split unlock functions into read/write variants. 2016-05-31 21:09:29 +00:00
refcount_test.cc Convert constant_time_test and refcount_test to C++. 2017-01-04 01:36:49 +00:00
thread_none.c Split unlock functions into read/write variants. 2016-05-31 21:09:29 +00:00
thread_pthread.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
thread_test.c Move much of rand/ into the FIPS module. 2017-04-21 22:03:18 +00:00
thread_win.c Work around language and compiler bug in memcpy, etc. 2016-12-21 20:34:47 +00:00
thread.c Remove a bunch of unnecessary includes. 2016-06-28 20:31:14 +00:00