Commit Graph

64 Commits

Author SHA1 Message Date
Roland McGrath 81b700e302 [sanitizer_common] Implement MemoryMappingLayout for Fuchsia
This is needed to port lsan to Fuchsia.

Patch By: mcgrathr

Differential Revision: https://reviews.llvm.org/D72886
2020-01-24 16:35:43 -08:00
Vitaly Buka 48eb4a27d1 Update compiler-rt cpplint.py
adb3500107

llvm-svn: 371675
2019-09-11 21:33:06 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
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
2019-01-19 08:50:56 +00:00
Evgeniy Stepanov e1caa4ac72 [asan] Support running without /proc
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
2019-01-08 01:07:34 +00:00
Evgeniy Stepanov 3408b497f9 Revert "[asan] Support running without /proc.", +1
Revert r350104 "[asan] Fix build on windows."
Revert r350101 "[asan] Support running without /proc."

These changes break Mac build, too.

llvm-svn: 350112
2018-12-28 01:27:18 +00:00
Evgeniy Stepanov d9df65fd0d [asan] Support running without /proc.
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
2018-12-27 21:31:52 +00:00
Vitaly Buka fc8bb95724 OpenBSD UBsan support procmaps
Summary: procmaps OpenBSD specifics

Patch by David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: mgorny, emaste, kubamracek, fedor.sergeev, llvm-commits, #sanitizers

Differential Revision: https://reviews.llvm.org/D44050

llvm-svn: 327677
2018-03-15 22:40:47 +00:00
Kamil Rytarowski 271018d216 [Sanitizers] Basic sanitizer Solaris support (PR 33274)
Summary:
This is the first mostly working version of the Sanitizer port to 32-bit Solaris/x86.
It is currently based on Solaris 11.4 Beta.

This part was initially developed inside libsanitizer in the GCC tree and should apply to
both.  Subsequent parts will address changes to clang, the compiler-rt build system
and testsuite.

I'm not yet sure what the right patch granularity is: if it's profitable to split the patch
up, I'd like to get guidance on how to do so.

Most of the changes are probably straightforward with a few exceptions:

* The Solaris syscall interface isn't stable, undocumented and can change within an
  OS release.  The stable interface is the libc interface, which I'm using here, if possible
  using the internal _-prefixed names.

* While the patch primarily target 32-bit x86, I've left a few sparc changes in.  They
  cannot currently be used with clang due to a backend limitation, but have worked
  fine inside the gcc tree.

* Some functions (e.g. largefile versions of functions like open64) only exist in 32-bit
  Solaris, so I've introduced a separate SANITIZER_SOLARIS32 to check for that.

The patch (with the subsequent ones to be submitted shortly) was tested
on i386-pc-solaris2.11.  Only a few failures remain, some of them analyzed, some
still TBD:

    AddressSanitizer-i386-sunos :: TestCases/Posix/concurrent_overflow.cc
    AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc
    AddressSanitizer-i386-sunos :: TestCases/log-path_test.cc
    AddressSanitizer-i386-sunos :: TestCases/malloc-no-intercept.c
    AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/concurrent_overflow.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/Posix/start-deactivated.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/default_options.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/log-path_test.cc
    AddressSanitizer-i386-sunos-dynamic :: TestCases/malloc-no-intercept.c

   SanitizerCommon-Unit :: ./Sanitizer-i386-Test/MemoryMappingLayout.DumpListOfModules
    SanitizerCommon-Unit :: ./Sanitizer-i386-Test/SanitizerCommon.PthreadDestructorIterations

Maybe this is good enough the get the ball rolling.

Reviewers: kcc, alekseyshl

Reviewed By: alekseyshl

Subscribers: srhines, jyknight, kubamracek, krytarowski, fedor.sergeev, llvm-commits, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D40898

llvm-svn: 320740
2017-12-14 20:14:29 +00:00
Francis Ricci 345187338e Move LoadedModule list to a NoCtor vector and initialize on demand.
Unreverting this patch because llvm-clang-lld-x86_64-debian-fast started
passing again before the revert hit. Must've been just a flake.

llvm-svn: 314556
2017-09-29 20:55:06 +00:00
Francis Ricci 74c93de659 Revert "Move LoadedModule list to a NoCtor vector and initialize on demand."
I think this may have introduced a failure on
llvm-clang-lld-x86_64-debian-fast

This reverts commit r314533

llvm-svn: 314552
2017-09-29 20:04:29 +00:00
Francis Ricci 113708b7cb Move LoadedModule list to a NoCtor vector and initialize on demand.
llvm-svn: 314533
2017-09-29 16:47:02 +00:00
Francis Ricci 052ec5f92a Revert "Add support for custom loaders to the sanitizer symbolizer"
This causes the gcc sanitizer buildbot to timeout.

