1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-16 13:18:12 +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 e1ca874882
commit 7d6cc6696a
2 changed files with 6 additions and 2 deletions

View file

@ -35,6 +35,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include "unwind_i.h"
@ -131,7 +132,8 @@ write_validate (void *addr)
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 );

View file

@ -34,6 +34,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include "unwind_i.h"
@ -107,7 +108,8 @@ write_validate (void *addr)
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 );