summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_libc.h
AgeCommit message (Collapse)Author
2016-07-21Fix clang-cl warning and crash in sanitizersReid Kleckner
Make kStderrFd a macro to avoid dynamic initialization of the report_file global. This actually causes a crash at runtime, because ASan initializes before static initializers run. Remove an unused variable in asan_win.cc. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@276314 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14[compiler-rt] Add internal wcslen to avoid crashing on windows 64-bitsEtienne Bergeron
Summary: The function wcslen is incorrectly hooked on windows 64-bits. The interception library is not able to hook without breaking the code. The function is too small and the interception must be done with trampoline-hooking which turned out to be incorrect on a small loop (first few instructions have a backedge). Reviewers: rnk Subscribers: wang0109, chrisha, llvm-commits, kubabrecka Differential Revision: https://reviews.llvm.org/D22363 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@275488 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-12Fixup for r269288. SleepForSeconds is not available in nolibc builds, let's ↵Kuba Brecka
add an internal_sleep. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269296 91177308-0d34-0410-b5e6-96231b3b80d8
2015-11-20[compiler-rt] Add internal implementations for strlcat and strlcpyAnna Zaks
The compiler-rt should make use of strlcpy() rather than strncpy(). Using internal_strncpy() may be fine with appropriate bounds checking or enforcement of nul-termination elsewhere, but it's just good practice these days to avoid using strncpy() in new code. A patch by Jeremy Sequoia! Differential Revision: http://reviews.llvm.org/D14714 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253690 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-29[sanitizer] Fix Clang-tidy modernize-use-nullptr warnings in ↵Kostya Serebryany
lib/sanitizer_common headers, unify closing inclusion guards. Patch by Eugene Zelenko git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@248816 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09[ASan/Win] Add more support for file operationsTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234494 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use RenameFile instead of internal_rename in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234490 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use WriteToFile instead of internal_write in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234487 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Use ReadFromFile instead of internal_read in non-POSIX codeTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234485 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Move more POSIX-specific functions to sanitizer_posix.hTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234482 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-09Introduce CloseFile to be used instead of internal_close on non-POSIXTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234481 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08[Sanitizer RT] Get rid of internal_isattyTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234423 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08Move some POSIX-specific functions from sanitizer_libc.h to a new ↵Timur Iskhodzhanov
sanitizer_posix.h git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234418 91177308-0d34-0410-b5e6-96231b3b80d8
2015-04-08[Sanitizers] Make OpenFile more portableTimur Iskhodzhanov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@234410 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-06[compiler-rt] Make MaybeReexec properly process DYLD_INSERT_LIBRARIES when ↵Kuba Brecka
using non-absolute paths MaybeReexec() in asan_mac.cc checks for presence of the ASan dylib in DYLD_INSERT_LIBRARIES, and if it is there, it will process this env. var. and remove the dylib from its value, so that spawned children don't have this variable set. However, the current implementation only works when using a canonical absolute path to the dylib, it fails to remove the dylib for example when using @executable_path. This patch changes the processing of DYLD_INSERT_LIBRARIES to comparing values only based on filenames (ignoring directories). Reviewed at http://reviews.llvm.org/D7160 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@228392 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15[sanitizer] Flag parser rewrite.Evgeniy Stepanov
The new parser is a lot stricter about syntax, reports unrecognized flags, and will make it easier to implemented some of the planned features. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@226169 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16[asan] new flag: hard_rss_limit_mbKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@224353 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-27[asancov] Write coverage directly to a memory-mapped file.Evgeniy Stepanov
This way does not require a __sanitizer_cov_dump() call. That's important on Android, where apps can be killed at arbitrary time. We write raw PCs to disk instead of module offsets; we also write memory layout to a separate file. This increases dump size by the factor of 2 on 64-bit systems. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@209653 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-13[libsanitizer] Fix the return type of internal_forkAlexander Potapenko
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208714 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-13[libsanitizer] Use internal_fork() to spawn the symbolizer process.Alexander Potapenko
This should fix https://code.google.com/p/thread-sanitizer/issues/detail?id=61 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@208707 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31[ASan] Move the SIGSEGV/SIGBUS handling to sanitizer_commonAlexander Potapenko
This change is a part of refactoring intended to have common signal handling behavior in all tools. This particular CL moves InstallSignalHandlers() into sanitizer_common (making it InstallDeadlySignalHandlers()), but doesn't enable default signal handlers for any tool other than ASan. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@200542 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-23[sanitizer] use 16-byte aligned bzero in performance critical place (mostly ↵Kostya Serebryany
for lsan) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@195549 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03Add internal_strchrnul functionAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@189797 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-17[nolibc] Move all platforms to internal_getpid.Peter Collingbourne
Before, we had an unused internal_getpid function for Linux, and a platform-independent GetPid function. To make the naming conventions consistent for syscall-like functions, the GetPid syscall wrapper in sanitizer_posix.cc is moved to sanitizer_mac.cc, and GetPid is renamed to internal_getpid, bringing the Linux variant into use. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@182132 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-08[nolibc] Change internal syscall API to remove reliance on libc's errno.Peter Collingbourne
This change moves to a model where the error value of a system call is potentially contained in the return value itself rather than being implicit in errno. The helper function internal_iserror can be used to extract the error value from a return value. On platforms other than Linux/x86_64 this still uses errno, but other platforms are free to port their error handling to this new model. Differential Revision: http://llvm-reviews.chandlerc.com/D756 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@181436 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-20tsan: add internal_unlink() functionDmitry Vyukov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@177510 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-27add Linux syscall wrappers and ThreadLister to sanitizer_commonKostya Serebryany
ThreadLister is a Linux-specific class for obtaining the thread IDs of a process from procfs (/proc/<pid>/task/). It will be used by leak checking code. Also add several syscall wrappers which will be required by the same code that uses ThreadLister, but are not used in ThreadLister itself. Patch by Sergey Matveev git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@176179 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20[Sanitizer] use raw syscall instead of _exit() function on LinuxAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@175622 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-04[Sanitizer] extend internal libc with stat/fstat/lstat functionsAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174316 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01[Sanitizer] use u32 instead of mode_t, which is defined in Darwin headersAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174189 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-01[Sanitizer] make internal_open have the same interface as libc versionAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@174187 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30[sanitizer] Further split private and public sanitizer headers.Evgeniy Stepanov
And make msan_interface.h C-compatible. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@173928 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-28[asan] implement more strict checking for memset/etc parameters. Instead of ↵Kostya Serebryany
checking the first and the last byte, we check the entire shadow region. This costs ~10 slowdown for the instrumented functions. Motivated by a nasty memset-buffer-overflow-by-140-bytes in chrome which was reported as a use-after-free or not at all git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@171198 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-02[Sanitizer] Add internal_isatty to sanitizer_libc and PrintsToTty to ↵Alexey Samsonov
determine whether error reports are printed to terminal git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167298 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-02[Sanitizer] Use kStderrFd constant instead of hardcoded 2Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@167291 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-15Implement internal_memmove.Alexander Potapenko
Use internal_memmove() and internal_memcpy() in the memcpy() and memmove() wrappers when building the dynamic runtime (OS X only), to work around a bug in resolver functions wrapping. See also http://code.google.com/p/address-sanitizer/issues/detail?id=116 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@165939 91177308-0d34-0410-b5e6-96231b3b80d8
2012-09-05[Sanitizer] implement readlink as syscall on LinuxAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@163213 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-29Relocate the external headers provided by ASan and the common sanitizerChandler Carruth
library. These headers are intended to be available to user code when built with AddressSanitizer (or one of the other sanitizer's in the future) to interface with the runtime library. As such, they form stable external C interfaces, and the headers shouldn't be located within the implementation. I've pulled them out into what seem like fairly obvious locations and names, but I'm wide open to further bikeshedding of these names and locations. I've updated the code and the build system to cope with the new locations, both CMake and Makefile. Please let me know if this breaks anyone's build. The eventual goal is to install these headers along side the Clang builtin headers when we build the ASan runtime and install it. My current thinking is to locate them at: <prefix>/lib/clang/X.Y/include/sanitizer/common_interface_defs.h <prefix>/lib/clang/X.Y/include/sanitizer/asan_interface.h <prefix>/lib/clang/X.Y/include/sanitizer/... But maybe others have different suggestions? Fixing the style of the #include between these headers at least unblocks experimentation with installing them as they now should work when installed in these locations. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162822 91177308-0d34-0410-b5e6-96231b3b80d8
2012-08-21[Sanitizer] implement internal_strcspnAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@162272 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-29[asan] get rid of libc's sscanf as it causes infinite recursion on Fedora. Kostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159424 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19[Sanitizer] Renaming: SNPrintf -> internal_snprintf (and move it to ↵Alexey Samsonov
sanitizer libc) git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158710 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-19[Sanitizer] State that sanitizer_libc.h header can be included in the user ↵Alexey Samsonov
code (and therefore it shouldn't include other sanitizer runtime headers). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158707 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18[Sanitizer] add internal_strncmp to sanitizer libcAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158658 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-18[Sanitizer] move different wrappers from TSan to common sanitizer runtimeAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158655 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15[Sanitizer] move all the rest re-implementations of libc functions from ASan ↵Alexey Samsonov
runtime to common sanitizer runtime git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158519 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-15[Sanitizer] Use DEFINE_REAL macro in TSan runtime to call libc ↵Alexey Samsonov
implementations of functions. Move strchr to sanitizer_libc. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158517 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-14[Sanitizer] Move internal_memcmp to common sanitizer libcAlexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158450 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-08[Sanitizer] add internal_memset and internal_strrchr to sanitizer_common/Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158202 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-07[Sanitizer] move internal_strdup and internal_memcpy to common runtime. Make ↵Alexey Samsonov
internal allocations from TSan runtime call InternalAlloc from common runtime git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158148 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06[Sanitizer] Move more functions/constants to sanitizer_common.Alexey Samsonov
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158056 91177308-0d34-0410-b5e6-96231b3b80d8