Skip to content
Snippets Groups Projects
  • Tamar Christina's avatar
    0debaceb
    hwasan: instrument new memory and string functions [PR112644] · 0debaceb
    Tamar Christina authored
    Recent libhwasan updates[1] intercept various string and memory functions.
    These functions have checking in them, which means there's no need to
    inline the checking.
    
    This patch marks said functions as intercepted, and adjusts a testcase
    to handle the difference.  It also looks for HWASAN in a check in
    expand_builtin.  This check originally is there to avoid using expand to
    inline the behaviour of builtins like memset which are intercepted by
    ASAN and hence which we rely on the function call staying as a function
    call.  With the new reliance on function calls in HWASAN we need to do
    the same thing for HWASAN too.
    
    HWASAN and ASAN don't seem to however instrument the same functions.
    
    Looking into libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc
    it looks like the common ones are memset, memmove and memcpy.
    
    The rest of the routines for asan seem to be defined in
    compiler-rt/lib/asan/asan_interceptors.h however compiler-rt/lib/hwasan/
    does not have such a file but it does have
    compiler-rt/lib/hwasan/hwasan_platform_interceptors.h which it looks like is
    forcing off everything but memset, memmove, memcpy, memcmp and bcmp.
    
    As such I've taken those as the final list that hwasan currently supports.
    This also means that on future updates this list should be cross checked.
    
    [1] https://discourse.llvm.org/t/hwasan-question-about-the-recent-interceptors-being-added/75351
    
    
    
    gcc/ChangeLog:
    
    	PR sanitizer/112644
    	* asan.h (asan_intercepted_p): Incercept memset, memmove, memcpy and
    	memcmp.
    	* builtins.cc (expand_builtin): Include HWASAN when checking for
    	builtin inlining.
    
    gcc/testsuite/ChangeLog:
    
    	PR sanitizer/112644
    	* c-c++-common/hwasan/builtin-special-handling.c: Update testcase.
    
    Co-Authored-By: default avatarMatthew Malcomson <matthew.malcomson@arm.com>
    0debaceb
    History
    hwasan: instrument new memory and string functions [PR112644]
    Tamar Christina authored
    Recent libhwasan updates[1] intercept various string and memory functions.
    These functions have checking in them, which means there's no need to
    inline the checking.
    
    This patch marks said functions as intercepted, and adjusts a testcase
    to handle the difference.  It also looks for HWASAN in a check in
    expand_builtin.  This check originally is there to avoid using expand to
    inline the behaviour of builtins like memset which are intercepted by
    ASAN and hence which we rely on the function call staying as a function
    call.  With the new reliance on function calls in HWASAN we need to do
    the same thing for HWASAN too.
    
    HWASAN and ASAN don't seem to however instrument the same functions.
    
    Looking into libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc
    it looks like the common ones are memset, memmove and memcpy.
    
    The rest of the routines for asan seem to be defined in
    compiler-rt/lib/asan/asan_interceptors.h however compiler-rt/lib/hwasan/
    does not have such a file but it does have
    compiler-rt/lib/hwasan/hwasan_platform_interceptors.h which it looks like is
    forcing off everything but memset, memmove, memcpy, memcmp and bcmp.
    
    As such I've taken those as the final list that hwasan currently supports.
    This also means that on future updates this list should be cross checked.
    
    [1] https://discourse.llvm.org/t/hwasan-question-about-the-recent-interceptors-being-added/75351
    
    
    
    gcc/ChangeLog:
    
    	PR sanitizer/112644
    	* asan.h (asan_intercepted_p): Incercept memset, memmove, memcpy and
    	memcmp.
    	* builtins.cc (expand_builtin): Include HWASAN when checking for
    	builtin inlining.
    
    gcc/testsuite/ChangeLog:
    
    	PR sanitizer/112644
    	* c-c++-common/hwasan/builtin-special-handling.c: Update testcase.
    
    Co-Authored-By: default avatarMatthew Malcomson <matthew.malcomson@arm.com>