Use getauxval on Android with API level > 18
authorLars Immisch <immisch@adobe.com>
Thu, 5 Mar 2020 10:26:06 +0000 (11:26 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 15 Jun 2021 10:53:26 +0000 (12:53 +0200)
We received analytics that devices of the device family Oppo A37x
are crashing with SIGILL when trying to load libcrypto.so.
These crashes were fixed by using the system-supplied getauxval function.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11257)

crypto/armcap.c

index 43438e0aa4f2241d6b660ae0043d71481fee6d84..93aeac85a37ea6c0efd531e9adc34879d00c14be 100644 (file)
@@ -93,6 +93,15 @@ static unsigned long getauxval(unsigned long key)
 #  endif
 # endif
 
+/*
+ * Android: according to https://developer.android.com/ndk/guides/cpu-features,
+ * getauxval is supported starting with API level 18
+ */
+#  if defined(__ANDROID__) && defined(__ANDROID_API__) && __ANDROID_API__ >= 18
+#   include <sys/auxv.h>
+#   define OSSL_IMPLEMENT_GETAUXVAL
+#  endif
+
 /*
  * ARM puts the feature bits for Crypto Extensions in AT_HWCAP2, whereas
  * AArch64 used AT_HWCAP.