1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-28 10:07:37 +01:00

Use syscall directly in write_validate to avoid ASAN errors

ASAN will complain about this write call with the following error:

ERROR: AddressSanitizer: stack-buffer-underflow on address
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext

This is similar to what google's abseil does to work around the issue.

Reported-by: qiwang@fb.com
This commit is contained in:
Dave Watson 2018-01-17 08:04:05 -08:00
parent 43934dae83
commit 26718da171

View file

@ -34,6 +34,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/syscall.h>
#include "unwind_i.h" #include "unwind_i.h"
@ -107,7 +108,8 @@ write_validate (void *addr)
do do
{ {
ret = write (mem_validate_pipe[1], addr, 1); /* use syscall insteadof write() so that ASAN does not complain */
ret = syscall (SYS_write, mem_validate_pipe[1], addr, 1);
} }
while ( errno == EINTR ); while ( errno == EINTR );