ASan/MSan should call __sanitizer_unaligned_{load,store}
functions when performing unaligned reads/writes (TSan already calls equivalents)
#81722
Labels
A-sanitizers
Area: Sanitizers for correctness and code quality
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
There are special functions exposed by several of the sanitizers for performing unaligned loads and stores. The functions have names like
__sanitizer_unaligned_{load,store}{16,32,64}
¹, and come with the runtimes of at least MSan/ASan/TSan, but not LSan.The documentation for them notes:
Under
-Zsanitize=thread
we end up calling functions like __tsan_unaligned_read4 which turns out to be what tsan's implementations for these do anyway: https://github.com/llvm/llvm-project/blob/350fafabe9d3bda75e80bf077303eb5a09130b53/compiler-rt/lib/tsan/rtl/tsan_interface.cppHowever, we don't do this for any other sanitizer. ASan and MSan both provide implementations of these. I don't know how beneficial this is for MSan, but for ASan at least is mentioned in the header.
Unless I'm mistaken, we should be doing this for MSan and ASan. The fact that we do it for TSan gives me hope that it can be added without too much effort. Alternatively, maybe the current behavior is intentional, and these are unneeded for our case for a reason that I'm not aware of.
For clarity, I haven't seen ASan miss issues because of this (and in truth have never gotten MSan working well), I just stumbled across it.
Anyway, Godbolt for convenience: https://rust.godbolt.org/z/Ed4arK. Change
-Zsanitize=thread
to use-Zsanitize=address
or-Zsanitize=memory
to see what I mean.¹ This is included by the (more commonly used) headers
<sanitizer/[atml]san_interface.h>
. These are definitely public even though they begin with underscores.The text was updated successfully, but these errors were encountered: