summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_platform_interceptors.h
AgeCommit message (Collapse)Author
2017-10-09[sanitizer] Don't intercept signal and sigaction on FuchsiaPetr Hosek
Fuchsia doesn't support signals, so don't use interceptors for signal or sigaction. Differential Revision: https://reviews.llvm.org/D38669 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@315227 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-18[sanitizer] Use SI_ instead of SANITIZER_ in sanitizer_platform_interceptorsVitaly Buka
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313505 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-16[sanitizer] Move signal interceptors from asan to sanitizer_commonVitaly Buka
Summary: Part of https://github.com/google/sanitizers/issues/637 Reviewers: eugenis, alekseyshl Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D37889 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313449 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-28Add NetBSD specific version of sanitizer_platform_limits_posixKamil Rytarowski
Summary: NetBSD is an Open-Source POSIX-like BSD Operating System. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, kcc, vitalybuka, filcab, fjricci Reviewed By: kcc Subscribers: llvm-commits, kubamracek, mgorny, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D37193 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@311933 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-01[sanitizer_common] Fuchsia support for interceptorsVitaly Buka
Summary: Actually Fuchsia non-support for interceptors. Fuchsia doesn't use interceptors in the common sense at all. Almost all system library functions don't need interception at all, because the system libraries are just themselves compiled with sanitizers enabled and have specific hook interfaces where needed to inform the sanitizer runtime about thread lifetimes and the like. For the few functions that do get intercepted, they don't use a generic mechanism like dlsym with RTLD_NEXT to find the underlying system library function. Instead, they use specific extra symbol names published by the system library (e.g. __unsanitized_memcpy). Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc, filcab Reviewed By: filcab Subscribers: kubamracek, phosek, filcab, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36028 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309745 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-31[sanitizer_common] Rename SI_NOT_WINDOWS to SI_POSIXVitaly Buka
Summary: New systems might be neither Windows nor POSIX. The SI_NOT_WINDOWS macro in sanitizer_platform_interceptors.h was already effectively the same as SI_POSIX, so just use SI_POSIX instead. Submitted on behalf of Roland McGrath. Reviewers: vitalybuka, alekseyshl, kcc Reviewed By: vitalybuka Subscribers: phosek, filcab, llvm-commits, kubamracek Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D36038 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@309536 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17[sanitizers] Make sure that all complex macros uses parenthesisVitaly Buka
Summary: Without them expressions like this may have different values. (SANITIZER_INTERCEPT_MEMRCHR && SANITIZER_INTERCEPT_PREADV) Reviewers: alekseyshl Subscribers: srhines, kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D35512 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308228 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-17Add NetBSD support in platform_interceptors.hKamil Rytarowski
Summary: Introduce SI_NETBSD for NetBSD. Add NetBSD support for appropriate `SANITIZER_INTERCEPT_*`. Part of the code inspired by the original work on libsanitizer in GCC 5.4 by Christos Zoulas. Sponsored by <The NetBSD Foundation> Reviewers: joerg, dim, kcc, alekseyshl, filcab, eugenis, vitalybuka Reviewed By: vitalybuka Subscribers: srhines, kubamracek, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D35468 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308217 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-29Fix WinASan after moving wcslen interceptor to sanitizer_commonReid Kleckner
Do this by removing SANITIZER_INTERCEPT_WCSLEN and intercept wcslen everywhere. Before this change, we were already intercepting wcslen on Windows, but the interceptor was in asan, not sanitizer_common. After this change, we stopped intercepting wcslen on Windows, which broke asan_dll_thunk.c, which attempts to thunk to __asan_wcslen in the ASan runtime. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306706 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-27[msan] Intercept wcscat, wcsncat.Evgeniy Stepanov
Also move wcslen, wscnlen to common interceptors. Reviewers: vitalybuka Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D34656 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@306482 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01[asan] Add strndup/__strndup interceptors.Pierre Gousseau
Recommit of r302781 with Vitaly Buka's fix for non zero terminated strings. Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@304399 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18Revert r302781 and subsequent attempts to disable part of it.Daniel Jasper
The Msan unit tests are still broken and by this point, I think we should start over. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@303339 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18temporary disable stndup interceptor, due to r302781 being buggyKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@303324 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-11[asan] Recommit of r301904: Add strndup/__strndup interceptorsPierre Gousseau
Fix undeclared __interceptor_malloc in esan_interceptors.cc Fix undeclared strnlen on OSX Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302781 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03[sanitizer] Intercept mcheck and mprobe on LinuxMaxim Ostapenko
This patch addresses https://github.com/google/sanitizers/issues/804. Users can use mcheck and mprobe functions to verify heap state so we should intercept them to avoid breakage of valid code. Differential Revision: https://reviews.llvm.org/D32589 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@302001 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02Revert r301904 causing tsan test failure in x86_64-linux-autoconfPierre Gousseau
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301909 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-02[asan] Add strndup/__strndup interceptors if targeting linux.Pierre Gousseau
Differential Revision: https://reviews.llvm.org/D31457 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@301904 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30[sanitizer] Move fread and fwrite interceptors to sanitizer_commonMaxim Ostapenko
{M, T, E}San have fread and fwrite interceptors, let's move them to sanitizer_common to enable ASan checks as well. Differential Revision: https://reviews.llvm.org/D31456 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@299061 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23[asan] Add an interceptor for strtokAlex Shlyapnikov
Summary: This change addresses https://github.com/google/sanitizers/issues/766. I tested the change with make check-asan and the newly added test case. Reviewers: ygribov, kcc, alekseyshl Subscribers: kubamracek, llvm-commits Patch by mrigger Differential Revision: https://reviews.llvm.org/D30384 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@298650 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-16[msan] Intercept getloadavg.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@297923 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-13Disable darwin interception of non-darwin functionsFrancis Ricci
Summary: Fixes build issues when compiling lsan for darwin. Reviewers: kubamracek, kcc, rnk Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D29785 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@294984 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-08[sanitizer] Add weak hooks for Windows.Marcos Pividori
Add support for weak hooks on Windows, as we do on Linux and Darwin. As we use the macro: `SANITIZER_INTERFACE_WEAK_DEF()` it was not necessary to modify the header file: `sanitizer_common_interceptors.h`. After this diff, many tests were fixed for libFuzzer. Differential Revision: https://reviews.llvm.org/D29562 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@294409 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-03[sanitizer] Fix 'dyld: Symbol not found: _memmem' linkage error on Darwin 10.6Maxim Ostapenko
This patch tries to fixes sanitizer linkage errors on Darwin 10.6 originally reporded in GCC's pr78663 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78663). Differential Revision: https://reviews.llvm.org/D29287 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293992 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-01[sanitizer] Support SANITIZER_INTERCEPTOR_HOOKS on DarwinJustin Bogner
This basically already worked other than weak symbols needing definitions on darwin. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293741 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-30Recommit: Stop intercepting some malloc-related functions on FreeBSD andDimitry Andric
macOS Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Also delete the non-functional `cfree` wrapper for Windows, to fix the test cases on that platform. Reviewers: emaste, kcc, rnk Subscribers: timurrrr, eugenis, hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293536 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-27Revert "Stop intercepting some malloc-related functions on FreeBSD and macOS"Evgeniy Stepanov
This reverts r293337, which breaks tests on Windows: malloc-no-intercept-499eb7.o : error LNK2019: unresolved external symbol _mallinfo referenced in function _main git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293346 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-27Stop intercepting some malloc-related functions on FreeBSD and macOSDimitry Andric
Summary: In https://bugs.freebsd.org/215125 I was notified that some configure scripts attempt to test for the Linux-specific `mallinfo` and `mallopt` functions by compiling and linking small programs which references the functions, and observing whether that results in errors. FreeBSD and macOS do not have the `mallinfo` and `mallopt` functions, so normally these tests would fail, but when sanitizers are enabled, they incorrectly succeed, because the sanitizers define interceptors for these functions. This also applies to some other malloc-related functions, such as `memalign`, `pvalloc` and `cfree`. Fix this by not intercepting `mallinfo`, `mallopt`, `memalign`, `pvalloc` and `cfree` for FreeBSD and macOS, in all sanitizers. Reviewers: emaste, kcc Subscribers: hans, joerg, llvm-commits, kubamracek Differential Revision: https://reviews.llvm.org/D27654 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@293337 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-20Fix build breakage on FreeBSD after rL289878/rL289881Dimitry Andric
Summary: After rL289878/rL289881, the build on FreeBSD is broken, because sanitizer_platform_limits_posix.cc attempts to include <utmp.h> and use `struct utmp`, neither of which are supported anymore on FreeBSD. Fix this by adding `&& !SANITIZER_FREEBSD` in a few places, and stop intercepting utmp functions altogether for FreeBSD. Reviewers: kubabrecka, emaste, eugenis, ed Subscribers: ed, llvm-commits Differential Revision: https://reviews.llvm.org/D27902 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@290167 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15Ifdef out utmp.h on Darwin to un-break the build after r289878 ([msan] ↵Kuba Mracek
Intercept getutent and friends). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289881 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15[msan] Intercept getutent and friends.Evgeniy Stepanov
Differential Revision: https://reviews.llvm.org/D27791 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289878 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15Revert r289690 "[sanitizer] intercept bstring functions, patch by Kuang-che ↵Hans Wennborg
Wu (https://reviews.llvm.org/D27659)" It breaks programs on Mac. See comments on the code review for details. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289864 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-14[sanitizer] intercept bstring functions, patch by Kuang-che Wu ↵Kostya Serebryany
(https://reviews.llvm.org/D27659) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@289690 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-09[sanitizer] Add interceptor for ttyname_rKeno Fischer
Reviewers: eugenis Subscribers: kubabrecka, llvm-commits Differential Revision: https://reviews.llvm.org/D24375 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@281116 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-21[compiler-rt] Fix interception of memcpy/memmove on win64Etienne Bergeron
Summary: This patch is fixing running interception unittests for memcpy/memmove on windows 64. Reviewers: rnk Subscribers: llvm-commits, wang0109, kubabrecka, chrisha Differential Revision: https://reviews.llvm.org/D22641 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276324 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15[asan] trying to fix the windows build Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275644 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15[sanitizers] add interceptor for memmem; add weak hooks for strncasecmp, ↵Kostya Serebryany
strcasecmp, strstr, strcasestr, memmem git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14[asan] Avoid hooking memchr() on Windows64Etienne Bergeron
There is not enough padding in front of memchr(), and, the first 6 bytes contains a branch instruction. Basically the current interception will not work on memchr(). It was disabled before, but was missing the part to disable it for INTERCEPT_LIBRARY_FUNCTION. Patch by Wei Wang Differential Revision: https://reviews.llvm.org/D22371 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275494 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24[msan] Intercept eventfd_read, eventfd_write.Evgeniy Stepanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@273748 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-17[msan] Intercept send/sendto/sendmsg.Evgeniy Stepanov
send/sendmsg moved from tsan to sanitizer_common; sendto is new. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@272980 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-06This patch attempts to primitive support for Win64 asanEtienne Bergeron
Some known issues are: When "head" include instructions that involve branching, the "cut and paste" approach may break down in a way that function interception still work but calling back the original function does not work. The jmp [rip -8] saves some bytes in the "head" but finding the safe zone of 0xCC is not implemented yet. So it may stomp on preceding codes. The shadow offset is not working yet on Win64. More complexity maybe involved since there are some differences regarding virtual address space between Window 8 and Windows 8.1/10. Patch by: Wang Wei Differential Revision: http://reviews.llvm.org/D20884 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@271915 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19Revert "[sanitizer] Move *fstat to the common interceptors"Benjamin Kramer
This reverts commit r269981. Breaks msan tests on linux http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24019/steps/test%20standalone%20compiler-rt/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@270076 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18[sanitizer] Move *fstat to the common interceptorsMike Aizatsky
Summary: Adds *fstat to the common interceptors. Removes the now-duplicate fstat interceptor from msan/tsan This adds fstat to asan/esan, which previously did not intercept it. Resubmit of http://reviews.llvm.org/D20318 with ios build fixes. Reviewers: eugenis, vitalybuka, aizatsky Subscribers: zaks.anna, kcc, bruening, kubabrecka, srhines, danalbert, tberghammer Differential Revision: http://reviews.llvm.org/D20350 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269981 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-18[sanitizer] Allow dlopen/dlclose interception to be disabled from cmakeFrancis Ricci
Summary: dlopen and dlclose interception are broken when RUNPATH is used: https://llvm.org/bugs/show_bug.cgi?id=27790 Reviewers: kutuzov.viktor.84, samsonov, dvyukov, eugenis, kcc Subscribers: kcc, filcab, kubabrecka, compnerd, llvm-commits Differential Revision: http://reviews.llvm.org/D20333 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269947 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17Revert "[sanitizer] Move *fstat to the common interceptors"Mike Aizatsky
This reverts commit http://reviews.llvm.org/rL269856 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269863 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-17[sanitizer] Move *fstat to the common interceptorsMike Aizatsky
Summary: Adds *fstat to the common interceptors. Removes the now-duplicate fstat interceptor from msan/tsan This adds fstat to asan/esan, which previously did not intercept it. Reviewers: eugenis, vitalybuka, aizatsky Subscribers: tberghammer, danalbert, srhines, kubabrecka, bruening, kcc Differential Revision: http://reviews.llvm.org/D20318 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269856 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-11[sanitizer] Move *stat to the common interceptorsEvgeniy Stepanov
Adds *stat to the common interceptors. Removes the now-duplicate *stat interceptor from msan/tsan/esan. This adds *stat to asan, which previously did not intercept it. Patch by Qin Zhao. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269223 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03[sanitizer] Move stat/__xstat to the common interceptorsMike Aizatsky
Summary: Adds stat/__xstat to the common interceptors. Removes the now-duplicate stat/__xstat interceptor from msan/tsan/esan. This adds stat/__xstat to asan, which previously did not intercept it. Resubmit of http://reviews.llvm.org/D19875 with win build fixes. Reviewers: aizatsky, eugenis Subscribers: tberghammer, llvm-commits, danalbert, vitalybuka, bruening, srhines, kubabrecka, kcc Differential Revision: http://reviews.llvm.org/D19890 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268466 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03Revert "[sanitizer] Move stat/__xstat to the common interceptors"Mike Aizatsky
This reverts commit 268440 because it breaks the windows bot. http://lab.llvm.org:8011/builders/sanitizer-windows/builds/21425/steps/build%20compiler-rt/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268448 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-03[sanitizer] Move stat/__xstat to the common interceptorsMike Aizatsky
Summary: Adds stat/__xstat to the common interceptors. Removes the now-duplicate stat/__xstat interceptor from msan/tsan/esan. This adds stat/__xstat to asan, which previously did not intercept it. Reviewers: aizatsky, eugenis Subscribers: tberghammer, danalbert, srhines, kubabrecka, llvm-commits, vitalybuka, eugenis, kcc, bruening Differential Revision: http://reviews.llvm.org/D19875 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@268440 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26[sanitizer] [SystemZ] Add ptrace support bits.Marcin Koscielnicki
Differential Revision: http://reviews.llvm.org/D19134 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@267548 91177308-0d34-0410-b5e6-96231b3b80d8