From cb7dc4da4ccc475675b5aec6a08d3e8c0a1761e4 Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Thu, 7 Nov 2019 10:33:54 +0100 Subject: [PATCH] Libsanitizer: merge from trunk 2019-11-07 Martin Liska * merge.sh: Update to use llvm-project git repository. * all source files: Merge from upstream 82588e05cc32bb30807e480abd4e689b0dee132a. From-SVN: r277909 --- libsanitizer/ChangeLog | 6 + libsanitizer/MERGE | 4 +- libsanitizer/asan/asan_allocator.cpp | 28 ++- libsanitizer/asan/asan_globals.cpp | 19 ++ libsanitizer/asan/asan_interceptors.h | 7 +- libsanitizer/asan/asan_interface.inc | 1 + libsanitizer/asan/asan_interface_internal.h | 3 + libsanitizer/asan/asan_malloc_win.cpp | 3 - libsanitizer/asan/asan_mapping.h | 2 +- .../include/sanitizer/asan_interface.h | 4 + .../include/sanitizer/netbsd_syscall_hooks.h | 165 +++++++++++++----- libsanitizer/lsan/lsan_allocator.cpp | 13 +- libsanitizer/merge.sh | 7 +- .../sanitizer_common/sanitizer_flags.inc | 3 + .../sanitizer_common/sanitizer_linux.cpp | 10 +- .../sanitizer_linux_libcdep.cpp | 4 - .../sanitizer_common/sanitizer_mac.cpp | 2 +- .../sanitizer_common/sanitizer_platform.h | 8 +- .../sanitizer_platform_limits_linux.cpp | 9 +- .../sanitizer_platform_limits_netbsd.h | 6 + .../sanitizer_platform_limits_posix.cpp | 2 +- .../sanitizer_platform_limits_posix.h | 5 +- .../sanitizer_common/sanitizer_stacktrace.cpp | 17 +- .../sanitizer_syscalls_netbsd.inc | 56 ++++-- libsanitizer/tsan/tsan_mman.cpp | 15 +- libsanitizer/tsan/tsan_rtl_ppc64.S | 1 - libsanitizer/ubsan/ubsan_flags.cpp | 1 - libsanitizer/ubsan/ubsan_handlers.cpp | 15 -- libsanitizer/ubsan/ubsan_handlers.h | 8 - libsanitizer/ubsan/ubsan_platform.h | 2 - 30 files changed, 292 insertions(+), 134 deletions(-) diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index aa3bb295a29..7054bce53bc 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,9 @@ +2019-11-07 Martin Liska + + * merge.sh: Update to use llvm-project git repository. + * all source files: Merge from upstream + 82588e05cc32bb30807e480abd4e689b0dee132a. + 2019-11-05 Martin Liska * ubsan/ubsan_flags.cpp (InitializeFlags): Trunk decided to print diff --git a/libsanitizer/MERGE b/libsanitizer/MERGE index b7bf2529910..49ee2c3bab8 100644 --- a/libsanitizer/MERGE +++ b/libsanitizer/MERGE @@ -1,4 +1,4 @@ -375507 +82588e05cc32bb30807e480abd4e689b0dee132a -The first line of this file holds the svn revision number of the +The first line of this file holds the git revision number of the last merge done from the master library sources. diff --git a/libsanitizer/asan/asan_allocator.cpp b/libsanitizer/asan/asan_allocator.cpp index c9e9f5a93d0..65c51fbafdd 100644 --- a/libsanitizer/asan/asan_allocator.cpp +++ b/libsanitizer/asan/asan_allocator.cpp @@ -246,6 +246,7 @@ struct Allocator { AllocatorCache fallback_allocator_cache; QuarantineCache fallback_quarantine_cache; + uptr max_user_defined_malloc_size; atomic_uint8_t rss_limit_exceeded; // ------------------- Options -------------------------- @@ -280,6 +281,10 @@ struct Allocator { SetAllocatorMayReturnNull(options.may_return_null); allocator.InitLinkerInitialized(options.release_to_os_interval_ms); SharedInitCode(options); + max_user_defined_malloc_size = common_flags()->max_allocation_size_mb + ? common_flags()->max_allocation_size_mb + << 20 + : kMaxAllowedMallocSize; } bool RssLimitExceeded() { @@ -394,6 +399,16 @@ struct Allocator { return right_chunk; } + bool UpdateAllocationStack(uptr addr, BufferedStackTrace *stack) { + AsanChunk *m = GetAsanChunkByAddr(addr); + if (!m) return false; + if (m->chunk_state != CHUNK_ALLOCATED) return false; + if (m->Beg() != addr) return false; + atomic_store((atomic_uint32_t *)&m->alloc_context_id, StackDepotPut(*stack), + memory_order_relaxed); + return true; + } + // -------------------- Allocation/Deallocation routines --------------- void *Allocate(uptr size, uptr alignment, BufferedStackTrace *stack, AllocType alloc_type, bool can_fill) { @@ -435,14 +450,16 @@ struct Allocator { using_primary_allocator = false; } CHECK(IsAligned(needed_size, min_alignment)); - if (size > kMaxAllowedMallocSize || needed_size > kMaxAllowedMallocSize) { + if (size > kMaxAllowedMallocSize || needed_size > kMaxAllowedMallocSize || + size > max_user_defined_malloc_size) { if (AllocatorMayReturnNull()) { Report("WARNING: AddressSanitizer failed to allocate 0x%zx bytes\n", (void*)size); return nullptr; } - ReportAllocationSizeTooBig(size, needed_size, kMaxAllowedMallocSize, - stack); + uptr malloc_limit = + Min(kMaxAllowedMallocSize, max_user_defined_malloc_size); + ReportAllocationSizeTooBig(size, needed_size, malloc_limit, stack); } AsanThread *t = GetCurrentThread(); @@ -1105,6 +1122,11 @@ void __sanitizer_purge_allocator() { instance.Purge(&stack); } +int __asan_update_allocation_context(void* addr) { + GET_STACK_TRACE_MALLOC; + return instance.UpdateAllocationStack((uptr)addr, &stack); +} + #if !SANITIZER_SUPPORTS_WEAK_HOOKS // Provide default (no-op) implementation of malloc hooks. SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_malloc_hook, diff --git a/libsanitizer/asan/asan_globals.cpp b/libsanitizer/asan/asan_globals.cpp index e045c31cd1c..9d7dbc6f264 100644 --- a/libsanitizer/asan/asan_globals.cpp +++ b/libsanitizer/asan/asan_globals.cpp @@ -154,6 +154,23 @@ static void CheckODRViolationViaIndicator(const Global *g) { } } +// Check ODR violation for given global G by checking if it's already poisoned. +// We use this method in case compiler doesn't use private aliases for global +// variables. +static void CheckODRViolationViaPoisoning(const Global *g) { + if (__asan_region_is_poisoned(g->beg, g->size_with_redzone)) { + // This check may not be enough: if the first global is much larger + // the entire redzone of the second global may be within the first global. + for (ListOfGlobals *l = list_of_all_globals; l; l = l->next) { + if (g->beg == l->g->beg && + (flags()->detect_odr_violation >= 2 || g->size != l->g->size) && + !IsODRViolationSuppressed(g->name)) + ReportODRViolation(g, FindRegistrationSite(g), + l->g, FindRegistrationSite(l->g)); + } + } +} + // Clang provides two different ways for global variables protection: // it can poison the global itself or its private alias. In former // case we may poison same symbol multiple times, that can help us to @@ -199,6 +216,8 @@ static void RegisterGlobal(const Global *g) { // where two globals with the same name are defined in different modules. if (UseODRIndicator(g)) CheckODRViolationViaIndicator(g); + else + CheckODRViolationViaPoisoning(g); } if (CanPoisonMemory()) PoisonRedZones(*g); diff --git a/libsanitizer/asan/asan_interceptors.h b/libsanitizer/asan/asan_interceptors.h index b7a85fedbdf..344a64bd83d 100644 --- a/libsanitizer/asan/asan_interceptors.h +++ b/libsanitizer/asan/asan_interceptors.h @@ -80,12 +80,7 @@ void InitializePlatformInterceptors(); #if ASAN_HAS_EXCEPTIONS && !SANITIZER_WINDOWS && !SANITIZER_SOLARIS && \ !SANITIZER_NETBSD # define ASAN_INTERCEPT___CXA_THROW 1 -# if ! defined(ASAN_HAS_CXA_RETHROW_PRIMARY_EXCEPTION) \ - || ASAN_HAS_CXA_RETHROW_PRIMARY_EXCEPTION -# define ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION 1 -# else -# define ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION 0 -# endif +# define ASAN_INTERCEPT___CXA_RETHROW_PRIMARY_EXCEPTION 1 # if defined(_GLIBCXX_SJLJ_EXCEPTIONS) || (SANITIZER_IOS && defined(__arm__)) # define ASAN_INTERCEPT__UNWIND_SJLJ_RAISEEXCEPTION 1 # else diff --git a/libsanitizer/asan/asan_interface.inc b/libsanitizer/asan/asan_interface.inc index 7c341f22e15..94801043982 100644 --- a/libsanitizer/asan/asan_interface.inc +++ b/libsanitizer/asan/asan_interface.inc @@ -164,6 +164,7 @@ INTERFACE_FUNCTION(__sanitizer_unaligned_load64) INTERFACE_FUNCTION(__sanitizer_unaligned_store16) INTERFACE_FUNCTION(__sanitizer_unaligned_store32) INTERFACE_FUNCTION(__sanitizer_unaligned_store64) +INTERFACE_FUNCTION(__asan_update_allocation_context) INTERFACE_WEAK_FUNCTION(__asan_default_options) INTERFACE_WEAK_FUNCTION(__asan_default_suppressions) INTERFACE_WEAK_FUNCTION(__asan_on_error) diff --git a/libsanitizer/asan/asan_interface_internal.h b/libsanitizer/asan/asan_interface_internal.h index c83aa11d741..f14cbbcb76a 100644 --- a/libsanitizer/asan/asan_interface_internal.h +++ b/libsanitizer/asan/asan_interface_internal.h @@ -251,6 +251,9 @@ extern "C" { const char* __asan_default_suppressions(); SANITIZER_INTERFACE_ATTRIBUTE void __asan_handle_vfork(void *sp); + + SANITIZER_INTERFACE_ATTRIBUTE int __asan_update_allocation_context( + void *addr); } // extern "C" #endif // ASAN_INTERFACE_INTERNAL_H diff --git a/libsanitizer/asan/asan_malloc_win.cpp b/libsanitizer/asan/asan_malloc_win.cpp index 13c6f652119..4b76d4ebd3e 100644 --- a/libsanitizer/asan/asan_malloc_win.cpp +++ b/libsanitizer/asan/asan_malloc_win.cpp @@ -35,11 +35,8 @@ constexpr unsigned long HEAP_REALLOC_IN_PLACE_ONLY = 0x00000010; constexpr unsigned long HEAP_ALLOCATE_SUPPORTED_FLAGS = (HEAP_ZERO_MEMORY); constexpr unsigned long HEAP_ALLOCATE_UNSUPPORTED_FLAGS = (~HEAP_ALLOCATE_SUPPORTED_FLAGS); -constexpr unsigned long HEAP_FREE_SUPPORTED_FLAGS = (0); constexpr unsigned long HEAP_FREE_UNSUPPORTED_FLAGS = (~HEAP_ALLOCATE_SUPPORTED_FLAGS); -constexpr unsigned long HEAP_REALLOC_SUPPORTED_FLAGS = - (HEAP_REALLOC_IN_PLACE_ONLY | HEAP_ZERO_MEMORY); constexpr unsigned long HEAP_REALLOC_UNSUPPORTED_FLAGS = (~HEAP_ALLOCATE_SUPPORTED_FLAGS); diff --git a/libsanitizer/asan/asan_mapping.h b/libsanitizer/asan/asan_mapping.h index 09be904270c..41fb49ee46d 100644 --- a/libsanitizer/asan/asan_mapping.h +++ b/libsanitizer/asan/asan_mapping.h @@ -163,7 +163,7 @@ static const u64 kDefaultShort64bitShadowOffset = static const u64 kAArch64_ShadowOffset64 = 1ULL << 36; static const u64 kMIPS32_ShadowOffset32 = 0x0aaa0000; static const u64 kMIPS64_ShadowOffset64 = 1ULL << 37; -static const u64 kPPC64_ShadowOffset64 = 1ULL << 41; +static const u64 kPPC64_ShadowOffset64 = 1ULL << 44; static const u64 kSystemZ_ShadowOffset64 = 1ULL << 52; static const u64 kSPARC64_ShadowOffset64 = 1ULL << 43; // 0x80000000000 static const u64 kFreeBSD_ShadowOffset32 = 1ULL << 30; // 0x40000000 diff --git a/libsanitizer/include/sanitizer/asan_interface.h b/libsanitizer/include/sanitizer/asan_interface.h index ab2dc97ed24..6af93aad651 100644 --- a/libsanitizer/include/sanitizer/asan_interface.h +++ b/libsanitizer/include/sanitizer/asan_interface.h @@ -315,6 +315,10 @@ void *__asan_addr_is_in_fake_stack(void *fake_stack, void *addr, void **beg, /// functions like _exit() and execl(). void __asan_handle_no_return(void); +/// Update allocation stack trace for the given allocation to the current stack +/// trace. Returns 1 if successfull, 0 if not. +int __asan_update_allocation_context(void* addr); + #ifdef __cplusplus } // extern "C" #endif diff --git a/libsanitizer/include/sanitizer/netbsd_syscall_hooks.h b/libsanitizer/include/sanitizer/netbsd_syscall_hooks.h index 27780e0d419..174b4bf06de 100644 --- a/libsanitizer/include/sanitizer/netbsd_syscall_hooks.h +++ b/libsanitizer/include/sanitizer/netbsd_syscall_hooks.h @@ -20,8 +20,8 @@ // DO NOT EDIT! THIS FILE HAS BEEN GENERATED! // // Generated with: generate_netbsd_syscalls.awk -// Generated date: 2018-10-30 -// Generated from: syscalls.master,v 1.293 2018/07/31 13:00:13 rjs Exp +// Generated date: 2019-11-01 +// Generated from: syscalls.master,v 1.296 2019/09/22 22:59:39 christos Exp // //===----------------------------------------------------------------------===// #ifndef SANITIZER_NETBSD_SYSCALL_HOOKS_H @@ -1839,23 +1839,24 @@ #define __sanitizer_syscall_post_uuidgen(res, store, count) \ __sanitizer_syscall_post_impl_uuidgen(res, (long long)(store), \ (long long)(count)) -#define __sanitizer_syscall_pre_getvfsstat(buf, bufsize, flags) \ - __sanitizer_syscall_pre_impl_getvfsstat( \ +#define __sanitizer_syscall_pre_compat_90_getvfsstat(buf, bufsize, flags) \ + __sanitizer_syscall_pre_impl_compat_90_getvfsstat( \ (long long)(buf), (long long)(bufsize), (long long)(flags)) -#define __sanitizer_syscall_post_getvfsstat(res, buf, bufsize, flags) \ - __sanitizer_syscall_post_impl_getvfsstat( \ +#define __sanitizer_syscall_post_compat_90_getvfsstat(res, buf, bufsize, \ + flags) \ + __sanitizer_syscall_post_impl_compat_90_getvfsstat( \ res, (long long)(buf), (long long)(bufsize), (long long)(flags)) -#define __sanitizer_syscall_pre_statvfs1(path, buf, flags) \ - __sanitizer_syscall_pre_impl_statvfs1((long long)(path), (long long)(buf), \ - (long long)(flags)) -#define __sanitizer_syscall_post_statvfs1(res, path, buf, flags) \ - __sanitizer_syscall_post_impl_statvfs1(res, (long long)(path), \ - (long long)(buf), (long long)(flags)) -#define __sanitizer_syscall_pre_fstatvfs1(fd, buf, flags) \ - __sanitizer_syscall_pre_impl_fstatvfs1((long long)(fd), (long long)(buf), \ - (long long)(flags)) -#define __sanitizer_syscall_post_fstatvfs1(res, fd, buf, flags) \ - __sanitizer_syscall_post_impl_fstatvfs1( \ +#define __sanitizer_syscall_pre_compat_90_statvfs1(path, buf, flags) \ + __sanitizer_syscall_pre_impl_compat_90_statvfs1( \ + (long long)(path), (long long)(buf), (long long)(flags)) +#define __sanitizer_syscall_post_compat_90_statvfs1(res, path, buf, flags) \ + __sanitizer_syscall_post_impl_compat_90_statvfs1( \ + res, (long long)(path), (long long)(buf), (long long)(flags)) +#define __sanitizer_syscall_pre_compat_90_fstatvfs1(fd, buf, flags) \ + __sanitizer_syscall_pre_impl_compat_90_fstatvfs1( \ + (long long)(fd), (long long)(buf), (long long)(flags)) +#define __sanitizer_syscall_post_compat_90_fstatvfs1(res, fd, buf, flags) \ + __sanitizer_syscall_post_impl_compat_90_fstatvfs1( \ res, (long long)(fd), (long long)(buf), (long long)(flags)) #define __sanitizer_syscall_pre_compat_30_fhstatvfs1(fhp, buf, flags) \ __sanitizer_syscall_pre_impl_compat_30_fhstatvfs1( \ @@ -2143,12 +2144,13 @@ #define __sanitizer_syscall_post___fhopen40(res, fhp, fh_size, flags) \ __sanitizer_syscall_post_impl___fhopen40( \ res, (long long)(fhp), (long long)(fh_size), (long long)(flags)) -#define __sanitizer_syscall_pre___fhstatvfs140(fhp, fh_size, buf, flags) \ - __sanitizer_syscall_pre_impl___fhstatvfs140( \ +#define __sanitizer_syscall_pre_compat_90_fhstatvfs1(fhp, fh_size, buf, flags) \ + __sanitizer_syscall_pre_impl_compat_90_fhstatvfs1( \ (long long)(fhp), (long long)(fh_size), (long long)(buf), \ (long long)(flags)) -#define __sanitizer_syscall_post___fhstatvfs140(res, fhp, fh_size, buf, flags) \ - __sanitizer_syscall_post_impl___fhstatvfs140( \ +#define __sanitizer_syscall_post_compat_90_fhstatvfs1(res, fhp, fh_size, buf, \ + flags) \ + __sanitizer_syscall_post_impl_compat_90_fhstatvfs1( \ res, (long long)(fhp), (long long)(fh_size), (long long)(buf), \ (long long)(flags)) #define __sanitizer_syscall_pre_compat_50___fhstat40(fhp, fh_size, sb) \ @@ -2703,6 +2705,53 @@ clock_id) \ __sanitizer_syscall_post_impl_clock_getcpuclockid2( \ res, (long long)(idtype), (long long)(id), (long long)(clock_id)) +#define __sanitizer_syscall_pre___getvfsstat90(buf, bufsize, flags) \ + __sanitizer_syscall_pre_impl___getvfsstat90( \ + (long long)(buf), (long long)(bufsize), (long long)(flags)) +#define __sanitizer_syscall_post___getvfsstat90(res, buf, bufsize, flags) \ + __sanitizer_syscall_post_impl___getvfsstat90( \ + res, (long long)(buf), (long long)(bufsize), (long long)(flags)) +#define __sanitizer_syscall_pre___statvfs190(path, buf, flags) \ + __sanitizer_syscall_pre_impl___statvfs190( \ + (long long)(path), (long long)(buf), (long long)(flags)) +#define __sanitizer_syscall_post___statvfs190(res, path, buf, flags) \ + __sanitizer_syscall_post_impl___statvfs190( \ + res, (long long)(path), (long long)(buf), (long long)(flags)) +#define __sanitizer_syscall_pre___fstatvfs190(fd, buf, flags) \ + __sanitizer_syscall_pre_impl___fstatvfs190( \ + (long long)(fd), (long long)(buf), (long long)(flags)) +#define __sanitizer_syscall_post___fstatvfs190(res, fd, buf, flags) \ + __sanitizer_syscall_post_impl___fstatvfs190( \ + res, (long long)(fd), (long long)(buf), (long long)(flags)) +#define __sanitizer_syscall_pre___fhstatvfs190(fhp, fh_size, buf, flags) \ + __sanitizer_syscall_pre_impl___fhstatvfs190( \ + (long long)(fhp), (long long)(fh_size), (long long)(buf), \ + (long long)(flags)) +#define __sanitizer_syscall_post___fhstatvfs190(res, fhp, fh_size, buf, flags) \ + __sanitizer_syscall_post_impl___fhstatvfs190( \ + res, (long long)(fhp), (long long)(fh_size), (long long)(buf), \ + (long long)(flags)) + +/* Compat with older releases */ +#define __sanitizer_syscall_pre_getvfsstat \ + __sanitizer_syscall_pre_compat_90_getvfsstat +#define __sanitizer_syscall_post_getvfsstat \ + __sanitizer_syscall_post_compat_90_getvfsstat + +#define __sanitizer_syscall_pre_statvfs1 \ + __sanitizer_syscall_pre_compat_90_statvfs1 +#define __sanitizer_syscall_post_statvfs1 \ + __sanitizer_syscall_post_compat_90_statvfs1 + +#define __sanitizer_syscall_pre_fstatvfs1 \ + __sanitizer_syscall_pre_compat_90_fstatvfs1 +#define __sanitizer_syscall_post_fstatvfs1 \ + __sanitizer_syscall_post_compat_90_fstatvfs1 + +#define __sanitizer_syscall_pre___fhstatvfs140 \ + __sanitizer_syscall_pre_compat_90_fhstatvfs1 +#define __sanitizer_syscall_post___fhstatvfs140 \ + __sanitizer_syscall_post_compat_90_fhstatvfs1 #ifdef __cplusplus extern "C" { @@ -4066,19 +4115,27 @@ void __sanitizer_syscall_post_impl_fsync_range(long long res, long long fd, void __sanitizer_syscall_pre_impl_uuidgen(long long store, long long count); void __sanitizer_syscall_post_impl_uuidgen(long long res, long long store, long long count); -void __sanitizer_syscall_pre_impl_getvfsstat(long long buf, long long bufsize, - long long flags); -void __sanitizer_syscall_post_impl_getvfsstat(long long res, long long buf, - long long bufsize, - long long flags); -void __sanitizer_syscall_pre_impl_statvfs1(long long path, long long buf, - long long flags); -void __sanitizer_syscall_post_impl_statvfs1(long long res, long long path, - long long buf, long long flags); -void __sanitizer_syscall_pre_impl_fstatvfs1(long long fd, long long buf, - long long flags); -void __sanitizer_syscall_post_impl_fstatvfs1(long long res, long long fd, - long long buf, long long flags); +void __sanitizer_syscall_pre_impl_compat_90_getvfsstat(long long buf, + long long bufsize, + long long flags); +void __sanitizer_syscall_post_impl_compat_90_getvfsstat(long long res, + long long buf, + long long bufsize, + long long flags); +void __sanitizer_syscall_pre_impl_compat_90_statvfs1(long long path, + long long buf, + long long flags); +void __sanitizer_syscall_post_impl_compat_90_statvfs1(long long res, + long long path, + long long buf, + long long flags); +void __sanitizer_syscall_pre_impl_compat_90_fstatvfs1(long long fd, + long long buf, + long long flags); +void __sanitizer_syscall_post_impl_compat_90_fstatvfs1(long long res, + long long fd, + long long buf, + long long flags); void __sanitizer_syscall_pre_impl_compat_30_fhstatvfs1(long long fhp, long long buf, long long flags); @@ -4304,14 +4361,15 @@ void __sanitizer_syscall_pre_impl___fhopen40(long long fhp, long long fh_size, void __sanitizer_syscall_post_impl___fhopen40(long long res, long long fhp, long long fh_size, long long flags); -void __sanitizer_syscall_pre_impl___fhstatvfs140(long long fhp, - long long fh_size, - long long buf, - long long flags); -void __sanitizer_syscall_post_impl___fhstatvfs140(long long res, long long fhp, - long long fh_size, - long long buf, - long long flags); +void __sanitizer_syscall_pre_impl_compat_90_fhstatvfs1(long long fhp, + long long fh_size, + long long buf, + long long flags); +void __sanitizer_syscall_post_impl_compat_90_fhstatvfs1(long long res, + long long fhp, + long long fh_size, + long long buf, + long long flags); void __sanitizer_syscall_pre_impl_compat_50___fhstat40(long long fhp, long long fh_size, long long sb); @@ -4721,6 +4779,29 @@ void __sanitizer_syscall_post_impl_clock_getcpuclockid2(long long res, long long idtype, long long id, long long clock_id); +void __sanitizer_syscall_pre_impl___getvfsstat90(long long buf, + long long bufsize, + long long flags); +void __sanitizer_syscall_post_impl___getvfsstat90(long long res, long long buf, + long long bufsize, + long long flags); +void __sanitizer_syscall_pre_impl___statvfs190(long long path, long long buf, + long long flags); +void __sanitizer_syscall_post_impl___statvfs190(long long res, long long path, + long long buf, long long flags); +void __sanitizer_syscall_pre_impl___fstatvfs190(long long fd, long long buf, + long long flags); +void __sanitizer_syscall_post_impl___fstatvfs190(long long res, long long fd, + long long buf, + long long flags); +void __sanitizer_syscall_pre_impl___fhstatvfs190(long long fhp, + long long fh_size, + long long buf, + long long flags); +void __sanitizer_syscall_post_impl___fhstatvfs190(long long res, long long fhp, + long long fh_size, + long long buf, + long long flags); #ifdef __cplusplus } // extern "C" diff --git a/libsanitizer/lsan/lsan_allocator.cpp b/libsanitizer/lsan/lsan_allocator.cpp index 66a81ab350e..d86c3921395 100644 --- a/libsanitizer/lsan/lsan_allocator.cpp +++ b/libsanitizer/lsan/lsan_allocator.cpp @@ -36,10 +36,17 @@ static const uptr kMaxAllowedMallocSize = 8UL << 30; static Allocator allocator; +static uptr max_malloc_size; + void InitializeAllocator() { SetAllocatorMayReturnNull(common_flags()->allocator_may_return_null); allocator.InitLinkerInitialized( common_flags()->allocator_release_to_os_interval_ms); + if (common_flags()->max_allocation_size_mb) + max_malloc_size = Min(common_flags()->max_allocation_size_mb << 20, + kMaxAllowedMallocSize); + else + max_malloc_size = kMaxAllowedMallocSize; } void AllocatorThreadFinish() { @@ -72,14 +79,14 @@ static void *ReportAllocationSizeTooBig(uptr size, const StackTrace &stack) { Report("WARNING: LeakSanitizer failed to allocate 0x%zx bytes\n", size); return nullptr; } - ReportAllocationSizeTooBig(size, kMaxAllowedMallocSize, &stack); + ReportAllocationSizeTooBig(size, max_malloc_size, &stack); } void *Allocate(const StackTrace &stack, uptr size, uptr alignment, bool cleared) { if (size == 0) size = 1; - if (size > kMaxAllowedMallocSize) + if (size > max_malloc_size) return ReportAllocationSizeTooBig(size, stack); void *p = allocator.Allocate(GetAllocatorCache(), size, alignment); if (UNLIKELY(!p)) { @@ -117,7 +124,7 @@ void Deallocate(void *p) { void *Reallocate(const StackTrace &stack, void *p, uptr new_size, uptr alignment) { RegisterDeallocation(p); - if (new_size > kMaxAllowedMallocSize) { + if (new_size > max_malloc_size) { allocator.Deallocate(GetAllocatorCache(), p); return ReportAllocationSizeTooBig(new_size, stack); } diff --git a/libsanitizer/merge.sh b/libsanitizer/merge.sh index 2f74fbef260..dfa7bf3d196 100755 --- a/libsanitizer/merge.sh +++ b/libsanitizer/merge.sh @@ -8,13 +8,12 @@ VCS=${1:-svn} get_upstream() { rm -rf upstream - #cp -rf orig upstream - svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk upstream + git clone https://github.com/llvm/llvm-project.git upstream } get_current_rev() { cd upstream - svn info | grep Revision | grep -o '[0-9]*' + git rev-parse HEAD } list_files() { @@ -85,6 +84,6 @@ rm -rf upstream cat << EOF > MERGE $CUR_REV -The first line of this file holds the svn revision number of the +The first line of this file holds the git revision number of the last merge done from the master library sources. EOF diff --git a/libsanitizer/sanitizer_common/sanitizer_flags.inc b/libsanitizer/sanitizer_common/sanitizer_flags.inc index 7d592bdcb61..065258a5a6e 100644 --- a/libsanitizer/sanitizer_common/sanitizer_flags.inc +++ b/libsanitizer/sanitizer_common/sanitizer_flags.inc @@ -132,6 +132,9 @@ COMMON_FLAG(uptr, soft_rss_limit_mb, 0, " until the RSS goes below the soft limit." " This limit does not affect memory allocations other than" " malloc/new.") +COMMON_FLAG(uptr, max_allocation_size_mb, 0, + "If non-zero, malloc/new calls larger than this size will return " + "nullptr (or crash if allocator_may_return_null=false).") COMMON_FLAG(bool, heap_profile, false, "Experimental heap profiler, asan-only") COMMON_FLAG(s32, allocator_release_to_os_interval_ms, ((bool)SANITIZER_FUCHSIA || (bool)SANITIZER_WINDOWS) ? -1 : 5000, diff --git a/libsanitizer/sanitizer_common/sanitizer_linux.cpp b/libsanitizer/sanitizer_common/sanitizer_linux.cpp index 0b53da6c349..3807a79b1cd 100644 --- a/libsanitizer/sanitizer_common/sanitizer_linux.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_linux.cpp @@ -407,7 +407,10 @@ uptr internal_unlink(const char *path) { } uptr internal_rename(const char *oldpath, const char *newpath) { -#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS || SANITIZER_OPENBSD +#if defined(__riscv) + return internal_syscall(SYSCALL(renameat2), AT_FDCWD, (uptr)oldpath, AT_FDCWD, + (uptr)newpath, 0); +#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS || SANITIZER_OPENBSD return internal_syscall(SYSCALL(renameat), AT_FDCWD, (uptr)oldpath, AT_FDCWD, (uptr)newpath); #else @@ -1972,6 +1975,11 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) { # endif *bp = ucontext->uc_mcontext.gregs[11]; *sp = ucontext->uc_mcontext.gregs[15]; +#elif defined(__riscv) + ucontext_t *ucontext = (ucontext_t*)context; + *pc = ucontext->uc_mcontext.__gregs[REG_PC]; + *bp = ucontext->uc_mcontext.__gregs[REG_S0]; + *sp = ucontext->uc_mcontext.__gregs[REG_SP]; #else # error "Unsupported arch" #endif diff --git a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp index e09d568d802..cd503718205 100644 --- a/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cpp @@ -698,13 +698,9 @@ u32 GetNumberOfCPUs() { #elif SANITIZER_SOLARIS return sysconf(_SC_NPROCESSORS_ONLN); #else -#if defined(CPU_COUNT) cpu_set_t CPUs; CHECK_EQ(sched_getaffinity(0, sizeof(cpu_set_t), &CPUs), 0); return CPU_COUNT(&CPUs); -#else - return 1; -#endif #endif } diff --git a/libsanitizer/sanitizer_common/sanitizer_mac.cpp b/libsanitizer/sanitizer_common/sanitizer_mac.cpp index b971ad058e9..ea4bd02aa92 100644 --- a/libsanitizer/sanitizer_common/sanitizer_mac.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_mac.cpp @@ -37,7 +37,7 @@ extern char **environ; #endif -#if defined(__has_include) && __has_include() && defined(__BLOCKS__) +#if defined(__has_include) && __has_include() #define SANITIZER_OS_TRACE 1 #include #else diff --git a/libsanitizer/sanitizer_common/sanitizer_platform.h b/libsanitizer/sanitizer_common/sanitizer_platform.h index b45c975358d..c68bfa25875 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform.h @@ -255,11 +255,11 @@ #define SANITIZER_SIGN_EXTENDED_ADDRESSES 0 #endif -// The AArch64 linux port uses the canonical syscall set as mandated by -// the upstream linux community for all new ports. Other ports may still -// use legacy syscalls. +// The AArch64 and RISC-V linux ports use the canonical syscall set as +// mandated by the upstream linux community for all new ports. Other ports +// may still use legacy syscalls. #ifndef SANITIZER_USES_CANONICAL_LINUX_SYSCALLS -# if defined(__aarch64__) && SANITIZER_LINUX +# if (defined(__aarch64__) || defined(__riscv)) && SANITIZER_LINUX # define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS 1 # else # define SANITIZER_USES_CANONICAL_LINUX_SYSCALLS 0 diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp index 7c1a21d6ccb..c51327e1269 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cpp @@ -26,12 +26,9 @@ // With old kernels (and even new kernels on powerpc) asm/stat.h uses types that // are not defined anywhere in userspace headers. Fake them. This seems to work -// fine with newer headers, too. Beware that with , struct stat -// takes the form of struct stat64 on 32-bit platforms if _FILE_OFFSET_BITS=64. -// Also, for some platforms (e.g. mips) there are additional members in the -// struct stat:s. +// fine with newer headers, too. #include -#if defined(__x86_64__) +#if defined(__x86_64__) || defined(__mips__) #include #else #define ino_t __kernel_ino_t @@ -68,7 +65,7 @@ namespace __sanitizer { #if !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__aarch64__)\ && !defined(__mips__) && !defined(__s390__)\ - && !defined(__sparc__) + && !defined(__sparc__) && !defined(__riscv) COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat)); #endif diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h index 4fb3b8c0e06..419d830c69e 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.h @@ -354,7 +354,13 @@ struct __sanitizer_addrinfo { int ai_family; int ai_socktype; int ai_protocol; +#if defined(__sparc__) && defined(_LP64) + int __ai_pad0; +#endif unsigned ai_addrlen; +#if defined(__alpha__) || (defined(__i386__) && defined(_LP64)) + int __ai_pad0; +#endif char *ai_canonname; void *ai_addr; struct __sanitizer_addrinfo *ai_next; diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp index 9852e6ba787..b4f8f67b664 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp @@ -230,7 +230,7 @@ namespace __sanitizer { // has been removed from glibc 2.28. #if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \ || defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \ - || defined(__x86_64__) + || defined(__x86_64__) || (defined(__riscv) && __riscv_xlen == 64) #define SIZEOF_STRUCT_USTAT 32 #elif defined(__arm__) || defined(__i386__) || defined(__mips__) \ || defined(__powerpc__) || defined(__s390__) || defined(__sparc__) diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h index 738bc3fd721..7789bc5887a 100644 --- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h @@ -82,7 +82,7 @@ const unsigned struct_kernel_stat64_sz = 104; #elif defined(__mips__) const unsigned struct_kernel_stat_sz = SANITIZER_ANDROID ? FIRST_32_SECOND_64(104, 128) - : FIRST_32_SECOND_64(144, 216); + : FIRST_32_SECOND_64(160, 216); const unsigned struct_kernel_stat64_sz = 104; #elif defined(__s390__) && !defined(__s390x__) const unsigned struct_kernel_stat_sz = 64; @@ -98,6 +98,9 @@ const unsigned struct_kernel_stat64_sz = 144; const unsigned struct___old_kernel_stat_sz = 0; const unsigned struct_kernel_stat_sz = 64; const unsigned struct_kernel_stat64_sz = 104; +#elif defined(__riscv) && __riscv_xlen == 64 +const unsigned struct_kernel_stat_sz = 128; +const unsigned struct_kernel_stat64_sz = 104; #endif struct __sanitizer_perf_event_attr { unsigned type; diff --git a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cpp b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cpp index ce75cbe5d26..ef14fb704ee 100644 --- a/libsanitizer/sanitizer_common/sanitizer_stacktrace.cpp +++ b/libsanitizer/sanitizer_common/sanitizer_stacktrace.cpp @@ -60,8 +60,8 @@ static inline uhwptr *GetCanonicFrame(uptr bp, // Nope, this does not look right either. This means the frame after next does // not have a valid frame pointer, but we can still extract the caller PC. // Unfortunately, there is no way to decide between GCC and LLVM frame - // layouts. Assume GCC. - return bp_prev - 1; + // layouts. Assume LLVM. + return bp_prev; #else return (uhwptr*)bp; #endif @@ -84,21 +84,14 @@ void BufferedStackTrace::UnwindFast(uptr pc, uptr bp, uptr stack_top, IsAligned((uptr)frame, sizeof(*frame)) && size < max_depth) { #ifdef __powerpc__ - // PowerPC ABIs specify that the return address is saved on the - // *caller's* stack frame. Thus we must dereference the back chain - // to find the caller frame before extracting it. + // PowerPC ABIs specify that the return address is saved at offset + // 16 of the *caller's* stack frame. Thus we must dereference the + // back chain to find the caller frame before extracting it. uhwptr *caller_frame = (uhwptr*)frame[0]; if (!IsValidFrame((uptr)caller_frame, stack_top, bottom) || !IsAligned((uptr)caller_frame, sizeof(uhwptr))) break; - // For most ABIs the offset where the return address is saved is two - // register sizes. The exception is the SVR4 ABI, which uses an - // offset of only one register size. -#ifdef _CALL_SYSV - uhwptr pc1 = caller_frame[1]; -#else uhwptr pc1 = caller_frame[2]; -#endif #elif defined(__s390__) uhwptr pc1 = frame[14]; #else diff --git a/libsanitizer/sanitizer_common/sanitizer_syscalls_netbsd.inc b/libsanitizer/sanitizer_common/sanitizer_syscalls_netbsd.inc index 21b52166963..69e59871874 100644 --- a/libsanitizer/sanitizer_common/sanitizer_syscalls_netbsd.inc +++ b/libsanitizer/sanitizer_common/sanitizer_syscalls_netbsd.inc @@ -42,8 +42,8 @@ // DO NOT EDIT! THIS FILE HAS BEEN GENERATED! // // Generated with: generate_netbsd_syscalls.awk -// Generated date: 2018-10-30 -// Generated from: syscalls.master,v 1.293 2018/07/31 13:00:13 rjs Exp +// Generated date: 2019-11-01 +// Generated from: syscalls.master,v 1.296 2019/09/22 22:59:39 christos Exp // //===----------------------------------------------------------------------===// @@ -2433,30 +2433,31 @@ PRE_SYSCALL(uuidgen)(void *store_, long long count_) { /* Nothing to do */ } POST_SYSCALL(uuidgen)(long long res, void *store_, long long count_) { /* Nothing to do */ } -PRE_SYSCALL(getvfsstat)(void *buf_, long long bufsize_, long long flags_) { +PRE_SYSCALL(compat_90_getvfsstat) +(void *buf_, long long bufsize_, long long flags_) { /* Nothing to do */ } -POST_SYSCALL(getvfsstat) +POST_SYSCALL(compat_90_getvfsstat) (long long res, void *buf_, long long bufsize_, long long flags_) { /* Nothing to do */ } -PRE_SYSCALL(statvfs1)(void *path_, void *buf_, long long flags_) { +PRE_SYSCALL(compat_90_statvfs1)(void *path_, void *buf_, long long flags_) { const char *path = (const char *)path_; if (path) { PRE_READ(path, __sanitizer::internal_strlen(path) + 1); } } -POST_SYSCALL(statvfs1) +POST_SYSCALL(compat_90_statvfs1) (long long res, void *path_, void *buf_, long long flags_) { const char *path = (const char *)path_; if (path) { POST_READ(path, __sanitizer::internal_strlen(path) + 1); } } -PRE_SYSCALL(fstatvfs1)(long long fd_, void *buf_, long long flags_) { +PRE_SYSCALL(compat_90_fstatvfs1)(long long fd_, void *buf_, long long flags_) { /* Nothing to do */ } -POST_SYSCALL(fstatvfs1) +POST_SYSCALL(compat_90_fstatvfs1) (long long res, long long fd_, void *buf_, long long flags_) { /* Nothing to do */ } @@ -2853,13 +2854,13 @@ PRE_SYSCALL(__fhopen40)(void *fhp_, long long fh_size_, long long flags_) { } POST_SYSCALL(__fhopen40) (long long res, void *fhp_, long long fh_size_, long long flags_) {} -PRE_SYSCALL(__fhstatvfs140) +PRE_SYSCALL(compat_90_fhstatvfs1) (void *fhp_, long long fh_size_, void *buf_, long long flags_) { if (fhp_) { PRE_READ(fhp_, fh_size_); } } -POST_SYSCALL(__fhstatvfs140) +POST_SYSCALL(compat_90_fhstatvfs1) (long long res, void *fhp_, long long fh_size_, void *buf_, long long flags_) {} PRE_SYSCALL(compat_50___fhstat40)(void *fhp_, long long fh_size_, void *sb_) { if (fhp_) { @@ -3768,6 +3769,41 @@ POST_SYSCALL(clock_getcpuclockid2) (long long res, long long idtype_, long long id_, void *clock_id_) { /* Nothing to do */ } +PRE_SYSCALL(__getvfsstat90)(void *buf_, long long bufsize_, long long flags_) { + /* Nothing to do */ +} +POST_SYSCALL(__getvfsstat90) +(long long res, void *buf_, long long bufsize_, long long flags_) { + /* Nothing to do */ +} +PRE_SYSCALL(__statvfs190)(void *path_, void *buf_, long long flags_) { + const char *path = (const char *)path_; + if (path) { + PRE_READ(path, __sanitizer::internal_strlen(path) + 1); + } +} +POST_SYSCALL(__statvfs190) +(long long res, void *path_, void *buf_, long long flags_) { + const char *path = (const char *)path_; + if (path) { + POST_READ(path, __sanitizer::internal_strlen(path) + 1); + } +} +PRE_SYSCALL(__fstatvfs190)(long long fd_, void *buf_, long long flags_) { + /* Nothing to do */ +} +POST_SYSCALL(__fstatvfs190) +(long long res, long long fd_, void *buf_, long long flags_) { + /* Nothing to do */ +} +PRE_SYSCALL(__fhstatvfs190) +(void *fhp_, long long fh_size_, void *buf_, long long flags_) { + if (fhp_) { + PRE_READ(fhp_, fh_size_); + } +} +POST_SYSCALL(__fhstatvfs190) +(long long res, void *fhp_, long long fh_size_, void *buf_, long long flags_) {} #undef SYS_MAXSYSARGS } // extern "C" diff --git a/libsanitizer/tsan/tsan_mman.cpp b/libsanitizer/tsan/tsan_mman.cpp index 1b2c0549d39..743e67bf2f7 100644 --- a/libsanitizer/tsan/tsan_mman.cpp +++ b/libsanitizer/tsan/tsan_mman.cpp @@ -113,9 +113,16 @@ ScopedGlobalProcessor::~ScopedGlobalProcessor() { gp->mtx.Unlock(); } +static constexpr uptr kMaxAllowedMallocSize = 1ull << 40; +static uptr max_user_defined_malloc_size; + void InitializeAllocator() { SetAllocatorMayReturnNull(common_flags()->allocator_may_return_null); allocator()->Init(common_flags()->allocator_release_to_os_interval_ms); + max_user_defined_malloc_size = common_flags()->max_allocation_size_mb + ? common_flags()->max_allocation_size_mb + << 20 + : kMaxAllowedMallocSize; } void InitializeAllocatorLate() { @@ -150,15 +157,17 @@ static void SignalUnsafeCall(ThreadState *thr, uptr pc) { OutputReport(thr, rep); } -static constexpr uptr kMaxAllowedMallocSize = 1ull << 40; void *user_alloc_internal(ThreadState *thr, uptr pc, uptr sz, uptr align, bool signal) { - if (sz >= kMaxAllowedMallocSize || align >= kMaxAllowedMallocSize) { + if (sz >= kMaxAllowedMallocSize || align >= kMaxAllowedMallocSize || + sz > max_user_defined_malloc_size) { if (AllocatorMayReturnNull()) return nullptr; + uptr malloc_limit = + Min(kMaxAllowedMallocSize, max_user_defined_malloc_size); GET_STACK_TRACE_FATAL(thr, pc); - ReportAllocationSizeTooBig(sz, kMaxAllowedMallocSize, &stack); + ReportAllocationSizeTooBig(sz, malloc_limit, &stack); } void *p = allocator()->Allocate(&thr->proc()->alloc_cache, sz, align); if (UNLIKELY(!p)) { diff --git a/libsanitizer/tsan/tsan_rtl_ppc64.S b/libsanitizer/tsan/tsan_rtl_ppc64.S index 9e533a71a9c..8285e21aa1e 100644 --- a/libsanitizer/tsan/tsan_rtl_ppc64.S +++ b/libsanitizer/tsan/tsan_rtl_ppc64.S @@ -1,6 +1,5 @@ #include "tsan_ppc_regs.h" - .machine altivec .section .text .hidden __tsan_setjmp .globl _setjmp diff --git a/libsanitizer/ubsan/ubsan_flags.cpp b/libsanitizer/ubsan/ubsan_flags.cpp index 80de2a6d101..721c2273f13 100644 --- a/libsanitizer/ubsan/ubsan_flags.cpp +++ b/libsanitizer/ubsan/ubsan_flags.cpp @@ -54,7 +54,6 @@ void InitializeFlags() { { CommonFlags cf; cf.CopyFrom(*common_flags()); - cf.print_summary = false; cf.external_symbolizer_path = GetFlag("UBSAN_SYMBOLIZER_PATH"); OverrideCommonFlags(cf); } diff --git a/libsanitizer/ubsan/ubsan_handlers.cpp b/libsanitizer/ubsan/ubsan_handlers.cpp index 0ddbb50c26c..3f9da75a12a 100644 --- a/libsanitizer/ubsan/ubsan_handlers.cpp +++ b/libsanitizer/ubsan/ubsan_handlers.cpp @@ -819,21 +819,6 @@ void __ubsan_handle_cfi_bad_type(CFICheckFailData *Data, ValueHandle Vtable, } // namespace __ubsan -void __ubsan::__ubsan_handle_cfi_bad_icall(CFIBadIcallData *CallData, - ValueHandle Function) { - GET_REPORT_OPTIONS(false); - CFICheckFailData Data = {CFITCK_ICall, CallData->Loc, CallData->Type}; - handleCFIBadIcall(&Data, Function, Opts); -} - -void __ubsan::__ubsan_handle_cfi_bad_icall_abort(CFIBadIcallData *CallData, - ValueHandle Function) { - GET_REPORT_OPTIONS(true); - CFICheckFailData Data = {CFITCK_ICall, CallData->Loc, CallData->Type}; - handleCFIBadIcall(&Data, Function, Opts); - Die(); -} - void __ubsan::__ubsan_handle_cfi_check_fail(CFICheckFailData *Data, ValueHandle Value, uptr ValidVtable) { diff --git a/libsanitizer/ubsan/ubsan_handlers.h b/libsanitizer/ubsan/ubsan_handlers.h index eba1cf918fc..22ca9642238 100644 --- a/libsanitizer/ubsan/ubsan_handlers.h +++ b/libsanitizer/ubsan/ubsan_handlers.h @@ -207,20 +207,12 @@ enum CFITypeCheckKind : unsigned char { CFITCK_VMFCall, }; -struct CFIBadIcallData { - SourceLocation Loc; - const TypeDescriptor &Type; -}; - struct CFICheckFailData { CFITypeCheckKind CheckKind; SourceLocation Loc; const TypeDescriptor &Type; }; -/// \brief Handle control flow integrity failure for indirect function calls. -RECOVERABLE(cfi_bad_icall, CFIBadIcallData *Data, ValueHandle Function) - /// \brief Handle control flow integrity failures. RECOVERABLE(cfi_check_fail, CFICheckFailData *Data, ValueHandle Function, uptr VtableIsValid) diff --git a/libsanitizer/ubsan/ubsan_platform.h b/libsanitizer/ubsan/ubsan_platform.h index 58aabbe67b5..71d7fb18c9b 100644 --- a/libsanitizer/ubsan/ubsan_platform.h +++ b/libsanitizer/ubsan/ubsan_platform.h @@ -12,7 +12,6 @@ #ifndef UBSAN_PLATFORM_H #define UBSAN_PLATFORM_H -#ifndef CAN_SANITIZE_UB // Other platforms should be easy to add, and probably work as-is. #if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) || \ defined(__NetBSD__) || defined(__OpenBSD__) || \ @@ -22,6 +21,5 @@ #else # define CAN_SANITIZE_UB 0 #endif -#endif //CAN_SANITIZE_UB #endif -- 2.30.2