summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Watson <davejwatson@fb.com>2018-01-17 08:04:05 -0800
committerDave Watson <davejwatson@fb.com>2018-01-17 08:16:16 -0800
commit7d6cc6696ab8a808da3dbe23ca2493ddf2799b56 (patch)
tree4e436ebc0965fec0e8b3476ec526226650cff1af
parente1ca874882d3cd2f4c16440acf30f4eef89c7959 (diff)
downloadlibunwind-7d6cc6696ab8a808da3dbe23ca2493ddf2799b56.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
-rw-r--r--src/s390x/Ginit.c4
-rw-r--r--src/x86_64/Ginit.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/src/s390x/Ginit.c b/src/s390x/Ginit.c
index 8f3e369e..f0886ac9 100644
--- a/src/s390x/Ginit.c
+++ b/src/s390x/Ginit.c
@@ -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 );
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 );