summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYawning Angel <yawning@schwanenlied.me>2015-07-27 00:49:11 +0000
committerYawning Angel <yawning@schwanenlied.me>2015-07-27 00:49:11 +0000
commitc0106118fadb35e22fdbb038c3dfac2a89f816de (patch)
treee7f0cf4fe1702f7278a8e4784db68c67e523d2d7
parent5be36a46cab7626c52e0c50e55ca73703698e399 (diff)
downloadtor-c0106118fadb35e22fdbb038c3dfac2a89f816de.tar.gz
tor-c0106118fadb35e22fdbb038c3dfac2a89f816de.zip
Fix ed25519-donna with SSP on non-x86.
The only reason 16 byte alignment is required is for SSE2 load and store operations, so only align datastructures to 16 byte boundaries when building with SSE2 support. This fixes builds with GCC SSP on platforms that don't have special case code to do dynamic stack re-alignment (everything not x86/x86_64). Fixes bug #16666.
-rw-r--r--src/ext/ed25519/donna/README.tor3
-rw-r--r--src/ext/ed25519/donna/ed25519-donna-portable.h14
2 files changed, 17 insertions, 0 deletions
diff --git a/src/ext/ed25519/donna/README.tor b/src/ext/ed25519/donna/README.tor
index 212fb119a2..2bb0efc012 100644
--- a/src/ext/ed25519/donna/README.tor
+++ b/src/ext/ed25519/donna/README.tor
@@ -37,3 +37,6 @@ as of 8757bd4cd209cb032853ece0ce413f122eef212c.
since the compilation will fail in `ge25519_scalarmult_base_choose_niels`
on x86_64 targets due to running out of registers.
+ * On non-x86 targets, GCC's Stack Protector dislikes variables that have
+ alignment constraints greater than that of other primitive types.
+ The `ALIGN` macro is thus no-oped for all non-SSE2 builds.
diff --git a/src/ext/ed25519/donna/ed25519-donna-portable.h b/src/ext/ed25519/donna/ed25519-donna-portable.h
index 44fa8407e2..9ec83b87e3 100644
--- a/src/ext/ed25519/donna/ed25519-donna-portable.h
+++ b/src/ext/ed25519/donna/ed25519-donna-portable.h
@@ -144,6 +144,20 @@ static inline void U64TO8_LE(unsigned char *p, const uint64_t v) {
#endif
#endif
+/* Tor: GCC's Stack Protector freaks out and produces variable length
+ * buffer warnings when alignment is requested that is greater than
+ * STACK_BOUNDARY (x86 has special code to deal with this for SSE2).
+ *
+ * Since the only reason things are 16 byte aligned in the first place
+ * is for SSE2, only request variable alignment for SSE2 builds.
+ *
+ * See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59674
+ */
+#if !defined(ED25519_SSE2)
+ #undef ALIGN
+ #define ALIGN(x)
+#endif
+
#include <stdlib.h>
#include <string.h>