This reverts commit 81f388fe570e5b6460dd5bc9b9a36b72714eeb68.

llvm-svn: 314453
2017-09-28 19:37:17 +00:00
Francis Ricci b9a32d470a Add support for custom loaders to the sanitizer symbolizer
Summary:
Adds a fallback mode to procmaps when the symbolizer
fails to locate a module for a given address by using
dl_iterate_phdr.

Reviewers: kubamracek, rnk, vitalybuka, eugenis

Reviewed By: eugenis

Subscribers: srhines, llvm-commits

Differential Revision: https://reviews.llvm.org/D37269

llvm-svn: 314431
2017-09-28 16:58:35 +00:00
Francis Ricci cb15e22b3b Revert "Add support for custom loaders to symbolizer"
This broke the windows buildbots, revert for now.

This reverts commit 24050b5ddef42f6f3306aa94d4a1f42a7893a9a7.

llvm-svn: 314347
2017-09-27 21:35:33 +00:00
Francis Ricci f80c42e589 Add support for custom loaders to symbolizer
Change-Id: I5594bd6b216deca2c73cf0a7001f9aec1e803c60
llvm-svn: 314342
2017-09-27 20:56:04 +00:00
Francis Ricci 92fa15d01c Add missing include to sanitizer procmaps
llvm-svn: 314162
2017-09-25 21:51:04 +00:00
Francis Ricci 7bde17f3ec Fix style in sanitizer_procmaps.h
llvm-svn: 314157
2017-09-25 21:26:34 +00:00
Francis Ricci 6e4dfccc31 [sanitizer_common] Don't provide sanitizer_procmaps API functions where not defined
Summary:
Platforms that don't implement procmaps (primarily fuchsia and windows) still expose
the procmaps API when including sanitizer_procmaps.h, despite not implementing the functions
provided by that header. Ensure that the API is only exposed on platforms that implement it.

Reviewers: vitalybuka, alekseyshl, kubamracek

Subscribers: llvm-commits, krytarowski

Differential Revision: https://reviews.llvm.org/D38187

llvm-svn: 314149
2017-09-25 20:48:51 +00:00
Francis Ricci 3aae099702 Fix fuchsia builds broken by r313999
llvm-svn: 314021
2017-09-22 19:22:08 +00:00
Francis Ricci c007c42ee9 Fix windows buildbot broken by r313999
llvm-svn: 314001
2017-09-22 18:17:26 +00:00
Francis Ricci fbccb0a8d2 Removed platform-specific ifdefs from sanitizer_procmaps.h
Summary: Removed platform-specific ifdefs for linux, mac, freebsd and netbsd from sanitizer_procmaps.h

Patch by Yicheng Wang <yichengfb@fb.com>

Reviewers: kcc, kubamracek, alekseyshl, fjricci, vitalybuka

Reviewed By: fjricci, vitalybuka

Subscribers: vitalybuka, emaste, krytarowski, llvm-commits

Differential Revision: https://reviews.llvm.org/D38098

llvm-svn: 313999
2017-09-22 17:48:24 +00:00
Francis Ricci ec4ac0f0c6 Add address ranges for individual macho sections on darwin
Summary:
This is a re-upload of the reverted commit r308644. It has changed quite
a bit to reflect post-commit comments by kcc, so I'm re-uploading as
a new review.

Reviewers: kubamracek, alekseyshl, kcc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35799

llvm-svn: 308977
2017-07-25 15:27:32 +00:00
Francis Ricci 4f82717643 [compiler-rt] Add missing const specifier to MemoryMappedSegment functions
llvm-svn: 308881
2017-07-24 14:31:01 +00:00
Francis Ricci d08a0864e4 Revert "Add MemoryMappedSection struct for two-level memory map iteration"
This probably broke lib0 tsan unit test on 10.11 buildbots

This reverts commit 35ad307c385e384f47a7fb348c14b3602d3a33c4.

llvm-svn: 308676
2017-07-20 21:23:14 +00:00
Francis Ricci 0ba09182bd Add MemoryMappedSection struct for two-level memory map iteration
Summary: This will allow sanitizer_procmaps on mac to expose section information.

Reviewers: kubamracek, alekseyshl, kcc

Subscribers: llvm-commits, emaste

Differential Revision: https://reviews.llvm.org/D35422

llvm-svn: 308644
2017-07-20 18:06:02 +00:00
Kamil Rytarowski 734acfda0f Add NetBSD support in sanitizer_procmaps.h
Summary:
Reuse Linux and FreeBSD - no NetBSD specific changes.

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, filcab, kcc, vitalybuka

Reviewed By: filcab

Subscribers: llvm-commits, emaste, kubamracek, #sanitizers

Tags: #sanitizers

Differential Revision: https://reviews.llvm.org/D35629

