[Python-checkins] [3.9] bpo-36515: Disable unaligned memory access in _sha3 on ARM (GH-25927) (GH-25928)

tiran webhook-mailer at python.org
Thu May 6 02:56:04 EDT 2021


https://github.com/python/cpython/commit/ce47addfb6f176fad053431b537b77a5f170765e
commit: ce47addfb6f176fad053431b537b77a5f170765e
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: tiran <christian at python.org>
date: 2021-05-06T08:55:35+02:00
summary:

[3.9] bpo-36515: Disable unaligned memory access in _sha3 on ARM (GH-25927) (GH-25928)

Contributed-By: Matthias Klose

Automerge-Triggered-By: GH:tiran
(cherry picked from commit da5c808fb50d34bc2e180d9481706072f33025da)

Co-authored-by: Gregory P. Smith <greg at krypto.org>

Co-authored-by: Gregory P. Smith <greg at krypto.org>

files:
A Misc/NEWS.d/next/Library/2021-05-05-11-44-49.bpo-36515.uOSa3q.rst
M Modules/_sha3/sha3module.c

diff --git a/Misc/NEWS.d/next/Library/2021-05-05-11-44-49.bpo-36515.uOSa3q.rst b/Misc/NEWS.d/next/Library/2021-05-05-11-44-49.bpo-36515.uOSa3q.rst
new file mode 100644
index 00000000000000..dd24474c2fde7e
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-05-05-11-44-49.bpo-36515.uOSa3q.rst
@@ -0,0 +1,2 @@
+The :mod:`hashlib` module no longer does unaligned memory accesses when
+compiled for ARM platforms.
diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c
index c826b42df13f92..b6a7130dd86974 100644
--- a/Modules/_sha3/sha3module.c
+++ b/Modules/_sha3/sha3module.c
@@ -64,6 +64,11 @@
 #define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN
 #endif
 
+/* Prevent bus errors on platforms requiring aligned accesses such ARM. */
+#if HAVE_ALIGNED_REQUIRED && !defined(NO_MISALIGNED_ACCESSES)
+#define NO_MISALIGNED_ACCESSES
+#endif
+
 /* mangle names */
 #define KeccakF1600_FastLoop_Absorb _PySHA3_KeccakF1600_FastLoop_Absorb
 #define Keccak_HashFinal _PySHA3_Keccak_HashFinal



More information about the Python-checkins mailing list