Skip to content
Snippets Groups Projects
  1. Jan 07, 2025
  2. Jan 06, 2025
    • Stefan Schulze Frielinghaus's avatar
      Fix type in some Min() calls (#119248) · 7a7903de
      Stefan Schulze Frielinghaus authored
      This is a follow-up to 6dec33834d1fd89f16e271dde9607c1de9554144 and
      pull requests #116957 and #119114.
      
      Cherry picked from LLVM commit 65a2eb0b1589590ae78cc1e5f05cd004b3b3bec5.
      
      libsanitizer/ChangeLog:
      
      	PR sanitizer/117725
      	* sanitizer_common/sanitizer_common_interceptors.inc: Cherry
      	picked from LLVM commit 65a2eb0b1589590ae78cc1e5f05cd004b3b3bec5.
      7a7903de
    • Vitaly Buka's avatar
      Fix few size types in memprof (#119114) · f0b82562
      Vitaly Buka authored
      
      Fix type in a few related Min() calls.
      
      Follow up to #116957.
      
      Cherry picked from LLVM commit 6dec33834d1fd89f16e271dde9607c1de9554144
      (removed memprof part).
      
      libsanitizer/ChangeLog:
      
      	PR sanitizer/117725
      	* asan/asan_interceptors.cpp: Cherry picked from LLVM commit
      	6dec33834d1fd89f16e271dde9607c1de9554144.
      	* sanitizer_common/sanitizer_common_interceptors.inc: Ditto.
      
      Co-authored-by: default avatarStefan Schulze Frielinghaus <stefansf@linux.ibm.com>
      f0b82562
    • Stefan Schulze Frielinghaus's avatar
      Add type __sanitizer::ssize (#116957) · 1bd03564
      Stefan Schulze Frielinghaus authored
      Since the sanitizer merge in commit r15-5164-gfa321004f3f628 of GCC
      which entails LLVM commit 61a6439f35b6de28ff4aff4450d6fca970292fd5, GCCs
      bootstrap is broken on s390 -m31. This is due to commit
      ec68dc1ca4d967b599f1202855917d5ec9cae52f which introduces stricter type
      checking which is why GCC bootstrap fails with
      
      ```
      In file included from /gcc/src/libsanitizer/interception/interception.h:18,
                       from /gcc/src/libsanitizer/interception/interception_type_test.cpp:14:
      /gcc/src/libsanitizer/interception/interception_type_test.cpp:30:61: error: static assertion failed
         30 | COMPILER_CHECK((__sanitizer::is_same<::SSIZE_T, ::ssize_t>::value));
            |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
      /gcc/src/libsanitizer/sanitizer_common/sanitizer_internal_defs.h:363:44: note: in definition of macro 'COMPILER_CHECK'
        363 | #define COMPILER_CHECK(pred) static_assert(pred, "")
            |                                            ^~~~
      make[8]: *** [Makefile:469: interception_type_test.lo] Error 1
      ```
      
      The culprit seems to be that we don't check for equality of type sizes
      anymore but rather whether the types are indeed the same. On s390 -m31
      we have that `sizeof(int)==sizeof(long)` holds which is why previously
      the checks succeeded. They fail now because
      
      ```
      size_t      => unsigned long
      ssize_t     => long
      ptrdiff_t   => int
      ::SSIZE_T   => __sanitizer::sptr => int
      ::PTRDIFF_T => __sanitizer::sptr => int
      ```
      
      This is fixed by mapping `SSIZE_T` to `long` in the end.
      
      ```
      typedef long ssize;
      typedef sptr ssize;
      
      ```
      
      Cherry picked from LLVM commit ce44640fe29550461120d22b0358e6cac4aed822.
      
      libsanitizer/ChangeLog:
      
      	PR sanitizer/117725
      	* interception/interception.h: Cherry picked from LLVM commit
      	ce44640fe29550461120d22b0358e6cac4aed822.
      	* sanitizer_common/sanitizer_internal_defs.h: Ditto.
      1bd03564
    • Stefan Schulze Frielinghaus's avatar
      Replace uptr by usize/SIZE_T in interfaces · 0bb38b27
      Stefan Schulze Frielinghaus authored
      For some targets uptr is mapped to unsigned int and size_t to unsigned
      long and sizeof(int)==sizeof(long) holds.  Still, these are distinct
      types and type checking may fail.  Therefore, replace uptr by
      usize/SIZE_T wherever a size_t is expected.
      
      Part of #116957
      
      Cherry picked from LLVM commit 9a156f6b2b0c892d8713ba907f07f027b24953d8
      (removed memprof, msan, and nsan parts).
      
      libsanitizer/ChangeLog:
      
      	PR sanitizer/117725
      	* asan/asan_interceptors.cpp: Cherry picked LLVM commit
      	9a156f6b2b0c892d8713ba907f07f027b24953d8.
      	* asan/asan_interceptors.h: Ditto.
      	* asan/asan_interceptors_memintrinsics.h: Ditto.
      	* sanitizer_common/sanitizer_common_interceptors.inc: Ditto.
      	* sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:
      	Ditto.
      	* sanitizer_common/sanitizer_platform_limits_posix.h: Ditto.
      	* tsan/tsan_interceptors_posix.cpp: Ditto.
      0bb38b27
  3. Nov 26, 2024
  4. Nov 25, 2024
    • Jakub Jelinek's avatar
      libsanitizer: Remove -pedantic from AM_CXXFLAGS [PR117732] · e984ba40
      Jakub Jelinek authored
      We aren't the master repository for the sanitizers and clearly upstream
      introduces various extensions in the code.
      All we care about is whether it builds and works fine with GCC, so
      -pedantic flag is of no use to us, only maybe to upstream if they
      cared about it (which they clearly don't).
      
      The following patch removes those and fixes some whitespace nits at the same
      time.
      
      2024-11-25  Jakub Jelinek  <jakub@redhat.com>
      
      	PR sanitizer/117732
      	* asan/Makefile.am (AM_CXXFLAGS): Remove -pedantic.  Formatting fix.
      	(asan_files): Formatting fix.
      	* hwasan/Makefile.am (AM_CXXFLAGS): Remove -pedantic.  Formatting fix.
      	* interception/Makefile.am (AM_CXXFLAGS): Likewise.
      	(interception_files): Formatting fix.
      	* libbacktrace/Makefile.am: Update copyright years.
      	* lsan/Makefile.am (AM_CXXFLAGS): Remove -pedantic.  Formatting fix.
      	* sanitizer_common/Makefile.am (AM_CXXFLAGS): Likewise.
      	(libsanitizer_common_la_DEPENDENCIES): Formatting fix.
      	* tsan/Makefile.am (AM_CXXFLAGS): Remove -pedantic.  Formatting fix.
      	* ubsan/Makefile.am (AM_CXXFLAGS): Likewise.
      	* asan/Makefile.in: Regenerate.
      	* hwasan/Makefile.in: Regenerate.
      	* interception/Makefile.in: Regenerate.
      	* libbacktrace/Makefile.in: Regenerate.
      	* lsan/Makefile.in: Regenerate.
      	* sanitizer_common/Makefile.in: Regenerate.
      	* tsan/Makefile.in: Regenerate.
      	* ubsan/Makefile.in: Regenerate.
      e984ba40
  5. Nov 23, 2024
  6. Nov 22, 2024
    • Andrew Pinski's avatar
      libsanitizer: Move language level from gnu++14 to gnu++17 · cdd7171a
      Andrew Pinski authored
      
      While compiling libsanitizer for aarch64-linux-gnu, I noticed the new warning:
      ```
      ../../../../libsanitizer/asan/asan_interceptors.cpp: In function ‘char* ___interceptor_strcpy(char*, const char*)’:
      ../../../../libsanitizer/asan/asan_interceptors.cpp:554:6: warning: ‘if constexpr’ only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
        554 |   if constexpr (SANITIZER_APPLE) {
            |      ^~~~~~~~~
      ```
      So compile-rt upstream compiles this as gnu++17 (the current defualt for clang), so let's update it
      to be similar.
      
      Build and tested on aarch64-linux-gnu.
      
      	PR sanitizer/117731
      libsanitizer/ChangeLog:
      
      	* asan/Makefile.am (AM_CXXFLAGS): Replace gnu++14 with gnu++17.
      	* asan/Makefile.in: Regenerate.
      	* hwasan/Makefile.am (AM_CXXFLAGS): Replace gnu++14 with gnu++17.
      	* hwasan/Makefile.in: Regenerate.
      	* interception/Makefile.am (AM_CXXFLAGS): Replace gnu++14 with gnu++17.
      	* interception/Makefile.in: Regenerate.
      	* libbacktrace/Makefile.am (AM_CXXFLAGS): Replace gnu++14 with gnu++17.
      	* libbacktrace/Makefile.in (AM_CXXFLAGS): Regenerate.
      	* lsan/Makefile.am (AM_CXXFLAGS): Replace gnu++14 with gnu++17.
      	* lsan/Makefile.in: Regenerate.
      	* sanitizer_common/Makefile.am (AM_CXXFLAGS): Replace gnu++14 with gnu++17.
      	* sanitizer_common/Makefile.in: Regenerate.
      	* tsan/Makefile.am (AM_CXXFLAGS): Replace gnu++14 with gnu++17.
      	* tsan/Makefile.in: Regenerate.
      	* ubsan/Makefile.am (AM_CXXFLAGS): Replace gnu++14 with gnu++17.
      	* ubsan/Makefile.in: Regenerate.
      
      Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
      cdd7171a
  7. Nov 12, 2024
  8. Sep 06, 2024
  9. Sep 05, 2024
    • Jakub Jelinek's avatar
      libsanitizer: On aarch64 use hint #34 in prologue of libsanitizer functions · 2379cbb9
      Jakub Jelinek authored
      When gcc is built with -mbranch-protection=standard, running sanitized
      programs doesn't work properly on bti enabled kernels.
      
      This has been fixed upstream with
      https://github.com/llvm/llvm-project/pull/84061
      
      The following patch cherry picks that from upstream.
      
      For trunk we should eventually do a full merge from upstream, but I'm hoping
      they will first fix up the _BitInt libubsan support mess.
      
      2024-09-05  Jakub Jelinek  <jakub@redhat.com>
      
      	* sanitizer_common/sanitizer_asm.h: Cherry-pick llvm-project revision
      	1c792d24e0a228ad49cc004a1c26bbd7cd87f030.
      	* interception/interception.h: Likewise.
      2379cbb9
  10. Feb 17, 2024
  11. Feb 16, 2024
    • Rainer Orth's avatar
      libsanitizer: Intercept __makecontext_v2 on Solaris/SPARC [PR113785] · 7c6071a6
      Rainer Orth authored
      c-c++-common/asan/swapcontext-test-1.c FAILs on Solaris/SPARC:
      
      FAIL: c-c++-common/asan/swapcontext-test-1.c   -O0  execution test
      FAIL: c-c++-common/asan/swapcontext-test-1.c   -O1  execution test
      FAIL: c-c++-common/asan/swapcontext-test-1.c   -O2  execution test
      FAIL: c-c++-common/asan/swapcontext-test-1.c   -O2 -flto  execution test
      FAIL: c-c++-common/asan/swapcontext-test-1.c -O2 -flto -flto-partition=none
      execution test
      FAIL: c-c++-common/asan/swapcontext-test-1.c -O3 -fomit-frame-pointer
      -funroll-loops -fpeel-loops -ftracer -finline-functions execution test
      FAIL: c-c++-common/asan/swapcontext-test-1.c   -O3 -g  execution test
      FAIL: c-c++-common/asan/swapcontext-test-1.c   -Os  execution test
      
      As detailed in PR sanitizer/113785, this happens because an ABI change
      in Solaris 10/SPARC caused the external symbol for makecontext to be
      changed to __makecontext_v2, which isn't intercepted.
      
      The following patch, submitted upstream at
      https://github.com/llvm/llvm-project/pull/81588, fixes that.
      
      Tested on sparc-sun-solaris2.11 and i386-pc-solaris2.11.
      
      2024-02-16  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	libsanitizer:
      	PR sanitizer/113785
      	* asan/asan_interceptors.cpp: Cherry-pick llvm-project revision
      	8c2033719a843a1880427a5e8caa5563248bce78.
      7c6071a6
  12. Feb 07, 2024
  13. Feb 06, 2024
  14. Jan 31, 2024
    • Tamar Christina's avatar
      libsanitizer: Sync fixes for asan interceptors from upstream · a73421bc
      Tamar Christina authored
      This cherry-picks and squashes the differences between commits
      
      d3e5c20ab846303874a2a25e5877c72271fc798b..76e1e45922e6709392fb82aac44bebe3dbc2ea63
      from LLVM upstream from compiler-rt/lib/hwasan/ to GCC on the changes relevant
      for GCC.
      
      This is required to fix the linked PR.
      
      As mentioned in the PR the last sync brought in a bug from upstream[1] where
      operations became non-recoverable and as such the tests in AArch64 started
      failing.  This cherry picks the fix and there are minor updates needed to GCC
      after this to fix the cases.
      
      [1] https://github.com/llvm/llvm-project/pull/74000
      
      PR sanitizer/112644
      Cherry-pick llvm-project revision
      672b71cc1003533460a82f06b7d24fbdc02ffd58,
      5fcf3bbb1acfe226572474636714ede86fffcce8,
      3bded112d02632209bd55fb28c6c5c234c23dec3 and
      76e1e45922e6709392fb82aac44bebe3dbc2ea63.
      a73421bc
  15. Jan 20, 2024
  16. Jan 19, 2024
    • Daniel Cederman's avatar
      libsanitizer: Replace memcpy with internal version in sanitizer_common · 3670fb86
      Daniel Cederman authored
      When GCC is configured with --enable-target-optspace the compiler generates
      a memcpy call in the Symbolizer constructor in sanitizer_symbolizer.cpp
      when compiling for SPARC V8. Add HAVE_AS_SYM_ASSIGN to replace it with a
      call to __sanitizer_internal_memcpy.
      
      libsanitizer/ChangeLog:
      
      	* sanitizer_common/Makefile.am (DEFS): Add @AS_SYM_ASSIGN_DEFS@.
      	* sanitizer_common/Makefile.in: Regenerate.
      3670fb86
  17. Jan 18, 2024
  18. Jan 17, 2024
    • YunQiang Su's avatar
      Sanitizer/MIPS: Use $t9 for preemptible function call · 557dbbac
      YunQiang Su authored
      Currently, almost all of the shared libraries of MIPS, rely on $t9
      to get the address of current function, instead of PCREL instructions,
      even on MIPSr6. So we have to set $t9 properly.
      
      To get the address of preemptible function, we need the help of GOT.
      MIPS/O32 has .cpload, which can help to generate 3 instructions to get GOT.
      For __mips64, we can get GOT by:
      
      lui $t8, %hi(%neg(%gp_rel(SANITIZER_STRINGIFY(TRAMPOLINE(func)))))
      daddu $t8, $t8, $t9
      daddiu $t8, $t8, %hi(%neg(%gp_rel(SANITIZER_STRINGIFY(TRAMPOLINE(func)))))
      
      And then get the address of __interceptor_func, and jump to it
      
      ld $t9, %got_disp(_interceptor" SANITIZER_STRINGIFY(func) ")($t8)
      jr $t9
      
      Upstream-Commit: 0a64367a72f1634321f5051221f05f2f364bd882
      
      libsanitizer
      
      	* interception/interception.h (substitution_##func_name):
      	Use macro C_ASM_TAIL_CALL.
      	* sanitizer_common/sanitizer_asm.h: Define C_ASM_TAIL_CALL
      	for MIPS with help of t9.
      557dbbac
  19. Jan 03, 2024
  20. Jan 02, 2024
  21. Nov 29, 2023
  22. Nov 28, 2023
    • Rainer Orth's avatar
      libsanitizer: Update LOCAL_PATCHES · 8f8db555
      Rainer Orth authored
      2023-11-28  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	libsanitizer:
      	* LOCAL_PATCHES: Update.
      8f8db555
    • Rainer Orth's avatar
      libsanitizer: Only use assembler symbol assignment if supported [PR112563] · 33b6ce99
      Rainer Orth authored
      This patch only enables symbol assignment if the configure test determined
      it's supported.
      
      Bootstrapped without regressions on sparc-sun-solaris2.11 (as and gas) and
      i386-pc-solaris2.11 (as and gas).
      
      2023-11-23  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	libsanitizer:
      	PR sanitizer/112563
      	* sanitizer_common/sanitizer_redefine_builtins.h: Check
      	HAVE_AS_SYM_ASSIGN.
      33b6ce99
    • Rainer Orth's avatar
      libsanitizer: Check assembler support for symbol assignment [PR112563] · 088d3cbc
      Rainer Orth authored
      The recent libsanitizer import broke the build on Solaris/SPARC with the
      native as:
      
      /usr/ccs/bin/as: ".libs/sanitizer_errno.s", line 4247: error: symbol
      "__sanitizer_internal_memset" is used but not defined
      /usr/ccs/bin/as: ".libs/sanitizer_errno.s", line 4247: error: symbol
      "__sanitizer_internal_memcpy" is used but not defined
      /usr/ccs/bin/as: ".libs/sanitizer_errno.s", line 4247: error: symbol
      "__sanitizer_internal_memmove" is used but not defined
      
      Since none of the alternatives considered in the PR worked out, this
      patch checks if the assembler does support symbol assignment, disabling
      the code otherwise.  This returns the code to the way it was up to LLVM 16.
      
      Bootstrapped without regressions on sparc-sun-solaris2.11 (as and gas) and
      i386-pc-solaris2.11 (as and gas).
      
      2023-11-23  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
      
      	libsanitizer:
      	PR sanitizer/112563
      	* configure.ac (libsanitizer_cv_as_sym_assign): Check for
      	assembler symbol assignment support.
      	* configure: Regenerate.
      	* asan/Makefile.am (DEFS): Add @AS_SYM_ASSIGN_DEFS@.
      	* Makefile.in, asan/Makefile.in, hwasan/Makefile.in,
      	interception/Makefile.in, libbacktrace/Makefile.in,
      	lsan/Makefile.in, sanitizer_common/Makefile.in, tsan/Makefile.in,
      	ubsan/Makefile.in: Regenerate.
      088d3cbc
  23. Nov 22, 2023
  24. Nov 21, 2023
    • Jakub Jelinek's avatar
      sanitizer: Fix build on SPARC/Solaris with Solaris as [PR112562] · c7c1ee1c
      Jakub Jelinek authored
      Solaris as apparently doesn't accept %function and requires @function
      instead.
      
      This cherry-picks upstream commit.
      
      2023-11-21  Jakub Jelinek  <jakub@redhat.com>
      
      	PR sanitizer/112562
      	* sanitizer_common/sanitizer_asm.h: Cherry-pick llvm-project revision
      	a855a16a02e76a0f4192c038bb64f3773947a2f7.
      	* interception/interception.h: Likewise.
      c7c1ee1c
  25. Nov 19, 2023
  26. Nov 18, 2023
  27. Nov 16, 2023
  28. Nov 15, 2023
    • Jakub Jelinek's avatar
      libsanitizer: update LOCAL_PATCHES · b648bc5c
      Jakub Jelinek authored
      2023-11-15  Jakub Jelinek  <jakub@redhat.com>
      
      	* LOCAL_PATCHES: Update revisions.
      b648bc5c
    • Jakub Jelinek's avatar
      libsanitizer: Readd __ubsan_handle_function_type_mismatch_v1{,_abort} · 95710d75
      Jakub Jelinek authored
      So that we don't have to bump libubsan.so.1 SONAME, the following patch
      reverts part of the changes which removed two handlers.  While we don't
      actually use them from GCC, we shouldn't remove supported entrypoints
      unless SONAME is changed (removal of __interceptor_* or ___interceptor_*
      is fine).  This is the only removal, other libraries just added some
      symbols.
      
      2023-11-15  Jakub Jelinek  <jakub@redhat.com>
      
      	* ubsan/ubsan_handlers_cxx.h (FunctionTypeMismatchData): Forward
      	declare.
      	(__ubsan_handle_function_type_mismatch_v1,
      	__ubsan_handle_function_type_mismatch_v1_abort): Declare.
      	* ubsan/ubsan_handlers_cxx.cpp (handleFunctionTypeMismatch,
      	__ubsan_handle_function_type_mismatch_v1,
      	__ubsan_handle_function_type_mismatch_v1_abort): New functions readded
      	for backwards compatibility from older ubsan.
      	* ubsan/ubsan_interface.inc (__ubsan_handle_function_type_mismatch_v1,
      	__ubsan_handle_function_type_mismatch_v1_abort): Readd.
      95710d75
    • Jakub Jelinek's avatar
      libsanitizer: Apply local patches · aaf0f121
      Jakub Jelinek authored
      This patch just reapplies local patches (will be noted in LOCAL_PATCHES).
      aaf0f121
    • Jakub Jelinek's avatar
      libsanitizer: merge from upstream (c425db2eb558c263) · 28219f7f
      Jakub Jelinek authored
      The following patch is result of libsanitizer/merge.sh
      from c425db2eb558c263 (yesterday evening).
      
      Bootstrapped/regtested on x86_64-linux and i686-linux (together with
      the follow-up 3 patches I'm about to post).
      
      BTW, seems upstream has added riscv64 support for I think lsan/tsan,
      so if anyone is willing to try it there, it would be a matter of
      copying e.g. the s390*-*-linux* libsanitizer/configure.tgt entry
      to riscv64-*-linux* with the obvious s/s390x/riscv64/ change in it.
      28219f7f
  29. Oct 23, 2023
Loading