llvm-svn: 308615
2017-07-20 13:31:06 +00:00
Francis Ricci bf60f68c2c Revert "Add MemoryMappedSection struct for two-level memory map iteration"
This reverts commit c8095ce74118dee8544b0f1ffaba8f46aa10215c.

Reverted due to some buildbot timeouts, perhaps due to 10.11 issues.

llvm-svn: 308395
2017-07-18 23:51:47 +00:00
Francis Ricci 1b5f773859 Revert "Only scan global sections containing data in LSan on darwin"
This reverts commit 7e46d78d47832f03ce42adcf56417fbfd47cbaad.

llvm-svn: 308394
2017-07-18 23:51:44 +00:00
Francis Ricci 7096b08cd7 Only scan global sections containing data in LSan on darwin
Summary:
__DATA segments on Darwin contain a large number of separate sections,
most of which cannot actually contain pointers, and contain const values or
objc metadata. Only scanning sections which can contain pointers greatly improves
performance.

On a medium-sized (~4000 files) internal project, I saw a speedup of about 50%
in standalone LSan's execution time (50% improvement in the time spent running
LSan, not the total program time).

Reviewers: kcc, kubamracek, alekseyshl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35432

llvm-svn: 308231
2017-07-17 23:03:03 +00:00
Francis Ricci 455ba3fd79 Add MemoryMappedSection struct for two-level memory map iteration
Summary: This will allow sanitizer_procmaps on mac to expose section information.

Reviewers: kubamracek, alekseyshl, kcc

Subscribers: llvm-commits, emaste

Differential Revision: https://reviews.llvm.org/D35422

llvm-svn: 308210
2017-07-17 20:09:20 +00:00
Francis Ricci edd53cb652 Inline function to get mac segment address range
Summary:
This function is only called once and is fairly simple. Inline to
keep API simple.

Reviewers: alekseyshl, kubamracek

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35270

llvm-svn: 307695
2017-07-11 19:40:53 +00:00
Francis Ricci f6a4329b7d Refactor MemoryMappingLayout::Next to use a single struct instead of output parameters. NFC.
Summary:
This is the first in a series of patches to refactor sanitizer_procmaps
to allow MachO section information to be exposed on darwin.

In addition, grouping all segment information in a single struct is
cleaner than passing it through a large set of output parameters, and
avoids the need for annotations of NULL parameters for unneeded
information.

The filename string is optional and must be managed and supplied by the
calling function. This is to allow the MemoryMappedSegment struct to be
stored on the stack without causing overly large stack sizes.

Reviewers: alekseyshl, kubamracek, glider

Subscribers: emaste, llvm-commits

Differential Revision: https://reviews.llvm.org/D35135

llvm-svn: 307688
2017-07-11 18:54:00 +00:00
Francis Ricci 61ed9345c9 Add dyld to sanitizer procmaps on darwin
Summary:
Sanitizer procmaps uses dyld apis to iterate over the list of images
in the process. This is much more performan than manually recursing
over all of the memory regions in the process, however, dyld does
not report itself in the list of images. In order to prevent reporting
leaks from dyld globals and to symbolize dyld functions in stack traces,
this patch special-cases dyld and ensures that it is added to the
list of modules.

This is accomplished by recursing through the memory map of the process
until a dyld Mach header is found. While this recursion is expensive,
it is run before the full set of images has been loaded in the process,
so only a few calls are required. The result is cached so that it never
needs to be searched for when the full process memory map exists, as this
would be incredibly slow, on the order of minutes for leak sanitizer with
only 25 or so libraries loaded.

Reviewers: alekseyshl, kubamracek

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32968

llvm-svn: 302899
2017-05-12 14:10:53 +00:00
Francis Ricci 4cd7a15cea Revert "Add dyld to sanitizer procmaps on darwin"
This breaks several tests because we don't always have
access to __cxa_guard functions

This reverts commit 45eb470c3e9e8f6993a204e247c33d4092237efe.

llvm-svn: 302693
2017-05-10 16:33:46 +00:00
Francis Ricci 1cdcbcdb92 Add dyld to sanitizer procmaps on darwin
Summary:
Sanitizer procmaps uses dyld apis to iterate over the list of images
in the process. This is much more performan than manually recursing
over all of the memory regions in the process, however, dyld does
not report itself in the list of images. In order to prevent reporting
leaks from dyld globals and to symbolize dyld functions in stack traces,
this patch special-cases dyld and ensures that it is added to the
list of modules.

This is accomplished by recursing through the memory map of the process
until a dyld Mach header is found. While this recursion is expensive,
it is run before the full set of images has been loaded in the process,
so only a few calls are required. The result is cached so that it never
needs to be searched for when the full process memory map exists, as this
would be incredibly slow, on the order of minutes for leak sanitizer with
only 25 or so libraries loaded.

Reviewers: alekseyshl, kubamracek

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32968

