[all-commits] [llvm/llvm-project] 652707: [nsan] Use sanitizer allocator

Fangrui Song via All-commits all-commits at lists.llvm.org
Mon Aug 12 13:57:02 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 652707a6457eeb3927a1fe82e6b2cbc2a1fa22f5
      https://github.com/llvm/llvm-project/commit/652707a6457eeb3927a1fe82e6b2cbc2a1fa22f5
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-08-12 (Mon, 12 Aug 2024)

  Changed paths:
    M compiler-rt/lib/nsan/CMakeLists.txt
    M compiler-rt/lib/nsan/nsan.cpp
    M compiler-rt/lib/nsan/nsan.h
    A compiler-rt/lib/nsan/nsan_allocator.cpp
    A compiler-rt/lib/nsan/nsan_allocator.h
    M compiler-rt/lib/nsan/nsan_flags.inc
    M compiler-rt/lib/nsan/nsan_malloc_linux.cpp
    A compiler-rt/lib/nsan/nsan_new_delete.cpp
    M compiler-rt/lib/nsan/nsan_platform.h
    M compiler-rt/lib/nsan/nsan_thread.cpp
    M compiler-rt/lib/nsan/nsan_thread.h
    A compiler-rt/test/nsan/Posix/allocator_mapping.cpp
    A compiler-rt/test/nsan/allocator_interface.cpp
    A compiler-rt/test/nsan/malloc_hook.cpp
    A compiler-rt/test/nsan/new_delete_test.cpp

  Log Message:
  -----------
  [nsan] Use sanitizer allocator

* The performance is better than the glibc allocator.
* Allocator interface functions, sanitizer allocator options, and
  MallocHooks/FreeHooks are supported.
* Shadow memory has specific memory layout requirement. Using libc
  allocator could lead to conflicts.
* When we add a mmap interceptor for reliability (the VMA could reuse a
  previously released VMA that is poisoned): glibc may invoke an
  internal system call to call unmmap, which cannot be intercepted. We
  will not be able to return the shadow memory to the OS.

Similar to dfsan https://reviews.llvm.org/D101204 . Also intercept
operator new/delete to be similar to other sanitizers using the
sanitizer allocator. The align_val_t overload of operator new has
slightly less overhead.

Pull Request: https://github.com/llvm/llvm-project/pull/102764



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list