diff options
author | Jack Lloyd <[email protected]> | 2015-12-31 11:59:27 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-12-31 11:59:27 -0500 |
commit | b269c8d1ce0cb5412712a8df963b2205364e17ae (patch) | |
tree | 8245489665f1f31c35626d4cf5275afbf0914276 /doc/news.rst | |
parent | 18d81936b55874ba76eca59b1d01e8028cc2bf9a (diff) |
Use memcpy instead of misaligned pointer casts for reading words.
It works on x86, but C says it is undefined and it makes UBSan
unhappy. Happily, this memcpy approach probably also works fine under
processors which previously used the byte-at-a-time approach such as
ARM. But for right now using memcpy here is still gated under the
processor alignment flags.
In my tests recent GCC and Clang seemed to produce basically identical
code for either approach when using -O3; I imagine most compilers
these days are very good at analyzing/inlining/unrolling memcpys.
Also remove the manually unrolled versions of xor_buf, which caused
problems with GCC and -O3 due to it vectorizing the loads into
(aligned) SSE2 loads, which would fail when a misaligned pointer was
passed. Which always seemed kind of bogus to me, but I guess that's
what undefined behavior is for. Enable -O3 for GCC.
With this change the test suite is clean under GCC ASan+UBSan and
Clang ASan+UBSan, with the exception of one failure due to a bug in
libstdc++ (GCC bug 60734) when compiled by Clang.
Diffstat (limited to 'doc/news.rst')
-rw-r--r-- | doc/news.rst | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/doc/news.rst b/doc/news.rst index 9ddca58bd..8a52f288d 100644 --- a/doc/news.rst +++ b/doc/news.rst @@ -38,6 +38,15 @@ Version 1.11.26, Not Yet Released infinite loop or the discarding of an incorrect number of bytes. Reported on mailing list by Falko Strenzke. +* Previously if BOTAN_TARGET_UNALIGNED_MEMORY_ACCESS_OK was defined, + the code doing low level loads/stores would use pointer casts to + access larger words out of a (potentially misaligned) byte array, + rather than using byte-at-a-time accesses. However even on platforms + such as x86 where this works, it triggers UBSan errors under Clang. + Instead use memcpy, which the C standard says is usable for such + purposes even with misaligned values. With recent GCC and Clang, the + same code seems to be emitted for either approach. + * Avoid calling memcpy, memset, or memmove with a length of zero to avoid undefined behavior, as calling these functions with an invalid or null pointer, even with a length of zero, is invalid. Often there |