diff options
author | Gregory P. Smith <greg@krypto.org> | 2021-05-05 20:55:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-05 20:55:33 (GMT) |
commit | da5c808fb50d34bc2e180d9481706072f33025da (patch) | |
tree | 305c183010edac7a9c4755288e16cc832c50d6bf | |
parent | 565a31804c1139fe7886f38af3b3923653b0c1b3 (diff) | |
download | cpython-da5c808fb50d34bc2e180d9481706072f33025da.zip cpython-da5c808fb50d34bc2e180d9481706072f33025da.tar.gz cpython-da5c808fb50d34bc2e180d9481706072f33025da.tar.bz2 |
bpo-36515: Disable unaligned memory access in _sha3 on ARM (GH-25927)
Contributed-By: Matthias Klose
Automerge-Triggered-By: GH:tiran
-rw-r--r-- | Misc/NEWS.d/next/Library/2021-05-05-11-44-49.bpo-36515.uOSa3q.rst | 2 | ||||
-rw-r--r-- | Modules/_sha3/sha3module.c | 5 |
2 files changed, 7 insertions, 0 deletions
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 0000000..dd24474 --- /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 aba7f6d..3974e0b 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 |