- Jul 28, 2020
-
-
Julian Lettner authored
Checking the OS version via `GetMacosAlignedVersion()` now works in simulators [1]. Let's use it to simplify `DyldNeedsEnvVariable()`. [1] 3fb0de82 Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D81197
-
Julian Lettner authored
compiler-rt checks OS versions by querying the Darwin kernel version. This is not necessarily correct inside the simulators if the simulator runtime is not aligned with the host macOS. Let's instead check the `SIMULATOR_RUNTIME_VERSION` env var. rdar://63031937 Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D83977
-
- Jul 16, 2020
-
-
Julian Lettner authored
This reverts commit b16dfbea. Accidental push, reverting and creating a new revision.
-
Teresa Johnson authored
Summary: This refactors some common support related to shadow memory setup from asan and hwasan into sanitizer_common. This should not only reduce code duplication but also make these facilities available for new compiler-rt uses (e.g. heap profiling). In most cases the separate copies of the code were either identical, or at least functionally identical. A few notes: In ProtectGap, the asan version checked the address against an upper bound (kZeroBaseMaxShadowStart, which is (2^18). I have created a copy of kZeroBaseMaxShadowStart in hwasan_mapping.h, with the same value, as it isn't clear why that code should not do the same check. If it shouldn't, I can remove this and guard this check so that it only happens for asan. In asan's InitializeShadowMemory, in the dynamic shadow case it was setting __asan_shadow_memory_dynamic_address to 0 (which then sets both macro SHADOW_OFFSET as well as macro kLowShadowBeg to 0) before calling FindDynamicShadowStart(). AFAICT this is only needed because FindDynamicShadowStart utilizes kHighShadowEnd to get the shadow size, and kHighShadowEnd is a macro invoking MEM_TO_SHADOW(kHighMemEnd) which in turn invokes: (((kHighMemEnd) >> SHADOW_SCALE) + (SHADOW_OFFSET)) I.e. it computes the shadow space needed by kHighMemEnd (the shift), and adds the offset. Since we only want the shadow space here, the earlier setting of SHADOW_OFFSET to 0 via __asan_shadow_memory_dynamic_address accomplishes this. In the hwasan version, it simply gets the shadow space via "MemToShadowSize(kHighMemEnd)", where MemToShadowSize just does the shift. I've simplified the asan handling to do the same thing, and therefore was able to remove the setting of the SHADOW_OFFSET via __asan_shadow_memory_dynamic_address to 0. Reviewers: vitalybuka, kcc, eugenis Subscribers: dberris, #sanitizers, llvm-commits, davidxl Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D83247
-
Julian Lettner authored
compiler-rt checks OS versions by querying the Darwin kernel version. This is not necessarily correct inside the simulators if the simulator runtime is not aligned with the host macOS. Let's instead check the `SIMULATOR_RUNTIME_VERSION` env var. Note that we still use the old code path as a fallback in case the `SIMULATOR_RUNTIME_VERSION` environment variable isn't set. rdar://63031937 Reviewers: delcypher Differential Revision: https://reviews.llvm.org/D79979
-
- Jul 10, 2020
-
-
Julian Lettner authored
Support macOS 11 in our runtime version checking code and update `GetMacosAlignedVersionInternal()` accordingly. This follows the implementation of `Triple::getMacOSXVersion()` in the Clang driver. Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D82918
-
- Jun 04, 2020
-
-
Julian Lettner authored
Extract ParseVersion helper function for testing. Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D80761
-
Julian Lettner authored
Fixup for ba6b1b43.
-
- Jun 03, 2020
-
-
Julian Lettner authored
Use a struct to represent numerical versions instead of encoding release names in an enumeration. This avoids the need to extend the enumeration every time there is a new release. Rename `GetMacosVersion() -> GetMacosAlignedVersion()` to better reflect how this is used on non-MacOS platforms. Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D79970
-
- Jun 01, 2020
-
-
Julian Lettner authored
This applies the learnings from [1]. What I intended as a simple cleanup made me realize that the compiler-rt version checks have two separate issues: 1) In some places (e.g., mmap flag setting) what matters is the kernel version, not the OS version. 2) OS version checks are implemented by querying the kernel version. This is not necessarily correct inside the simulators if the simulator runtime isn't aligned with the host macOS. This commit tackles 1) by adopting a separate query function for the Darwin kernel version. 2) (and cleanups) will be dealt with in follow-ups. [1] https://reviews.llvm.org/D78942 rdar://63031937 Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D79965
-
- May 21, 2020
-
-
Julian Lettner authored
The oldest supported deployment target currently is 10.7 [1]. We can remove a few outdated checks. [1] https://github.com/llvm/llvm-project/blob/3db893b3712a5cc98ac0dbc88e08df70069be216/compiler-rt/cmake/config-ix.cmake#L397 Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D79958
-
- May 11, 2020
-
-
Julian Lettner authored
Create a sanitizer_ptrauth.h header that #includes <ptrauth> when available and defines just the required macros as "no ops" otherwise. This should avoid the need for excessive #ifdef'ing. Follow-up to and discussed in: https://reviews.llvm.org/D79132 Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D79540
-
- May 07, 2020
-
-
Julian Lettner authored
When reporting diagnostics from ASan's (and other sanitizer's) signal handlers we should strip the "invalid signature" bit before printing addresses. This makes the report less confusing and let's the user focus on the real issue. rdar://62615826 Reviewed By: kubamracek, delcypher Differential Revision: https://reviews.llvm.org/D79132
-
- Apr 29, 2020
-
-
Julian Lettner authored
Newer iOS SDK introduce accessors to retrieve the register values (arm_thread_state64_get_*) and disallows direct access to fields. If arm_thread_state64_get_sp is defined, the accessors are available.
-
- Mar 24, 2020
-
-
Dan Liew authored
Add a `Symbolizer::GetEnvP()` method that allows symbolizer implementations to customise the environment of the symbolizer binary. Summary: This change introduces the `Symbolizer::GetEnvP()` method that returns a pointer to environment array used for spawning the symbolizer process. The motivation is to allow implementations to customise the environment if required. The default implementation just returns `__sanitizer::GetEnviron()` which (provided it's implemented) should preserve the existing behaviours of the various implementations. This change has been plumbed through the `internal_spawn(...)` and `StartSubprocess(...)` process spawning implementations. For the `StartSubprocess()` implementation we need to call `execve()` rather than `execv()` to pass the environment. However, it appears that `internal_execve(...)` exists in sanitizer_common so this patch use that which seems like a nice clean up. Support in the Windows implementation of `SymbolizerProcess:StartSymbolizerSubprocess()` has not been added because the Windows sanitizer runtime doesn't implement `GetEnviron()`. rdar://problem/58789439 Reviewers: kubamracek, yln, dvyukov, vitalybuka, eugenis, phosek, aizatsky, rnk Subscribers: #sanitizers, llvm-commits Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D76666
-
- Feb 10, 2020
-
-
Dimitry Andric authored
Summary: Instead of hand-crafting an offset into the structure returned by dlopen(3) to get at the link map, use the documented API. This is described in dlinfo(3): by calling it with `RTLD_DI_LINKMAP`, the dynamic linker ensures the right address is returned. This is a recommit of 92e267a9, with dlinfo(3) expliclity being referenced only for FreeBSD, non-Android Linux, NetBSD and Solaris. Other OSes will have to add their own implementation. Reviewers: devnexen, emaste, MaskRay, krytarowski Reviewed By: krytarowski Subscribers: krytarowski, vitalybuka, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D73990
-
Dimitry Andric authored
This reverts commit 92e267a9, as it appears Android is missing dlinfo(3).
-
Dimitry Andric authored
Summary: Instead of hand-crafting an offset into the structure returned by dlopen(3) to get at the link map, use the documented API. This is described in dlinfo(3): by calling it with `RTLD_DI_LINKMAP`, the dynamic linker ensures the right address is returned. Reviewers: devnexen, emaste, MaskRay, krytarowski Reviewed By: krytarowski Subscribers: krytarowski, vitalybuka, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D73990
-
- Jan 23, 2020
-
-
Evgenii Stepanov authored
This avoids a CFI-unfriendly function pointer type cast in internal_start_thread.
-
- Oct 10, 2019
-
-
Julian Lettner authored
Updated: Removed offending TODO comment. Dereferences with addresses above the 48-bit hardware addressable range produce "invalid instruction" (instead of "invalid access") hardware exceptions (there is no hardware address decoding logic for those bits), and the address provided by this exception is the address of the instruction (not the faulting address). The kernel maps the "invalid instruction" to SEGV, but fails to provide the real fault address. Because of this ASan lies and says that those cases are null dereferences. This downgrades the severity of a found bug in terms of security. In the ASan signal handler, we can not provide the real faulting address, but at least we can try not to lie. rdar://50366151 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D68676 > llvm-svn: 374265 llvm-svn: 374384
-
Russell Gallop authored
As it was breaking bots running sanitizer lint check This reverts r374265 (git b577efe4) llvm-svn: 374308
-
Julian Lettner authored
Dereferences with addresses above the 48-bit hardware addressable range produce "invalid instruction" (instead of "invalid access") hardware exceptions (there is no hardware address decoding logic for those bits), and the address provided by this exception is the address of the instruction (not the faulting address). The kernel maps the "invalid instruction" to SEGV, but fails to provide the real fault address. Because of this ASan lies and says that those cases are null dereferences. This downgrades the severity of a found bug in terms of security. In the ASan signal handler, we can not provide the real faulting address, but at least we can try not to lie. rdar://50366151 Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D68676 llvm-svn: 374265
-
- Aug 28, 2019
-
-
Julian Lettner authored
Use attribute flag `POSIX_SPAWN_CLOEXEC_DEFAULT` in the call to `posix_spawn`. If this flag is set, then only file descriptors explicitly described by the file_actions argument are available in the spawned process; all of the other file descriptors are automatically closed in the spawned process. POSIX_SPAWN_CLOEXEC_DEFAULT is an Apple-specific extension. llvm-svn: 370121
-
- Aug 19, 2019
-
-
David Carlier authored
Reviewers: yln,vitalybuka Reviewed By: yln Differential Revision: https://reviews.llvm.org/D66391 llvm-svn: 369285
-
- Aug 15, 2019
-
-
Julian Lettner authored
On Darwin, we currently use forkpty to communicate with the "atos" symbolizer. There are several problems that fork[pty] has, e.g. that after fork, interceptors are still active and this sometimes causes crashes or hangs. This is especially problematic for TSan, which uses interceptors for OS-provided locks and mutexes, and even Libc functions use those. This patch replaces forkpty with posix_spawn on Darwin. Since posix_spawn doesn't fork (at least on Darwin), the interceptors are not a problem. Another benefit is that we'll handle post-fork failures (e.g. sandbox disallows "exec") gracefully now. Related revisions and previous attempts that were blocked by or had to be revered due to test failures: https://reviews.llvm.org/D48451 https://reviews.llvm.org/D40032 Reviewed By: kubamracek Differential Revision: https://reviews.llvm.org/D65253 llvm-svn: 368947
-
- Jul 31, 2019
-
-
Nico Weber authored
See https://reviews.llvm.org/D58620 for discussion, and for the commands I ran. In addition I also ran for f in $(svn diff | diffstat | grep .cc | cut -f 2 -d ' '); do rg $f . ; done and manually updated (many) references to renamed files found by that. llvm-svn: 367463
-
- Jun 21, 2019
-
-
Julian Lettner authored
The VM layout on iOS is not stable between releases. On 64-bit iOS and its derivatives we use a dynamic shadow offset that enables ASan to search for a valid location for the shadow heap on process launch rather than hardcode it. This commit extends that approach for 32-bit iOS plus derivatives and their simulators. rdar://50645192 rdar://51200372 rdar://51767702 Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D63586 llvm-svn: 364105
-
- Jun 11, 2019
-
-
Julian Lettner authored
Reviewed By: delcypher Differential Revision: https://reviews.llvm.org/D63096 llvm-svn: 363104
-
- Apr 11, 2019
-
-
JF Bastien authored
llvm-svn: 358145
-
- Jan 19, 2019
-
-
Chandler Carruth authored
to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
-
- Jan 08, 2019
-
-
Evgeniy Stepanov authored
Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: vitalybuka, pcc, krytarowski Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D56141 llvm-svn: 350590
-
- Dec 28, 2018
-
-
Evgeniy Stepanov authored
Revert r350104 "[asan] Fix build on windows." Revert r350101 "[asan] Support running without /proc." These changes break Mac build, too. llvm-svn: 350112
-
- Dec 27, 2018
-
-
Evgeniy Stepanov authored
Summary: This patch lets ASan run when /proc is not accessible (ex. not mounted yet). It includes a special test-only flag that emulates this condition in an unpriviledged process. This only matters on Linux, where /proc is necessary to enumerate virtual memory mappings. Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55874 llvm-svn: 350101
-
- Dec 23, 2018
-
-
Michal Gorny authored
Add a CheckMPROTECT() routine to detect when pax MPROTECT is enabled on NetBSD, and error xray out when it is. The solution is adapted from existing CheckASLR(). Differential Revision: https://reviews.llvm.org/D56049 llvm-svn: 350030
-
- Dec 20, 2018
-
-
Evgeniy Stepanov authored
Summary: Support running with no open file descriptors (as may happen to "init" process on linux). * Remove a check that writing to stderr succeeds. * When opening a file (ex. for log_path option), dup the new fd out of [0, 2] range to avoid confusing the program. (2nd attempt, this time without the sanitizer_rtems change) Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55801 llvm-svn: 349817
-
Ilya Biryukov authored
This reverts commit r349699. Reason: the commit breaks compilation of sanitizer_rtems.cc when building for RTEMS. llvm-svn: 349745
-
Evgeniy Stepanov authored
Summary: Support running with no open file descriptors (as may happen to "init" process on linux). * Remove a check that writing to stderr succeeds. * When opening a file (ex. for log_path option), dup the new fd out of [0, 2] range to avoid confusing the program. Reviewers: pcc, vitalybuka Subscribers: kubamracek, llvm-commits Differential Revision: https://reviews.llvm.org/D55801 llvm-svn: 349699
-
- Nov 06, 2018
-
-
Kuba Mracek authored
This speeds up process startup and teardown and also reduces lock contention when running multiple ASanified/TSanified processes simultaneously. Should greatly improve lit testing time. Differential Revision: https://reviews.llvm.org/D48445 llvm-svn: 346262
-
- Oct 26, 2018
-
-
Kuba Mracek authored
Part of <https://reviews.llvm.org/D48445>. llvm-svn: 345406
-
- Oct 05, 2018
-
-
Kamil Rytarowski authored
Summary: This change will allow to install sysctlbyname() interceptors more easily in sanitizers. Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D52793 llvm-svn: 343840
-