Skip to content
  1. Jul 28, 2020
  2. Jul 16, 2020
    • Julian Lettner's avatar
      Revert "[Darwin] Fix OS version checks inside simulators" · bd88991a
      Julian Lettner authored
      This reverts commit b16dfbea.
      
      Accidental push, reverting and creating a new revision.
      bd88991a
    • Teresa Johnson's avatar
      [compiler-rt][asan][hwasan] Refactor shadow setup into sanitizer_common (NFCI) · 5d2be1a1
      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
      5d2be1a1
    • Julian Lettner's avatar
      [Darwin] Fix OS version checks inside simulators · b16dfbea
      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
      b16dfbea
  3. Jul 10, 2020
  4. Jun 04, 2020
  5. Jun 03, 2020
    • Julian Lettner's avatar
      [Darwin] Improve runtime OS version checks · ba6b1b43
      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
      ba6b1b43
  6. Jun 01, 2020
    • Julian Lettner's avatar
      [Darwin] Add and adopt a way to query the Darwin kernel version · f97a609b
      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
      f97a609b
  7. May 21, 2020
  8. May 11, 2020
  9. May 07, 2020
  10. Apr 29, 2020
    • Julian Lettner's avatar
      [Darwin] Fix compilation issues on arm64 · 82ed13cd
      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.
      82ed13cd
  11. Mar 24, 2020
    • Dan Liew's avatar
      Add a `Symbolizer::GetEnvP()` method that allows symbolizer implementations to... · b684c1a5
      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
      b684c1a5
  12. Feb 10, 2020
    • Dimitry Andric's avatar
      [Sanitizers] Get link map on FreeBSD and NetBSD via documented API · 52f2df1e
      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
      52f2df1e
    • Dimitry Andric's avatar
      Revert "[Sanitizers] Get link map on FreeBSD via documented API" · 480eea4e
      Dimitry Andric authored
      This reverts commit 92e267a9, as it
      appears Android is missing dlinfo(3).
      480eea4e
    • Dimitry Andric's avatar
      [Sanitizers] Get link map on FreeBSD via documented API · 92e267a9
      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
      92e267a9
  13. Jan 23, 2020
  14. Oct 10, 2019
    • Julian Lettner's avatar
      Reland "[ASan] Do not misrepresent high value address dereferences as null dereferences" · 99c9d7bd
      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
      99c9d7bd
    • Russell Gallop's avatar
      Revert "[ASan] Do not misrepresent high value address dereferences as null dereferences" · c48e0873
      Russell Gallop authored
      As it was breaking bots running sanitizer lint check
      
      This reverts r374265 (git b577efe4)
      
      llvm-svn: 374308
      c48e0873
    • Julian Lettner's avatar
      [ASan] Do not misrepresent high value address dereferences as null dereferences · b577efe4
      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
      b577efe4
  15. Aug 28, 2019
    • Julian Lettner's avatar
      [sanitizer_common] Close superfluous file descriptors in spawned process · d3136661
      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
      d3136661
  16. Aug 19, 2019
  17. Aug 15, 2019
    • Julian Lettner's avatar
      [sanitizer_common] Replace forkpty with posix_spawn on Darwin · 399408a9
      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
      399408a9
  18. Jul 31, 2019
  19. Jun 21, 2019
  20. Jun 11, 2019
  21. Apr 11, 2019
  22. Jan 19, 2019
    • Chandler Carruth's avatar
      Update the file headers across all of the LLVM projects in the monorepo · 2946cd70
      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
      2946cd70
  23. Jan 08, 2019
    • Evgeniy Stepanov's avatar
      [asan] Support running without /proc · e1caa4ac
      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
      e1caa4ac
  24. Dec 28, 2018
  25. Dec 27, 2018
    • Evgeniy Stepanov's avatar
      [asan] Support running without /proc. · d9df65fd
      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
      d9df65fd
  26. Dec 23, 2018
  27. Dec 20, 2018
    • Evgeniy Stepanov's avatar
      [sanitizer] Support running without fd 0,1,2. · 3b7e8b2d
      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
      3b7e8b2d
    • Ilya Biryukov's avatar
      Revert "[sanitizer] Support running without fd 0,1,2." · ea8646ad
      Ilya Biryukov authored
      This reverts commit r349699.
      Reason: the commit breaks compilation of sanitizer_rtems.cc when
      building for RTEMS.
      
      llvm-svn: 349745
      ea8646ad
    • Evgeniy Stepanov's avatar
      [sanitizer] Support running without fd 0,1,2. · f762a9f8
      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
      f762a9f8
  28. Nov 06, 2018
  29. Oct 26, 2018
  30. Oct 05, 2018
Loading