diff options
author | Dave Watson <davejwatson@fb.com> | 2018-01-17 08:04:05 -0800 |
---|---|---|
committer | Dave Watson <davejwatson@fb.com> | 2018-01-17 08:18:21 -0800 |
commit | 26718da1713a5698070e702e68db1f995baeae07 (patch) | |
tree | 3acc1c0aef8a88cecf8f39ce825e043b32952e9a /src/x86_64/Ginit.c | |
parent | 43934dae8300ef0ae270c9dac3e4209c002da8de (diff) | |
download | libunwind-26718da1713a5698070e702e68db1f995baeae07.tar.gz |
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
Diffstat (limited to 'src/x86_64/Ginit.c')
-rw-r--r-- | src/x86_64/Ginit.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/x86_64/Ginit.c b/src/x86_64/Ginit.c index 6281b767..2a84a1ee 100644 --- a/src/x86_64/Ginit.c +++ b/src/x86_64/Ginit.c @@ -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 ); |