Various ASan interceptors may corrupt memory if passed a
pointer to freed memory (https://github.com/google/sanitizers/issues/321).
This patch fixes the issue for the backtrace interceptor,
by calling REAL(backtrace) with a known-good scratch buffer,
and performing an addressability check on the user-provided
buffer prior to writing to it.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc | ||
---|---|---|
4408 | That would be a stricter check than currently done, because it would have to performed with 'size' rather than 'res'. For example, if the user calls backtrace with a buffer of 100 elements but a size parameter of 1000000, COMMON_INTERCEPTOR_WRITE_RANGE before REAL would complain because the buffer is not large enough. However, if the REAL(backtrace) function only ends up returning 50 items, then the buffer is large enough in practice, and it doesn't really matter that the size parameter was too large. The current implementation only checks that the buffer was large enough for the actual number of items written by REAL(backtrace). | |
4414 | Will do. |
why we can't check with COMMON_INTERCEPTOR_WRITE_RANGE before real and after?
before for asan, after for msan