llvm-svn: 302673
2017-05-10 14:38:04 +00:00
Kuba Mracek 43d287e04e [sanitizer] Track which modules are instrumented in LoadedModule objects
This patch adds tracking which modules are instrumented and which are not. On macOS, instrumented modules link against the ASan/TSan/... dylib, so we can just check if such a load command exists or not.

Differential Revision: https://reviews.llvm.org/D28263

llvm-svn: 291268
2017-01-06 19:34:54 +00:00
Kuba Mracek 3eb98a1318 [sanitizer] Track architecture and UUID of modules in LoadedModule
When we enumerate loaded modules, we only track the module name and base address, which then has several problems on macOS. Dylibs and executables often have several architecture slices and not storing which architecture/UUID is actually loaded creates problems with symbolication: A file path + offset isn't enough to correctly symbolicate, since the offset can be valid in multiple slices. This is especially common for Haswell+ X86_64 machines, where x86_64h slices are preferred, but if one is not available, a regular x86_64 is loaded instead. But the same issue exists for i386 vs. x86_64 as well.

This patch adds tracking of arch and UUID for each LoadedModule. At this point, this information isn't used in reports, but this is the first step. The goal is to correctly identify which slice is loaded in symbolication, and also to output this information in reports so that we can tell which exact slices were loaded in post-mortem analysis.

Differential Revision: https://reviews.llvm.org/D26632

llvm-svn: 288537
2016-12-02 21:27:14 +00:00
Alexey Samsonov 8e3cbde27d [Sanitizer] Introduce ListOfModules object and use it to replace GetListOfModules().
Summary:
This removes the hard limit on the number of loaded modules (used to be
16K), and makes it easier to use LoadedModules w/o causing a memory
leak: ListOfModules owns the modules, and makes sure to properly clean
them in destructor.

Remove filtering functionality that is only needed in one place (LSan).

Reviewers: aizatsky

Subscribers: llvm-commits, kcc

Differential Revision: http://reviews.llvm.org/D17470

llvm-svn: 261554
2016-02-22 18:52:51 +00:00
Viktor Kutuzov a37ad099e8 Segregate FreeBSD-specific parts from sanitizer_procmaps_linux.cc
Differential Revision: http://reviews.llvm.org/D4555

llvm-svn: 214955
2014-08-06 10:16:52 +00:00
Alexey Samsonov d52b9ba38d [FreeBSD] Enable procmaps on FreeBSD.
This is not the final patch for procmaps, but it's enough for building
sanitizers and tests on FreeBSD.

Patch by Viktor Kutuzov!

llvm-svn: 203099
2014-03-06 08:58:24 +00:00
Alexey Samsonov 782ad0eb71 [Sanitizer] Remove now unused symbolization functionality from MemoryMappingLayout
llvm-svn: 198014
2013-12-25 12:11:06 +00:00
Alexey Samsonov 64ffa598ce [Sanitizer] Teach MemoryMappingLayout to dump all loaded modules.
Use this to implement GetListOfModules() on Mac and on Android
(on Linux we use dl_iterate_phdr).

llvm-svn: 198004
2013-12-25 08:39:38 +00:00
Alexey Samsonov 2f392d237c [Sanitizer] Move OS-specific code for MemoryMappingLayout into separate source files.
llvm-svn: 198003
2013-12-25 08:01:16 +00:00
Dmitry Vyukov 4e9c091dd7 tsan: allow to obtain code range for a particular module
this is required to ignore interceptors when called from the module

llvm-svn: 191149
2013-09-21 21:41:08 +00:00
Alexander Potapenko 7e1c51988d [TSan] Move the /proc/self/maps parsing logic to sanitizer_common
Provide a generic way for the tools to generate memory profiles from contents of /proc/self/maps

llvm-svn: 189789
2013-09-03 11:09:16 +00:00
Alexey Samsonov a0e28a7aaa [Sanitizer] Kill the remainders of platform defines in favor of SANITIZER_ defines
llvm-svn: 178627
2013-04-03 07:24:35 +00:00
Dmitry Vyukov 9f08fe5065 tsan: fix lint warning
llvm-svn: 178157
2013-03-27 17:57:58 +00:00
Alexander Potapenko 29310ba077 [libsanitizer] Fix the Win build.
llvm-svn: 178012
2013-03-26 13:02:11 +00:00
Alexander Potapenko f8109dd0f8 [libsanitizer] Unmapping the old cache partially invalidates the memory layout, so add
a flag to skip cache update for cases when that's unacceptable (e.g. lsan).

Patch by Sergey Matveev (earthdok@google.com)

llvm-svn: 178000
2013-03-26 10:34:37 +00:00
Evgeniy Stepanov 95eaa21637 [sanitizer] More renamed macros.
llvm-svn: 177401
2013-03-19 14:54:17 +00:00