From 58d43607862096aeb32d72173911c9df244a30f1 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 19 Jan 2019 08:50:56 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_activation.cc | 7 +++---- lib/asan/asan_activation.h | 7 +++---- lib/asan/asan_activation_flags.inc | 7 +++---- lib/asan/asan_allocator.cc | 7 +++---- lib/asan/asan_allocator.h | 7 +++---- lib/asan/asan_debugging.cc | 7 +++---- lib/asan/asan_descriptions.cc | 7 +++---- lib/asan/asan_descriptions.h | 7 +++---- lib/asan/asan_errors.cc | 7 +++---- lib/asan/asan_errors.h | 7 +++---- lib/asan/asan_fake_stack.cc | 7 +++---- lib/asan/asan_fake_stack.h | 7 +++---- lib/asan/asan_flags.cc | 7 +++---- lib/asan/asan_flags.h | 7 +++---- lib/asan/asan_flags.inc | 7 +++---- lib/asan/asan_fuchsia.cc | 7 +++---- lib/asan/asan_globals.cc | 7 +++---- lib/asan/asan_globals_win.cc | 7 +++---- lib/asan/asan_init_version.h | 7 +++---- lib/asan/asan_interceptors.cc | 7 +++---- lib/asan/asan_interceptors.h | 7 +++---- lib/asan/asan_interceptors_memintrinsics.cc | 7 +++---- lib/asan/asan_interceptors_memintrinsics.h | 7 +++---- lib/asan/asan_interface.inc | 7 +++---- lib/asan/asan_interface_internal.h | 7 +++---- lib/asan/asan_internal.h | 7 +++---- lib/asan/asan_linux.cc | 7 +++---- lib/asan/asan_mac.cc | 7 +++---- lib/asan/asan_malloc_linux.cc | 7 +++---- lib/asan/asan_malloc_local.h | 7 +++---- lib/asan/asan_malloc_mac.cc | 7 +++---- lib/asan/asan_malloc_win.cc | 7 +++---- lib/asan/asan_mapping.h | 7 +++---- lib/asan/asan_mapping_myriad.h | 7 +++---- lib/asan/asan_memory_profile.cc | 7 +++---- lib/asan/asan_new_delete.cc | 7 +++---- lib/asan/asan_poisoning.cc | 7 +++---- lib/asan/asan_poisoning.h | 7 +++---- lib/asan/asan_posix.cc | 7 +++---- lib/asan/asan_preinit.cc | 7 +++---- lib/asan/asan_premap_shadow.cc | 7 +++---- lib/asan/asan_premap_shadow.h | 7 +++---- lib/asan/asan_report.cc | 7 +++---- lib/asan/asan_report.h | 7 +++---- lib/asan/asan_rtems.cc | 7 +++---- lib/asan/asan_rtl.cc | 7 +++---- lib/asan/asan_scariness_score.h | 7 +++---- lib/asan/asan_shadow_setup.cc | 7 +++---- lib/asan/asan_stack.cc | 7 +++---- lib/asan/asan_stack.h | 7 +++---- lib/asan/asan_stats.cc | 7 +++---- lib/asan/asan_stats.h | 7 +++---- lib/asan/asan_suppressions.cc | 7 +++---- lib/asan/asan_suppressions.h | 7 +++---- lib/asan/asan_thread.cc | 7 +++---- lib/asan/asan_thread.h | 7 +++---- lib/asan/asan_win.cc | 7 +++---- lib/asan/asan_win_dll_thunk.cc | 7 +++---- lib/asan/asan_win_dynamic_runtime_thunk.cc | 7 +++---- lib/asan/asan_win_weak_interception.cc | 7 +++---- lib/asan/scripts/asan_device_setup | 7 +++---- lib/asan/scripts/asan_symbolize.py | 7 +++---- lib/asan/tests/asan_asm_test.cc | 7 +++---- lib/asan/tests/asan_benchmarks_test.cc | 7 +++---- lib/asan/tests/asan_fake_stack_test.cc | 7 +++---- lib/asan/tests/asan_globals_test.cc | 7 +++---- lib/asan/tests/asan_interface_test.cc | 7 +++---- lib/asan/tests/asan_internal_interface_test.cc | 7 +++---- lib/asan/tests/asan_mac_test.cc | 7 +++---- lib/asan/tests/asan_mem_test.cc | 7 +++---- lib/asan/tests/asan_noinst_test.cc | 7 +++---- lib/asan/tests/asan_oob_test.cc | 7 +++---- lib/asan/tests/asan_str_test.cc | 7 +++---- lib/asan/tests/asan_test.cc | 7 +++---- lib/asan/tests/asan_test_config.h | 7 +++---- lib/asan/tests/asan_test_main.cc | 7 +++---- lib/asan/tests/asan_test_utils.h | 7 +++---- 77 files changed, 231 insertions(+), 308 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_activation.cc b/lib/asan/asan_activation.cc index d642be934..fc97cbb55 100644 --- a/lib/asan/asan_activation.cc +++ b/lib/asan/asan_activation.cc @@ -1,9 +1,8 @@ //===-- asan_activation.cc --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_activation.h b/lib/asan/asan_activation.h index d5e1ce433..93c290c2a 100644 --- a/lib/asan/asan_activation.h +++ b/lib/asan/asan_activation.h @@ -1,9 +1,8 @@ //===-- asan_activation.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_activation_flags.inc b/lib/asan/asan_activation_flags.inc index 1c66e5bb5..e0fdffc82 100644 --- a/lib/asan/asan_activation_flags.inc +++ b/lib/asan/asan_activation_flags.inc @@ -1,9 +1,8 @@ //===-- asan_activation_flags.inc -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_allocator.cc b/lib/asan/asan_allocator.cc index c0fad4fa0..64813eb4b 100644 --- a/lib/asan/asan_allocator.cc +++ b/lib/asan/asan_allocator.cc @@ -1,9 +1,8 @@ //===-- asan_allocator.cc -------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h index c9b37dc7a..339c6df01 100644 --- a/lib/asan/asan_allocator.h +++ b/lib/asan/asan_allocator.h @@ -1,9 +1,8 @@ //===-- asan_allocator.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_debugging.cc b/lib/asan/asan_debugging.cc index 7c877ded3..7052a371e 100644 --- a/lib/asan/asan_debugging.cc +++ b/lib/asan/asan_debugging.cc @@ -1,9 +1,8 @@ //===-- asan_debugging.cc -------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_descriptions.cc b/lib/asan/asan_descriptions.cc index cdb562d97..9b1217a86 100644 --- a/lib/asan/asan_descriptions.cc +++ b/lib/asan/asan_descriptions.cc @@ -1,9 +1,8 @@ //===-- asan_descriptions.cc ------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_descriptions.h b/lib/asan/asan_descriptions.h index 5c2d7662a..0226d844a 100644 --- a/lib/asan/asan_descriptions.h +++ b/lib/asan/asan_descriptions.h @@ -1,9 +1,8 @@ //===-- asan_descriptions.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_errors.cc b/lib/asan/asan_errors.cc index 0ecd30dca..6fd465d61 100644 --- a/lib/asan/asan_errors.cc +++ b/lib/asan/asan_errors.cc @@ -1,9 +1,8 @@ //===-- asan_errors.cc ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_errors.h b/lib/asan/asan_errors.h index 7ddd7e94e..9c54d0759 100644 --- a/lib/asan/asan_errors.h +++ b/lib/asan/asan_errors.h @@ -1,9 +1,8 @@ //===-- asan_errors.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_fake_stack.cc b/lib/asan/asan_fake_stack.cc index 1c6184e3c..f8e1ac4b7 100644 --- a/lib/asan/asan_fake_stack.cc +++ b/lib/asan/asan_fake_stack.cc @@ -1,9 +1,8 @@ //===-- asan_fake_stack.cc ------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_fake_stack.h b/lib/asan/asan_fake_stack.h index da9a91c23..59ba85218 100644 --- a/lib/asan/asan_fake_stack.h +++ b/lib/asan/asan_fake_stack.h @@ -1,9 +1,8 @@ //===-- asan_fake_stack.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_flags.cc b/lib/asan/asan_flags.cc index 5682ab4eb..69d2a4088 100644 --- a/lib/asan/asan_flags.cc +++ b/lib/asan/asan_flags.cc @@ -1,9 +1,8 @@ //===-- asan_flags.cc -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_flags.h b/lib/asan/asan_flags.h index 4935161c3..b55c81f07 100644 --- a/lib/asan/asan_flags.h +++ b/lib/asan/asan_flags.h @@ -1,9 +1,8 @@ //===-- asan_flags.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_flags.inc b/lib/asan/asan_flags.inc index a9c97d53b..3c30a6283 100644 --- a/lib/asan/asan_flags.inc +++ b/lib/asan/asan_flags.inc @@ -1,9 +1,8 @@ //===-- asan_flags.inc ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_fuchsia.cc b/lib/asan/asan_fuchsia.cc index 34399c923..e333b7b0f 100644 --- a/lib/asan/asan_fuchsia.cc +++ b/lib/asan/asan_fuchsia.cc @@ -1,9 +1,8 @@ //===-- asan_fuchsia.cc --------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===---------------------------------------------------------------------===// // diff --git a/lib/asan/asan_globals.cc b/lib/asan/asan_globals.cc index 146234ac6..d9c875550 100644 --- a/lib/asan/asan_globals.cc +++ b/lib/asan/asan_globals.cc @@ -1,9 +1,8 @@ //===-- asan_globals.cc ---------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_globals_win.cc b/lib/asan/asan_globals_win.cc index 0e75992bf..bdce37f70 100644 --- a/lib/asan/asan_globals_win.cc +++ b/lib/asan/asan_globals_win.cc @@ -1,9 +1,8 @@ //===-- asan_globals_win.cc -----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_init_version.h b/lib/asan/asan_init_version.h index c49fcd740..b806d794e 100644 --- a/lib/asan/asan_init_version.h +++ b/lib/asan/asan_init_version.h @@ -1,9 +1,8 @@ //===-- asan_init_version.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc index aac2bb8a6..7f2660df4 100644 --- a/lib/asan/asan_interceptors.cc +++ b/lib/asan/asan_interceptors.cc @@ -1,9 +1,8 @@ //===-- asan_interceptors.cc ----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h index 50895b167..271f373cd 100644 --- a/lib/asan/asan_interceptors.h +++ b/lib/asan/asan_interceptors.h @@ -1,9 +1,8 @@ //===-- asan_interceptors.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_interceptors_memintrinsics.cc b/lib/asan/asan_interceptors_memintrinsics.cc index 39e32cdad..e17f9ba4a 100644 --- a/lib/asan/asan_interceptors_memintrinsics.cc +++ b/lib/asan/asan_interceptors_memintrinsics.cc @@ -1,9 +1,8 @@ //===-- asan_interceptors_memintrinsics.cc --------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===---------------------------------------------------------------------===// // diff --git a/lib/asan/asan_interceptors_memintrinsics.h b/lib/asan/asan_interceptors_memintrinsics.h index a071e8f68..1fd65fe24 100644 --- a/lib/asan/asan_interceptors_memintrinsics.h +++ b/lib/asan/asan_interceptors_memintrinsics.h @@ -1,9 +1,8 @@ //===-- asan_interceptors_memintrinsics.h -----------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===---------------------------------------------------------------------===// // diff --git a/lib/asan/asan_interface.inc b/lib/asan/asan_interface.inc index e65f61722..1dd9c6301 100644 --- a/lib/asan/asan_interface.inc +++ b/lib/asan/asan_interface.inc @@ -1,9 +1,8 @@ //===-- asan_interface.inc ------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // Asan interface list. diff --git a/lib/asan/asan_interface_internal.h b/lib/asan/asan_interface_internal.h index b974c0cc4..ea8750e90 100644 --- a/lib/asan/asan_interface_internal.h +++ b/lib/asan/asan_interface_internal.h @@ -1,9 +1,8 @@ //===-- asan_interface_internal.h -------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_internal.h b/lib/asan/asan_internal.h index 57869497c..e4f771079 100644 --- a/lib/asan/asan_internal.h +++ b/lib/asan/asan_internal.h @@ -1,9 +1,8 @@ //===-- asan_internal.h -----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_linux.cc b/lib/asan/asan_linux.cc index a150b1955..f91823289 100644 --- a/lib/asan/asan_linux.cc +++ b/lib/asan/asan_linux.cc @@ -1,9 +1,8 @@ //===-- asan_linux.cc -----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_mac.cc b/lib/asan/asan_mac.cc index 17a0ec577..7bb7c2bdd 100644 --- a/lib/asan/asan_mac.cc +++ b/lib/asan/asan_mac.cc @@ -1,9 +1,8 @@ //===-- asan_mac.cc -------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_malloc_linux.cc b/lib/asan/asan_malloc_linux.cc index 0a534fe21..998a4f35f 100644 --- a/lib/asan/asan_malloc_linux.cc +++ b/lib/asan/asan_malloc_linux.cc @@ -1,9 +1,8 @@ //===-- asan_malloc_linux.cc ----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_malloc_local.h b/lib/asan/asan_malloc_local.h index 0e8de207d..65e3e5a97 100644 --- a/lib/asan/asan_malloc_local.h +++ b/lib/asan/asan_malloc_local.h @@ -1,9 +1,8 @@ //===-- asan_malloc_local.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_malloc_mac.cc b/lib/asan/asan_malloc_mac.cc index 27281f1bc..d25b3d5a1 100644 --- a/lib/asan/asan_malloc_mac.cc +++ b/lib/asan/asan_malloc_mac.cc @@ -1,9 +1,8 @@ //===-- asan_malloc_mac.cc ------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_malloc_win.cc b/lib/asan/asan_malloc_win.cc index 887936431..752976567 100644 --- a/lib/asan/asan_malloc_win.cc +++ b/lib/asan/asan_malloc_win.cc @@ -1,9 +1,8 @@ //===-- asan_malloc_win.cc ------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_mapping.h b/lib/asan/asan_mapping.h index f3696da62..c8b00299f 100644 --- a/lib/asan/asan_mapping.h +++ b/lib/asan/asan_mapping.h @@ -1,9 +1,8 @@ //===-- asan_mapping.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_mapping_myriad.h b/lib/asan/asan_mapping_myriad.h index baa3247bd..6969e3a49 100644 --- a/lib/asan/asan_mapping_myriad.h +++ b/lib/asan/asan_mapping_myriad.h @@ -1,9 +1,8 @@ //===-- asan_mapping_myriad.h -----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_memory_profile.cc b/lib/asan/asan_memory_profile.cc index 8c86d9fe4..87d874d2f 100644 --- a/lib/asan/asan_memory_profile.cc +++ b/lib/asan/asan_memory_profile.cc @@ -1,9 +1,8 @@ //===-- asan_memory_profile.cc.cc -----------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_new_delete.cc b/lib/asan/asan_new_delete.cc index e6053c1fe..8b53ac96e 100644 --- a/lib/asan/asan_new_delete.cc +++ b/lib/asan/asan_new_delete.cc @@ -1,9 +1,8 @@ //===-- asan_interceptors.cc ----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_poisoning.cc b/lib/asan/asan_poisoning.cc index 1e9c37a13..44b87c76e 100644 --- a/lib/asan/asan_poisoning.cc +++ b/lib/asan/asan_poisoning.cc @@ -1,9 +1,8 @@ //===-- asan_poisoning.cc -------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_poisoning.h b/lib/asan/asan_poisoning.h index c94794cea..ca14d11fd 100644 --- a/lib/asan/asan_poisoning.h +++ b/lib/asan/asan_poisoning.h @@ -1,9 +1,8 @@ //===-- asan_poisoning.h ----------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_posix.cc b/lib/asan/asan_posix.cc index ca99c04b3..5c5e0359a 100644 --- a/lib/asan/asan_posix.cc +++ b/lib/asan/asan_posix.cc @@ -1,9 +1,8 @@ //===-- asan_posix.cc -----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_preinit.cc b/lib/asan/asan_preinit.cc index a3986d24f..444998c44 100644 --- a/lib/asan/asan_preinit.cc +++ b/lib/asan/asan_preinit.cc @@ -1,9 +1,8 @@ //===-- asan_preinit.cc ---------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_premap_shadow.cc b/lib/asan/asan_premap_shadow.cc index 229eba99f..6e547718c 100644 --- a/lib/asan/asan_premap_shadow.cc +++ b/lib/asan/asan_premap_shadow.cc @@ -1,9 +1,8 @@ //===-- asan_premap_shadow.cc ---------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_premap_shadow.h b/lib/asan/asan_premap_shadow.h index 41acbdbbb..c9c886e8d 100644 --- a/lib/asan/asan_premap_shadow.h +++ b/lib/asan/asan_premap_shadow.h @@ -1,9 +1,8 @@ //===-- asan_mapping.h ------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc index 439712350..ad6b12e6d 100644 --- a/lib/asan/asan_report.cc +++ b/lib/asan/asan_report.cc @@ -1,9 +1,8 @@ //===-- asan_report.cc ----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_report.h b/lib/asan/asan_report.h index b0c167dda..653fc948d 100644 --- a/lib/asan/asan_report.h +++ b/lib/asan/asan_report.h @@ -1,9 +1,8 @@ //===-- asan_report.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_rtems.cc b/lib/asan/asan_rtems.cc index b48cc6a75..a76a32bda 100644 --- a/lib/asan/asan_rtems.cc +++ b/lib/asan/asan_rtems.cc @@ -1,9 +1,8 @@ //===-- asan_rtems.cc -----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index 13344f3b8..67eb1a783 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -1,9 +1,8 @@ //===-- asan_rtl.cc -------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_scariness_score.h b/lib/asan/asan_scariness_score.h index 7f095dd29..9e7ba47d8 100644 --- a/lib/asan/asan_scariness_score.h +++ b/lib/asan/asan_scariness_score.h @@ -1,9 +1,8 @@ //===-- asan_scariness_score.h ----------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_shadow_setup.cc b/lib/asan/asan_shadow_setup.cc index 083926e70..9cfa4e2bd 100644 --- a/lib/asan/asan_shadow_setup.cc +++ b/lib/asan/asan_shadow_setup.cc @@ -1,9 +1,8 @@ //===-- asan_shadow_setup.cc ----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index cf7a587fa..fe968e8e0 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -1,9 +1,8 @@ //===-- asan_stack.cc -----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_stack.h b/lib/asan/asan_stack.h index 8e9df888d..664882606 100644 --- a/lib/asan/asan_stack.h +++ b/lib/asan/asan_stack.h @@ -1,9 +1,8 @@ //===-- asan_stack.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_stats.cc b/lib/asan/asan_stats.cc index b8c68c32d..2f996ce63 100644 --- a/lib/asan/asan_stats.cc +++ b/lib/asan/asan_stats.cc @@ -1,9 +1,8 @@ //===-- asan_stats.cc -----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_stats.h b/lib/asan/asan_stats.h index 4605135e1..d6da65340 100644 --- a/lib/asan/asan_stats.h +++ b/lib/asan/asan_stats.h @@ -1,9 +1,8 @@ //===-- asan_stats.h --------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_suppressions.cc b/lib/asan/asan_suppressions.cc index ac8aa023f..118853e61 100644 --- a/lib/asan/asan_suppressions.cc +++ b/lib/asan/asan_suppressions.cc @@ -1,9 +1,8 @@ //===-- asan_suppressions.cc ----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_suppressions.h b/lib/asan/asan_suppressions.h index 5246b4b30..9bf297602 100644 --- a/lib/asan/asan_suppressions.h +++ b/lib/asan/asan_suppressions.h @@ -1,9 +1,8 @@ //===-- asan_suppressions.h -------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_thread.cc b/lib/asan/asan_thread.cc index 0895e4ce0..8a2852980 100644 --- a/lib/asan/asan_thread.cc +++ b/lib/asan/asan_thread.cc @@ -1,9 +1,8 @@ //===-- asan_thread.cc ----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h index 660919211..1e08d5771 100644 --- a/lib/asan/asan_thread.h +++ b/lib/asan/asan_thread.h @@ -1,9 +1,8 @@ //===-- asan_thread.h -------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc index 068f4a5d2..692da5823 100644 --- a/lib/asan/asan_win.cc +++ b/lib/asan/asan_win.cc @@ -1,9 +1,8 @@ //===-- asan_win.cc -------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_win_dll_thunk.cc b/lib/asan/asan_win_dll_thunk.cc index df593ab92..47b3948c5 100644 --- a/lib/asan/asan_win_dll_thunk.cc +++ b/lib/asan/asan_win_dll_thunk.cc @@ -1,9 +1,8 @@ //===-- asan_win_dll_thunk.cc ---------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_win_dynamic_runtime_thunk.cc b/lib/asan/asan_win_dynamic_runtime_thunk.cc index 416c73b23..cf4a59842 100644 --- a/lib/asan/asan_win_dynamic_runtime_thunk.cc +++ b/lib/asan/asan_win_dynamic_runtime_thunk.cc @@ -1,9 +1,8 @@ //===-- asan_win_dynamic_runtime_thunk.cc ---------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/asan_win_weak_interception.cc b/lib/asan/asan_win_weak_interception.cc index ca26f914c..19965ca47 100644 --- a/lib/asan/asan_win_weak_interception.cc +++ b/lib/asan/asan_win_weak_interception.cc @@ -1,9 +1,8 @@ //===-- asan_win_weak_interception.cc -------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // This module should be included in Address Sanitizer when it is implemented as diff --git a/lib/asan/scripts/asan_device_setup b/lib/asan/scripts/asan_device_setup index 5e679e366..041bf92e6 100755 --- a/lib/asan/scripts/asan_device_setup +++ b/lib/asan/scripts/asan_device_setup @@ -1,10 +1,9 @@ #!/bin/bash #===- lib/asan/scripts/asan_device_setup -----------------------------------===# # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # # Prepare Android device to run ASan applications. # diff --git a/lib/asan/scripts/asan_symbolize.py b/lib/asan/scripts/asan_symbolize.py index 2dbb05283..5cb42c656 100755 --- a/lib/asan/scripts/asan_symbolize.py +++ b/lib/asan/scripts/asan_symbolize.py @@ -1,10 +1,9 @@ #!/usr/bin/env python #===- lib/asan/scripts/asan_symbolize.py -----------------------------------===# # -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # #===------------------------------------------------------------------------===# import argparse diff --git a/lib/asan/tests/asan_asm_test.cc b/lib/asan/tests/asan_asm_test.cc index 91f8aacd6..a3c599f28 100644 --- a/lib/asan/tests/asan_asm_test.cc +++ b/lib/asan/tests/asan_asm_test.cc @@ -1,9 +1,8 @@ //===-- asan_asm_test.cc --------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_benchmarks_test.cc b/lib/asan/tests/asan_benchmarks_test.cc index fc522de47..9a0ed72d4 100644 --- a/lib/asan/tests/asan_benchmarks_test.cc +++ b/lib/asan/tests/asan_benchmarks_test.cc @@ -1,9 +1,8 @@ //===-- asan_benchmarks_test.cc ----------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_fake_stack_test.cc b/lib/asan/tests/asan_fake_stack_test.cc index 516142f0c..13beea8f2 100644 --- a/lib/asan/tests/asan_fake_stack_test.cc +++ b/lib/asan/tests/asan_fake_stack_test.cc @@ -1,9 +1,8 @@ //===-- asan_fake_stack_test.cc -------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_globals_test.cc b/lib/asan/tests/asan_globals_test.cc index 5042ef073..b852b6b5e 100644 --- a/lib/asan/tests/asan_globals_test.cc +++ b/lib/asan/tests/asan_globals_test.cc @@ -1,9 +1,8 @@ //===-- asan_globals_test.cc ----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_interface_test.cc b/lib/asan/tests/asan_interface_test.cc index b5c8303cb..8cbe469bf 100644 --- a/lib/asan/tests/asan_interface_test.cc +++ b/lib/asan/tests/asan_interface_test.cc @@ -1,9 +1,8 @@ //===-- asan_interface_test.cc --------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_internal_interface_test.cc b/lib/asan/tests/asan_internal_interface_test.cc index e247bb429..2d3b9c1f5 100644 --- a/lib/asan/tests/asan_internal_interface_test.cc +++ b/lib/asan/tests/asan_internal_interface_test.cc @@ -1,9 +1,8 @@ //===-- asan_internal_interface_test.cc -----------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_mac_test.cc b/lib/asan/tests/asan_mac_test.cc index dfa6d7596..14e105252 100644 --- a/lib/asan/tests/asan_mac_test.cc +++ b/lib/asan/tests/asan_mac_test.cc @@ -1,9 +1,8 @@ //===-- asan_test_mac.cc --------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_mem_test.cc b/lib/asan/tests/asan_mem_test.cc index c32088684..b4d3b16ec 100644 --- a/lib/asan/tests/asan_mem_test.cc +++ b/lib/asan/tests/asan_mem_test.cc @@ -1,9 +1,8 @@ //===-- asan_mem_test.cc --------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_noinst_test.cc b/lib/asan/tests/asan_noinst_test.cc index 3e366842c..8460abf97 100644 --- a/lib/asan/tests/asan_noinst_test.cc +++ b/lib/asan/tests/asan_noinst_test.cc @@ -1,9 +1,8 @@ //===-- asan_noinst_test.cc -----------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_oob_test.cc b/lib/asan/tests/asan_oob_test.cc index 0c6bea285..f023ca24b 100644 --- a/lib/asan/tests/asan_oob_test.cc +++ b/lib/asan/tests/asan_oob_test.cc @@ -1,9 +1,8 @@ //===-- asan_oob_test.cc --------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_str_test.cc b/lib/asan/tests/asan_str_test.cc index 5cf4e05c8..8ed451408 100644 --- a/lib/asan/tests/asan_str_test.cc +++ b/lib/asan/tests/asan_str_test.cc @@ -1,9 +1,8 @@ //=-- asan_str_test.cc ----------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_test.cc b/lib/asan/tests/asan_test.cc index 464e99f61..2795b71cd 100644 --- a/lib/asan/tests/asan_test.cc +++ b/lib/asan/tests/asan_test.cc @@ -1,9 +1,8 @@ //===-- asan_test.cc ------------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_test_config.h b/lib/asan/tests/asan_test_config.h index 8493f41ef..a0fadf8af 100644 --- a/lib/asan/tests/asan_test_config.h +++ b/lib/asan/tests/asan_test_config.h @@ -1,9 +1,8 @@ //===-- asan_test_config.h --------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_test_main.cc b/lib/asan/tests/asan_test_main.cc index 0c1b93c7f..1f94ec287 100644 --- a/lib/asan/tests/asan_test_main.cc +++ b/lib/asan/tests/asan_test_main.cc @@ -1,9 +1,8 @@ //===-- asan_test_main.cc -------------------------------------------------===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // diff --git a/lib/asan/tests/asan_test_utils.h b/lib/asan/tests/asan_test_utils.h index d7b6f82e2..2ab44855a 100644 --- a/lib/asan/tests/asan_test_utils.h +++ b/lib/asan/tests/asan_test_utils.h @@ -1,9 +1,8 @@ //===-- asan_test_utils.h ---------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // -- cgit v1.2.1 From b5b9a27a9a608336d201ca73761f838881b68bcd Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Sun, 20 Jan 2019 16:57:24 +0000 Subject: Fix bug in `AsanAllocatorASVT` (ASan) and `AllocatorASVT` (LSan) templated alias. We forgot to pass `AddressSpaceView` to the `CombinedAllocator` which meant we would always use `LocalAddressSpaceView` for the `CombinedAllocator` leading to a static_assert failing when we tried to do `AsanAllocatorASVT` or `AllocatorASVT`. rdar://problem/45284065 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351689 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_allocator.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h index 339c6df01..c8987ac9e 100644 --- a/lib/asan/asan_allocator.h +++ b/lib/asan/asan_allocator.h @@ -204,7 +204,8 @@ template using AsanAllocatorASVT = CombinedAllocator, AllocatorCacheASVT, - SecondaryAllocatorASVT>; + SecondaryAllocatorASVT, + AddressSpaceView>; using AsanAllocator = AsanAllocatorASVT; struct AsanThreadLocalMallocStorage { -- cgit v1.2.1 From 5afabe80eb2232e364dbf6c709d56f8c42c69d17 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 21 Jan 2019 01:41:01 +0000 Subject: On Darwin allow for sanitizer malloc implementations to provide a zone enumerator. This is done by defining `COMMON_MALLOC_HAS_ZONE_ENUMERATOR` to `1` and then by providing an implementation of the `mi_enumerator(...)` function. If a custom implementation isn't desired the macro is set to `0` which causes a stub version (that fails) to be used. Currently all Darwin sanitizers that have malloc implementations define this to be `0` so there is no functionality change. rdar://problem/45284065 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351711 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_malloc_mac.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/asan') diff --git a/lib/asan/asan_malloc_mac.cc b/lib/asan/asan_malloc_mac.cc index d25b3d5a1..005296241 100644 --- a/lib/asan/asan_malloc_mac.cc +++ b/lib/asan/asan_malloc_mac.cc @@ -57,6 +57,7 @@ using namespace __asan; GET_STACK_TRACE_FREE; \ ReportMacMzReallocUnknown((uptr)ptr, (uptr)zone_ptr, zone_name, &stack); #define COMMON_MALLOC_NAMESPACE __asan +#define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0 #include "sanitizer_common/sanitizer_malloc_mac.inc" -- cgit v1.2.1 From 1d5332b3bb19668257dc49b9dd5a73c129251e9b Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 21 Jan 2019 01:41:08 +0000 Subject: On Darwin add allocator address and size fields to `sanitizer_malloc_introspection_t` and initialize them to zero. We allow sanitizer implementations to perform different initialization by defining `COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT` to be `1` and providing an implementation of `mi_extra_init(...)`. We use these changes in future patches to implement malloc zone enumeration. rdar://problem/45284065 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351712 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_malloc_mac.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/asan') diff --git a/lib/asan/asan_malloc_mac.cc b/lib/asan/asan_malloc_mac.cc index 005296241..faa6c62df 100644 --- a/lib/asan/asan_malloc_mac.cc +++ b/lib/asan/asan_malloc_mac.cc @@ -58,6 +58,7 @@ using namespace __asan; ReportMacMzReallocUnknown((uptr)ptr, (uptr)zone_ptr, zone_name, &stack); #define COMMON_MALLOC_NAMESPACE __asan #define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0 +#define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 0 #include "sanitizer_common/sanitizer_malloc_mac.inc" -- cgit v1.2.1 From b93e071803f6989ae7bf419b30ecbeac14c87768 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 21 Jan 2019 01:41:12 +0000 Subject: [ASan] On Darwin record global allocator pointer and size in introspection struct. This implements `mi_extra_init(...)` for the ASan allocator on Darwin and uses the `__lsan::GetAllocatorGlobalRange(...)` function to retrieve the allocator pointer and size. rdar://problem/45284065 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@351713 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_malloc_mac.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_malloc_mac.cc b/lib/asan/asan_malloc_mac.cc index faa6c62df..06dc1c289 100644 --- a/lib/asan/asan_malloc_mac.cc +++ b/lib/asan/asan_malloc_mac.cc @@ -18,6 +18,7 @@ #include "asan_report.h" #include "asan_stack.h" #include "asan_stats.h" +#include "lsan/lsan_common.h" using namespace __asan; #define COMMON_MALLOC_ZONE_NAME "asan" @@ -58,11 +59,12 @@ using namespace __asan; ReportMacMzReallocUnknown((uptr)ptr, (uptr)zone_ptr, zone_name, &stack); #define COMMON_MALLOC_NAMESPACE __asan #define COMMON_MALLOC_HAS_ZONE_ENUMERATOR 0 -#define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 0 +#define COMMON_MALLOC_HAS_EXTRA_INTROSPECTION_INIT 1 #include "sanitizer_common/sanitizer_malloc_mac.inc" namespace COMMON_MALLOC_NAMESPACE { + bool HandleDlopenInit() { static_assert(SANITIZER_SUPPORTS_INIT_FOR_DLOPEN, "Expected SANITIZER_SUPPORTS_INIT_FOR_DLOPEN to be true"); @@ -83,4 +85,18 @@ bool HandleDlopenInit() { } } // namespace COMMON_MALLOC_NAMESPACE +namespace { + +void mi_extra_init(sanitizer_malloc_introspection_t *mi) { + uptr last_byte_plus_one = 0; + mi->allocator_ptr = 0; + // Range is [begin_ptr, end_ptr) + __lsan::GetAllocatorGlobalRange(&(mi->allocator_ptr), &last_byte_plus_one); + CHECK_NE(mi->allocator_ptr, 0); + CHECK_GT(last_byte_plus_one, mi->allocator_ptr); + mi->allocator_size = last_byte_plus_one - (mi->allocator_ptr); + CHECK_GT(mi->allocator_size, 0); +} +} // namespace + #endif -- cgit v1.2.1 From b530d99932493bed1fb29b45e980f7f36508bb5f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 7 Feb 2019 11:01:22 +0000 Subject: sanitizers: Introduce ThreadType enum Replace bool workerthread flag with ThreadType enum. This change is preparation for fiber support. [dvyukov: fixed build of sanitizer_thread_registry_test.cc] Author: yuri (Yuri Per) Reviewed in: https://reviews.llvm.org/D57839 Context: https://reviews.llvm.org/D54889 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@353390 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_fuchsia.cc | 2 +- lib/asan/asan_mac.cc | 4 ++-- lib/asan/asan_rtems.cc | 4 ++-- lib/asan/asan_thread.cc | 3 +-- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_fuchsia.cc b/lib/asan/asan_fuchsia.cc index e333b7b0f..aebc17f38 100644 --- a/lib/asan/asan_fuchsia.cc +++ b/lib/asan/asan_fuchsia.cc @@ -178,7 +178,7 @@ static void ThreadStartHook(void *hook, uptr os_id) { SetCurrentThread(thread); // In lieu of AsanThread::ThreadStart. - asanThreadRegistry().StartThread(thread->tid(), os_id, /*workerthread*/ false, + asanThreadRegistry().StartThread(thread->tid(), os_id, ThreadType::Regular, nullptr); } diff --git a/lib/asan/asan_mac.cc b/lib/asan/asan_mac.cc index 7bb7c2bdd..e776acd2f 100644 --- a/lib/asan/asan_mac.cc +++ b/lib/asan/asan_mac.cc @@ -181,8 +181,8 @@ void asan_register_worker_thread(int parent_tid, StackTrace *stack) { t = AsanThread::Create(/* start_routine */ nullptr, /* arg */ nullptr, parent_tid, stack, /* detached */ true); t->Init(); - asanThreadRegistry().StartThread(t->tid(), GetTid(), - /* workerthread */ true, 0); + asanThreadRegistry().StartThread(t->tid(), GetTid(), ThreadType::Worker, + nullptr); SetCurrentThread(t); } } diff --git a/lib/asan/asan_rtems.cc b/lib/asan/asan_rtems.cc index a76a32bda..4878f4d67 100644 --- a/lib/asan/asan_rtems.cc +++ b/lib/asan/asan_rtems.cc @@ -183,8 +183,8 @@ static void ThreadStartHook(void *hook, uptr os_id) { // Determine whether we are starting or restarting the thread. if (status == ThreadStatusCreated) // In lieu of AsanThread::ThreadStart. - asanThreadRegistry().StartThread(thread->tid(), os_id, - /*workerthread*/ false, nullptr); + asanThreadRegistry().StartThread(thread->tid(), os_id, ThreadType::Regular, + nullptr); else { // In a thread restart, a thread may resume execution at an // arbitrary function entry point, with its stack and TLS state diff --git a/lib/asan/asan_thread.cc b/lib/asan/asan_thread.cc index 8a2852980..e63561c22 100644 --- a/lib/asan/asan_thread.cc +++ b/lib/asan/asan_thread.cc @@ -245,8 +245,7 @@ void AsanThread::Init(const InitOptions *options) { thread_return_t AsanThread::ThreadStart( tid_t os_id, atomic_uintptr_t *signal_thread_is_registered) { Init(); - asanThreadRegistry().StartThread(tid(), os_id, /*workerthread*/ false, - nullptr); + asanThreadRegistry().StartThread(tid(), os_id, ThreadType::Regular, nullptr); if (signal_thread_is_registered) atomic_store(signal_thread_is_registered, 1, memory_order_release); -- cgit v1.2.1 From 3a8f865f1a8407e11e305fae69cc833227f64ef8 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Fri, 15 Feb 2019 14:30:18 +0000 Subject: [compiler-rt] Cleanup usage of C++ ABI library Add missed value "libcxxabi" and introduce SANITIZER_TEST_CXX for linking unit tests. This needs to be a full C++ library and cannot be libcxxabi. Differential Revision: https://reviews.llvm.org/D58012 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354132 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/asan') diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 726da27d0..51bda0524 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -92,7 +92,7 @@ append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC -ftls-model=initial-exec ASAN_DYNAMIC_CFLAGS) append_list_if(MSVC /DEBUG ASAN_DYNAMIC_LINK_FLAGS) -set(ASAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY} ${SANITIZER_COMMON_LINK_LIBS}) +set(ASAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARIES} ${SANITIZER_COMMON_LINK_LIBS}) append_list_if(COMPILER_RT_HAS_LIBDL dl ASAN_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBRT rt ASAN_DYNAMIC_LIBS) -- cgit v1.2.1 From 2bc86f57b732cdec6b72879adb88faac88346a28 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Fri, 15 Feb 2019 18:25:26 +0000 Subject: Revert "[compiler-rt] Cleanup usage of C++ ABI library" This reverts r354132 because it breaks sanitizer-x86_64-linux: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/19915 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354153 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/asan') diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 51bda0524..726da27d0 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -92,7 +92,7 @@ append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC -ftls-model=initial-exec ASAN_DYNAMIC_CFLAGS) append_list_if(MSVC /DEBUG ASAN_DYNAMIC_LINK_FLAGS) -set(ASAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARIES} ${SANITIZER_COMMON_LINK_LIBS}) +set(ASAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY} ${SANITIZER_COMMON_LINK_LIBS}) append_list_if(COMPILER_RT_HAS_LIBDL dl ASAN_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBRT rt ASAN_DYNAMIC_LIBS) -- cgit v1.2.1 From 3b34e7c533ea8837a1e11e14131edeb565a9a562 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Sat, 16 Feb 2019 08:34:26 +0000 Subject: [compiler-rt] Cleanup usage of C++ ABI library Add missed value "libcxxabi" and introduce SANITIZER_TEST_CXX for linking unit tests. This needs to be a full C++ library and cannot be libcxxabi. Recommit r354132 which I reverted in r354153 because it broke a sanitizer bot. This was because of the "fixes" for pthread linking, so I've removed these changes. Differential Revision: https://reviews.llvm.org/D58012 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354198 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/asan') diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 726da27d0..51bda0524 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -92,7 +92,7 @@ append_list_if(COMPILER_RT_HAS_FTLS_MODEL_INITIAL_EXEC -ftls-model=initial-exec ASAN_DYNAMIC_CFLAGS) append_list_if(MSVC /DEBUG ASAN_DYNAMIC_LINK_FLAGS) -set(ASAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARY} ${SANITIZER_COMMON_LINK_LIBS}) +set(ASAN_DYNAMIC_LIBS ${SANITIZER_CXX_ABI_LIBRARIES} ${SANITIZER_COMMON_LINK_LIBS}) append_list_if(COMPILER_RT_HAS_LIBDL dl ASAN_DYNAMIC_LIBS) append_list_if(COMPILER_RT_HAS_LIBRT rt ASAN_DYNAMIC_LIBS) -- cgit v1.2.1 From 806f4749b8116d9ad554e723779e3fcfa8761b74 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Thu, 21 Feb 2019 21:32:24 +0000 Subject: [hwasan,asan] Intercept vfork. Summary: AArch64 only for now. Reviewers: vitalybuka, pcc Subscribers: srhines, kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, jdoerfert, #sanitizers, llvm-commits, kcc Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58313 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354625 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/CMakeLists.txt | 1 + lib/asan/asan_interceptors.cc | 4 ++++ lib/asan/asan_interceptors_vfork.S | 7 +++++++ lib/asan/asan_interface.inc | 2 ++ lib/asan/asan_interface_internal.h | 3 +++ lib/asan/asan_rtl.cc | 15 +++++++++++++++ lib/asan/asan_thread.h | 3 +++ 7 files changed, 35 insertions(+) create mode 100644 lib/asan/asan_interceptors_vfork.S (limited to 'lib/asan') diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 51bda0524..0cf6888a1 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -13,6 +13,7 @@ set(ASAN_SOURCES asan_globals_win.cc asan_interceptors.cc asan_interceptors_memintrinsics.cc + asan_interceptors_vfork.S asan_linux.cc asan_mac.cc asan_malloc_linux.cc diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc index 7f2660df4..e59679bec 100644 --- a/lib/asan/asan_interceptors.cc +++ b/lib/asan/asan_interceptors.cc @@ -579,6 +579,8 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg, } #endif // ASAN_INTERCEPT___CXA_ATEXIT +DEFINE_REAL(void, vfork); + // ---------------------- InitializeAsanInterceptors ---------------- {{{1 namespace __asan { void InitializeAsanInterceptors() { @@ -656,6 +658,8 @@ void InitializeAsanInterceptors() { ASAN_INTERCEPT_FUNC(__cxa_atexit); #endif + __interception::GetRealFunctionAddress("vfork", (uptr *)&REAL(vfork), 0, 0); + InitializePlatformInterceptors(); VReport(1, "AddressSanitizer: libc interceptors initialized\n"); diff --git a/lib/asan/asan_interceptors_vfork.S b/lib/asan/asan_interceptors_vfork.S new file mode 100644 index 000000000..7f4d8c688 --- /dev/null +++ b/lib/asan/asan_interceptors_vfork.S @@ -0,0 +1,7 @@ +#define COMMON_INTERCEPTOR_SPILL_AREA __asan_extra_spill_area +#define COMMON_INTERCEPTOR_HANDLE_VFORK __asan_handle_vfork +#include "sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S" + +#if defined(__linux__) +.section .note.GNU-stack,"",@progbits +#endif diff --git a/lib/asan/asan_interface.inc b/lib/asan/asan_interface.inc index 1dd9c6301..99f1db493 100644 --- a/lib/asan/asan_interface.inc +++ b/lib/asan/asan_interface.inc @@ -26,6 +26,7 @@ INTERFACE_FUNCTION(__asan_exp_store4) INTERFACE_FUNCTION(__asan_exp_store8) INTERFACE_FUNCTION(__asan_exp_store16) INTERFACE_FUNCTION(__asan_exp_storeN) +INTERFACE_FUNCTION(__asan_extra_spill_area) INTERFACE_FUNCTION(__asan_get_alloc_stack) INTERFACE_FUNCTION(__asan_get_current_fake_stack) INTERFACE_FUNCTION(__asan_get_free_stack) @@ -38,6 +39,7 @@ INTERFACE_FUNCTION(__asan_get_report_pc) INTERFACE_FUNCTION(__asan_get_report_sp) INTERFACE_FUNCTION(__asan_get_shadow_mapping) INTERFACE_FUNCTION(__asan_handle_no_return) +INTERFACE_FUNCTION(__asan_handle_vfork) INTERFACE_FUNCTION(__asan_init) INTERFACE_FUNCTION(__asan_load_cxx_array_cookie) INTERFACE_FUNCTION(__asan_load1) diff --git a/lib/asan/asan_interface_internal.h b/lib/asan/asan_interface_internal.h index ea8750e90..59163a332 100644 --- a/lib/asan/asan_interface_internal.h +++ b/lib/asan/asan_interface_internal.h @@ -249,6 +249,9 @@ extern "C" { SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const char* __asan_default_suppressions(); + + SANITIZER_INTERFACE_ATTRIBUTE void *__asan_extra_spill_area(); + SANITIZER_INTERFACE_ATTRIBUTE void __asan_handle_vfork(void *sp); } // extern "C" #endif // ASAN_INTERFACE_INTERNAL_H diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index 67eb1a783..f68373809 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -597,6 +597,21 @@ void NOINLINE __asan_handle_no_return() { curr_thread->fake_stack()->HandleNoReturn(); } +void *__asan_extra_spill_area() { + AsanThread *t = GetCurrentThread(); + CHECK(t); + return t->extra_spill_area(); +} + +void __asan_handle_vfork(void *sp) { + AsanThread *t = GetCurrentThread(); + CHECK(t); + uptr PageSize = GetPageSizeCached(); + uptr top = t->stack_top(); + uptr bottom = ((uptr)sp - PageSize) & ~(PageSize - 1); + PoisonShadow(bottom, top - bottom, 0); +} + void NOINLINE __asan_set_death_callback(void (*callback)(void)) { SetUserDieCallback(callback); } diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h index 1e08d5771..5a6010e85 100644 --- a/lib/asan/asan_thread.h +++ b/lib/asan/asan_thread.h @@ -130,6 +130,8 @@ class AsanThread { AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; } AsanStats &stats() { return stats_; } + void *extra_spill_area() { return &extra_spill_area_; } + private: // NOTE: There is no AsanThread constructor. It is allocated // via mmap() and *must* be valid in zero-initialized state. @@ -165,6 +167,7 @@ class AsanThread { AsanThreadLocalMallocStorage malloc_storage_; AsanStats stats_; bool unwinding_; + uptr extra_spill_area_; }; // ScopedUnwinding is a scope for stacktracing member of a context -- cgit v1.2.1 From 0733cd3710e924eb8452338480e27db71c35910f Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Thu, 21 Feb 2019 21:55:06 +0000 Subject: [asan] Fix vfork handling. __asan_handle_vfork was unpoisoning the wrong part of the stack. Adjust the test to catch this reliably (current failure is non-deterministic). git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354627 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_rtl.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index f68373809..f5ebef3c8 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -606,10 +606,8 @@ void *__asan_extra_spill_area() { void __asan_handle_vfork(void *sp) { AsanThread *t = GetCurrentThread(); CHECK(t); - uptr PageSize = GetPageSizeCached(); - uptr top = t->stack_top(); - uptr bottom = ((uptr)sp - PageSize) & ~(PageSize - 1); - PoisonShadow(bottom, top - bottom, 0); + uptr bottom = t->stack_bottom(); + PoisonShadow(bottom, (uptr)sp - bottom, 0); } void NOINLINE __asan_set_death_callback(void (*callback)(void)) { -- cgit v1.2.1 From 748f97f86ca8e5ce660be440ddee30d93e8f87c8 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Thu, 21 Feb 2019 22:02:24 +0000 Subject: Revert "[asan] Fix vfork handling.", +1 Revert r354625, r354627 - multiple build failures. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354629 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/CMakeLists.txt | 1 - lib/asan/asan_interceptors.cc | 4 ---- lib/asan/asan_interceptors_vfork.S | 7 ------- lib/asan/asan_interface.inc | 2 -- lib/asan/asan_interface_internal.h | 3 --- lib/asan/asan_rtl.cc | 13 ------------- lib/asan/asan_thread.h | 3 --- 7 files changed, 33 deletions(-) delete mode 100644 lib/asan/asan_interceptors_vfork.S (limited to 'lib/asan') diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 0cf6888a1..51bda0524 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -13,7 +13,6 @@ set(ASAN_SOURCES asan_globals_win.cc asan_interceptors.cc asan_interceptors_memintrinsics.cc - asan_interceptors_vfork.S asan_linux.cc asan_mac.cc asan_malloc_linux.cc diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc index e59679bec..7f2660df4 100644 --- a/lib/asan/asan_interceptors.cc +++ b/lib/asan/asan_interceptors.cc @@ -579,8 +579,6 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg, } #endif // ASAN_INTERCEPT___CXA_ATEXIT -DEFINE_REAL(void, vfork); - // ---------------------- InitializeAsanInterceptors ---------------- {{{1 namespace __asan { void InitializeAsanInterceptors() { @@ -658,8 +656,6 @@ void InitializeAsanInterceptors() { ASAN_INTERCEPT_FUNC(__cxa_atexit); #endif - __interception::GetRealFunctionAddress("vfork", (uptr *)&REAL(vfork), 0, 0); - InitializePlatformInterceptors(); VReport(1, "AddressSanitizer: libc interceptors initialized\n"); diff --git a/lib/asan/asan_interceptors_vfork.S b/lib/asan/asan_interceptors_vfork.S deleted file mode 100644 index 7f4d8c688..000000000 --- a/lib/asan/asan_interceptors_vfork.S +++ /dev/null @@ -1,7 +0,0 @@ -#define COMMON_INTERCEPTOR_SPILL_AREA __asan_extra_spill_area -#define COMMON_INTERCEPTOR_HANDLE_VFORK __asan_handle_vfork -#include "sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S" - -#if defined(__linux__) -.section .note.GNU-stack,"",@progbits -#endif diff --git a/lib/asan/asan_interface.inc b/lib/asan/asan_interface.inc index 99f1db493..1dd9c6301 100644 --- a/lib/asan/asan_interface.inc +++ b/lib/asan/asan_interface.inc @@ -26,7 +26,6 @@ INTERFACE_FUNCTION(__asan_exp_store4) INTERFACE_FUNCTION(__asan_exp_store8) INTERFACE_FUNCTION(__asan_exp_store16) INTERFACE_FUNCTION(__asan_exp_storeN) -INTERFACE_FUNCTION(__asan_extra_spill_area) INTERFACE_FUNCTION(__asan_get_alloc_stack) INTERFACE_FUNCTION(__asan_get_current_fake_stack) INTERFACE_FUNCTION(__asan_get_free_stack) @@ -39,7 +38,6 @@ INTERFACE_FUNCTION(__asan_get_report_pc) INTERFACE_FUNCTION(__asan_get_report_sp) INTERFACE_FUNCTION(__asan_get_shadow_mapping) INTERFACE_FUNCTION(__asan_handle_no_return) -INTERFACE_FUNCTION(__asan_handle_vfork) INTERFACE_FUNCTION(__asan_init) INTERFACE_FUNCTION(__asan_load_cxx_array_cookie) INTERFACE_FUNCTION(__asan_load1) diff --git a/lib/asan/asan_interface_internal.h b/lib/asan/asan_interface_internal.h index 59163a332..ea8750e90 100644 --- a/lib/asan/asan_interface_internal.h +++ b/lib/asan/asan_interface_internal.h @@ -249,9 +249,6 @@ extern "C" { SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const char* __asan_default_suppressions(); - - SANITIZER_INTERFACE_ATTRIBUTE void *__asan_extra_spill_area(); - SANITIZER_INTERFACE_ATTRIBUTE void __asan_handle_vfork(void *sp); } // extern "C" #endif // ASAN_INTERFACE_INTERNAL_H diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index f5ebef3c8..67eb1a783 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -597,19 +597,6 @@ void NOINLINE __asan_handle_no_return() { curr_thread->fake_stack()->HandleNoReturn(); } -void *__asan_extra_spill_area() { - AsanThread *t = GetCurrentThread(); - CHECK(t); - return t->extra_spill_area(); -} - -void __asan_handle_vfork(void *sp) { - AsanThread *t = GetCurrentThread(); - CHECK(t); - uptr bottom = t->stack_bottom(); - PoisonShadow(bottom, (uptr)sp - bottom, 0); -} - void NOINLINE __asan_set_death_callback(void (*callback)(void)) { SetUserDieCallback(callback); } diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h index 5a6010e85..1e08d5771 100644 --- a/lib/asan/asan_thread.h +++ b/lib/asan/asan_thread.h @@ -130,8 +130,6 @@ class AsanThread { AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; } AsanStats &stats() { return stats_; } - void *extra_spill_area() { return &extra_spill_area_; } - private: // NOTE: There is no AsanThread constructor. It is allocated // via mmap() and *must* be valid in zero-initialized state. @@ -167,7 +165,6 @@ class AsanThread { AsanThreadLocalMallocStorage malloc_storage_; AsanStats stats_; bool unwinding_; - uptr extra_spill_area_; }; // ScopedUnwinding is a scope for stacktracing member of a context -- cgit v1.2.1 From 3ad5c29b75c27873d4d27100e9db031407f251eb Mon Sep 17 00:00:00 2001 From: David Major Date: Tue, 26 Feb 2019 01:35:48 +0000 Subject: [winasan] Unpoison stack memory when threads exit (redux) This is a second attempt at r342652 using a TLS callback instead of an interceptor. In long-running builds we've seen some ASan complaints during thread creation that we suspect are due to leftover poisoning from previous threads whose stacks occupied that memory. This patch adds a callback that unpoisons the stack memory when a thread exits. Differential Revision: https://reviews.llvm.org/D58641 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354836 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_win.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/asan') diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc index 692da5823..3eee845ee 100644 --- a/lib/asan/asan_win.cc +++ b/lib/asan/asan_win.cc @@ -354,6 +354,19 @@ __declspec(allocate(".CRT$XLAB")) void (NTAPI *__asan_tls_init)(void *, unsigned long, void *) = asan_thread_init; #endif +static void NTAPI asan_thread_exit(void *module, DWORD reason, void *reserved) { + if (reason == DLL_THREAD_DETACH) { + // Unpoison the thread's stack because the memory may be re-used. + NT_TIB *tib = (NT_TIB *)NtCurrentTeb(); + uptr stackSize = (uptr)tib->StackBase - (uptr)tib->StackLimit; + __asan_unpoison_memory_region(tib->StackLimit, stackSize); + } +} + +#pragma section(".CRT$XLY", long, read) // NOLINT +__declspec(allocate(".CRT$XLY")) void (NTAPI *__asan_tls_exit)(void *, + unsigned long, void *) = asan_thread_exit; + WIN_FORCE_LINK(__asan_dso_reg_hook) // }}} -- cgit v1.2.1 From b9d79a0d9c8b36d590ab50544cf4389fd21ac281 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Tue, 26 Feb 2019 07:43:01 +0000 Subject: [compiler-rt] Intercept the bcmp() function. Summary: I have not introduced a separate hook for `bcmp()` as I don't think there should be any reason for a sanitizer to treat it differently from `memcmp()`. This is only enabled when building on POSIX with GNU extensions. Context: this is to avoid losing coverage when emitting `bcmp() == 0` instead of `memcmp() == 0` in llvm, see https://reviews.llvm.org/D56593. Reviewers: mgorny, krytarowski, vitalybuka, dvyukov Subscribers: kubamracek, dberris, delcypher, jdoerfert, #sanitizers, llvm-commits, jyknight Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D58379 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354851 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/tests/asan_mem_test.cc | 42 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/tests/asan_mem_test.cc b/lib/asan/tests/asan_mem_test.cc index b4d3b16ec..10b215599 100644 --- a/lib/asan/tests/asan_mem_test.cc +++ b/lib/asan/tests/asan_mem_test.cc @@ -9,7 +9,11 @@ // This file is a part of AddressSanitizer, an address sanity checker. // //===----------------------------------------------------------------------===// +#include #include "asan_test_utils.h" +#if defined(_GNU_SOURCE) +#include // for bcmp +#endif #include template @@ -205,37 +209,43 @@ TEST(AddressSanitizer, MemMoveOOBTest) { MemTransferOOBTestTemplate(1024); } - -TEST(AddressSanitizer, MemCmpOOBTest) { +template +void CmpOOBTestCommon() { size_t size = Ident(100); char *s1 = MallocAndMemsetString(size); char *s2 = MallocAndMemsetString(size); - // Normal memcmp calls. - Ident(memcmp(s1, s2, size)); - Ident(memcmp(s1 + size - 1, s2 + size - 1, 1)); - Ident(memcmp(s1 - 1, s2 - 1, 0)); + // Normal cmpfn calls. + Ident(cmpfn(s1, s2, size)); + Ident(cmpfn(s1 + size - 1, s2 + size - 1, 1)); + Ident(cmpfn(s1 - 1, s2 - 1, 0)); // One of arguments points to not allocated memory. - EXPECT_DEATH(Ident(memcmp)(s1 - 1, s2, 1), LeftOOBReadMessage(1)); - EXPECT_DEATH(Ident(memcmp)(s1, s2 - 1, 1), LeftOOBReadMessage(1)); - EXPECT_DEATH(Ident(memcmp)(s1 + size, s2, 1), RightOOBReadMessage(0)); - EXPECT_DEATH(Ident(memcmp)(s1, s2 + size, 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1 - 1, s2, 1), LeftOOBReadMessage(1)); + EXPECT_DEATH(Ident(cmpfn)(s1, s2 - 1, 1), LeftOOBReadMessage(1)); + EXPECT_DEATH(Ident(cmpfn)(s1 + size, s2, 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1, s2 + size, 1), RightOOBReadMessage(0)); // Hit unallocated memory and die. - EXPECT_DEATH(Ident(memcmp)(s1 + 1, s2 + 1, size), RightOOBReadMessage(0)); - EXPECT_DEATH(Ident(memcmp)(s1 + size - 1, s2, 2), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1 + 1, s2 + 1, size), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1 + size - 1, s2, 2), RightOOBReadMessage(0)); // Zero bytes are not terminators and don't prevent from OOB. s1[size - 1] = '\0'; s2[size - 1] = '\0'; - EXPECT_DEATH(Ident(memcmp)(s1, s2, size + 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1, s2, size + 1), RightOOBReadMessage(0)); // Even if the buffers differ in the first byte, we still assume that - // memcmp may access the whole buffer and thus reporting the overflow here: + // cmpfn may access the whole buffer and thus reporting the overflow here: s1[0] = 1; s2[0] = 123; - EXPECT_DEATH(Ident(memcmp)(s1, s2, size + 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1, s2, size + 1), RightOOBReadMessage(0)); free(s1); free(s2); } +TEST(AddressSanitizer, MemCmpOOBTest) { CmpOOBTestCommon(); } - +TEST(AddressSanitizer, BCmpOOBTest) { +#if defined(_GNU_SOURCE) || defined(__NetBSD__) || defined(__FreeBSD__) || \ + defined(__OpenBSD__) + CmpOOBTestCommon(); +#endif +} -- cgit v1.2.1 From addcbe40d6743d0c4b807580fdbd867c59058f2e Mon Sep 17 00:00:00 2001 From: Vlad Tsyrklevich Date: Tue, 26 Feb 2019 18:28:15 +0000 Subject: Revert "[compiler-rt] Intercept the bcmp() function." This reverts commits r354851, 354852, 354853 and r354888. They were causing build failures on the android sanitizer bot. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354906 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/tests/asan_mem_test.cc | 42 ++++++++++++++++------------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/tests/asan_mem_test.cc b/lib/asan/tests/asan_mem_test.cc index 10b215599..b4d3b16ec 100644 --- a/lib/asan/tests/asan_mem_test.cc +++ b/lib/asan/tests/asan_mem_test.cc @@ -9,11 +9,7 @@ // This file is a part of AddressSanitizer, an address sanity checker. // //===----------------------------------------------------------------------===// -#include #include "asan_test_utils.h" -#if defined(_GNU_SOURCE) -#include // for bcmp -#endif #include template @@ -209,43 +205,37 @@ TEST(AddressSanitizer, MemMoveOOBTest) { MemTransferOOBTestTemplate(1024); } -template -void CmpOOBTestCommon() { + +TEST(AddressSanitizer, MemCmpOOBTest) { size_t size = Ident(100); char *s1 = MallocAndMemsetString(size); char *s2 = MallocAndMemsetString(size); - // Normal cmpfn calls. - Ident(cmpfn(s1, s2, size)); - Ident(cmpfn(s1 + size - 1, s2 + size - 1, 1)); - Ident(cmpfn(s1 - 1, s2 - 1, 0)); + // Normal memcmp calls. + Ident(memcmp(s1, s2, size)); + Ident(memcmp(s1 + size - 1, s2 + size - 1, 1)); + Ident(memcmp(s1 - 1, s2 - 1, 0)); // One of arguments points to not allocated memory. - EXPECT_DEATH(Ident(cmpfn)(s1 - 1, s2, 1), LeftOOBReadMessage(1)); - EXPECT_DEATH(Ident(cmpfn)(s1, s2 - 1, 1), LeftOOBReadMessage(1)); - EXPECT_DEATH(Ident(cmpfn)(s1 + size, s2, 1), RightOOBReadMessage(0)); - EXPECT_DEATH(Ident(cmpfn)(s1, s2 + size, 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(memcmp)(s1 - 1, s2, 1), LeftOOBReadMessage(1)); + EXPECT_DEATH(Ident(memcmp)(s1, s2 - 1, 1), LeftOOBReadMessage(1)); + EXPECT_DEATH(Ident(memcmp)(s1 + size, s2, 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(memcmp)(s1, s2 + size, 1), RightOOBReadMessage(0)); // Hit unallocated memory and die. - EXPECT_DEATH(Ident(cmpfn)(s1 + 1, s2 + 1, size), RightOOBReadMessage(0)); - EXPECT_DEATH(Ident(cmpfn)(s1 + size - 1, s2, 2), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(memcmp)(s1 + 1, s2 + 1, size), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(memcmp)(s1 + size - 1, s2, 2), RightOOBReadMessage(0)); // Zero bytes are not terminators and don't prevent from OOB. s1[size - 1] = '\0'; s2[size - 1] = '\0'; - EXPECT_DEATH(Ident(cmpfn)(s1, s2, size + 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(memcmp)(s1, s2, size + 1), RightOOBReadMessage(0)); // Even if the buffers differ in the first byte, we still assume that - // cmpfn may access the whole buffer and thus reporting the overflow here: + // memcmp may access the whole buffer and thus reporting the overflow here: s1[0] = 1; s2[0] = 123; - EXPECT_DEATH(Ident(cmpfn)(s1, s2, size + 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(memcmp)(s1, s2, size + 1), RightOOBReadMessage(0)); free(s1); free(s2); } -TEST(AddressSanitizer, MemCmpOOBTest) { CmpOOBTestCommon(); } -TEST(AddressSanitizer, BCmpOOBTest) { -#if defined(_GNU_SOURCE) || defined(__NetBSD__) || defined(__FreeBSD__) || \ - defined(__OpenBSD__) - CmpOOBTestCommon(); -#endif -} + -- cgit v1.2.1 From 25b31f2fe50d4c43dc125ffb4622db1511f87a6d Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Wed, 27 Feb 2019 20:01:04 +0000 Subject: [NFC][Sanitizer] Hard-code fast/slow unwinder at call site Also assert that the caller always gets what it requested. This purely mechanical change simplifies future refactorings and eventual removal of BufferedStackTrace::Unwind. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58557 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355022 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.h b/lib/asan/asan_stack.h index 664882606..81cc5a922 100644 --- a/lib/asan/asan_stack.h +++ b/lib/asan/asan_stack.h @@ -33,7 +33,7 @@ ALWAYS_INLINE void GetStackTrace(BufferedStackTrace *stack, uptr max_depth, uptr pc, uptr bp, void *context, bool fast) { #if SANITIZER_WINDOWS - stack->Unwind(max_depth, pc, bp, context, 0, 0, fast); + stack->Unwind(max_depth, pc, 0, context, 0, 0, false); #else AsanThread *t; stack->size = 0; @@ -43,8 +43,11 @@ void GetStackTrace(BufferedStackTrace *stack, uptr max_depth, uptr pc, uptr bp, uptr stack_bottom = t->stack_bottom(); ScopedUnwinding unwind_scope(t); if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { - stack->Unwind(max_depth, pc, bp, context, stack_top, stack_bottom, - fast); + if (StackTrace::WillUseFastUnwind(fast)) + stack->Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, + true); + else + stack->Unwind(max_depth, pc, 0, context, 0, 0, false); } } else if (!t && !fast) { /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ -- cgit v1.2.1 From 9cde2249660f19f4ffa6d7703cecfdced27f9917 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Wed, 27 Feb 2019 21:11:50 +0000 Subject: [hwasan, asan] Intercept vfork. Summary: Intercept vfork on arm, aarch64, i386 and x86_64. Reviewers: pcc, vitalybuka Subscribers: kubamracek, mgorny, javed.absar, krytarowski, kristof.beyls, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58533 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355030 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/CMakeLists.txt | 4 ++++ lib/asan/asan_interceptors.cc | 9 +++++++++ lib/asan/asan_interceptors_vfork.S | 12 ++++++++++++ lib/asan/asan_interface.inc | 1 + lib/asan/asan_interface_internal.h | 2 ++ lib/asan/asan_rtl.cc | 13 +++++++++++++ lib/asan/asan_thread.h | 3 +++ 7 files changed, 44 insertions(+) create mode 100644 lib/asan/asan_interceptors_vfork.S (limited to 'lib/asan') diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 51bda0524..3fbd7204c 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -32,6 +32,10 @@ set(ASAN_SOURCES asan_thread.cc asan_win.cc) +if (NOT WIN32) + list(APPEND ASAN_SOURCES asan_interceptors_vfork.S) +endif() + set(ASAN_CXX_SOURCES asan_new_delete.cc) diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc index 7f2660df4..5622f1da3 100644 --- a/lib/asan/asan_interceptors.cc +++ b/lib/asan/asan_interceptors.cc @@ -579,6 +579,11 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg, } #endif // ASAN_INTERCEPT___CXA_ATEXIT +#if defined(__linux__) +DEFINE_REAL(int, vfork); +DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork); +#endif + // ---------------------- InitializeAsanInterceptors ---------------- {{{1 namespace __asan { void InitializeAsanInterceptors() { @@ -656,6 +661,10 @@ void InitializeAsanInterceptors() { ASAN_INTERCEPT_FUNC(__cxa_atexit); #endif +#if defined(__linux__) + ASAN_INTERCEPT_FUNC(vfork); +#endif + InitializePlatformInterceptors(); VReport(1, "AddressSanitizer: libc interceptors initialized\n"); diff --git a/lib/asan/asan_interceptors_vfork.S b/lib/asan/asan_interceptors_vfork.S new file mode 100644 index 000000000..90a169d4b --- /dev/null +++ b/lib/asan/asan_interceptors_vfork.S @@ -0,0 +1,12 @@ +#include "sanitizer_common/sanitizer_asm.h" + +#if defined(__linux__) +#define COMMON_INTERCEPTOR_SPILL_AREA __asan_extra_spill_area +#define COMMON_INTERCEPTOR_HANDLE_VFORK __asan_handle_vfork +#include "sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S" +#include "sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S" +#include "sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S" +#include "sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S" +#endif + +NO_EXEC_STACK_DIRECTIVE diff --git a/lib/asan/asan_interface.inc b/lib/asan/asan_interface.inc index 1dd9c6301..7c341f22e 100644 --- a/lib/asan/asan_interface.inc +++ b/lib/asan/asan_interface.inc @@ -38,6 +38,7 @@ INTERFACE_FUNCTION(__asan_get_report_pc) INTERFACE_FUNCTION(__asan_get_report_sp) INTERFACE_FUNCTION(__asan_get_shadow_mapping) INTERFACE_FUNCTION(__asan_handle_no_return) +INTERFACE_FUNCTION(__asan_handle_vfork) INTERFACE_FUNCTION(__asan_init) INTERFACE_FUNCTION(__asan_load_cxx_array_cookie) INTERFACE_FUNCTION(__asan_load1) diff --git a/lib/asan/asan_interface_internal.h b/lib/asan/asan_interface_internal.h index ea8750e90..c83aa11d7 100644 --- a/lib/asan/asan_interface_internal.h +++ b/lib/asan/asan_interface_internal.h @@ -249,6 +249,8 @@ extern "C" { SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE const char* __asan_default_suppressions(); + + SANITIZER_INTERFACE_ATTRIBUTE void __asan_handle_vfork(void *sp); } // extern "C" #endif // ASAN_INTERFACE_INTERNAL_H diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc index 67eb1a783..db8dcd068 100644 --- a/lib/asan/asan_rtl.cc +++ b/lib/asan/asan_rtl.cc @@ -597,6 +597,19 @@ void NOINLINE __asan_handle_no_return() { curr_thread->fake_stack()->HandleNoReturn(); } +extern "C" void *__asan_extra_spill_area() { + AsanThread *t = GetCurrentThread(); + CHECK(t); + return t->extra_spill_area(); +} + +void __asan_handle_vfork(void *sp) { + AsanThread *t = GetCurrentThread(); + CHECK(t); + uptr bottom = t->stack_bottom(); + PoisonShadow(bottom, (uptr)sp - bottom, 0); +} + void NOINLINE __asan_set_death_callback(void (*callback)(void)) { SetUserDieCallback(callback); } diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h index 1e08d5771..5a6010e85 100644 --- a/lib/asan/asan_thread.h +++ b/lib/asan/asan_thread.h @@ -130,6 +130,8 @@ class AsanThread { AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; } AsanStats &stats() { return stats_; } + void *extra_spill_area() { return &extra_spill_area_; } + private: // NOTE: There is no AsanThread constructor. It is allocated // via mmap() and *must* be valid in zero-initialized state. @@ -165,6 +167,7 @@ class AsanThread { AsanThreadLocalMallocStorage malloc_storage_; AsanStats stats_; bool unwinding_; + uptr extra_spill_area_; }; // ScopedUnwinding is a scope for stacktracing member of a context -- cgit v1.2.1 From b8655cd8bcda83fc404ef4e71359da6bcdbd651b Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Wed, 27 Feb 2019 22:16:02 +0000 Subject: [NFC][Sanitizer] Pull up GetStackTrace into sanitizer_common We already independently declare GetStackTrace in all (except TSan) sanitizer runtime headers. Lets move it to sanitizer_stacktrace.h to have one canonical way to fill in a BufferedStackFrame. Also enables us to use it in sanitizer_common itself. This patch defines GetStackTrace for TSan and moves the function from ubsan_diag.cc to ubsan_diag_standalone.cc to avoid duplicate symbols for the UBSan-ASan runtime. Other than that this patch just moves the code out of headers and into the correct namespace. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58651 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355039 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 28 ++++++++++++++++++++++++++++ lib/asan/asan_stack.h | 31 ------------------------------- 2 files changed, 28 insertions(+), 31 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index fe968e8e0..e4bc424e5 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -28,6 +28,34 @@ u32 GetMallocContextSize() { } // namespace __asan +void __sanitizer::GetStackTrace(BufferedStackTrace *stack, uptr max_depth, + uptr pc, uptr bp, void *context, bool fast) { + using namespace __asan; +#if SANITIZER_WINDOWS + stack->Unwind(max_depth, pc, 0, context, 0, 0, false); +#else + AsanThread *t; + stack->size = 0; + if (LIKELY(asan_inited)) { + if ((t = GetCurrentThread()) && !t->isUnwinding()) { + uptr stack_top = t->stack_top(); + uptr stack_bottom = t->stack_bottom(); + ScopedUnwinding unwind_scope(t); + if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { + if (StackTrace::WillUseFastUnwind(fast)) + stack->Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, + true); + else + stack->Unwind(max_depth, pc, 0, context, 0, 0, false); + } + } else if (!t && !fast) { + /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ + stack->Unwind(max_depth, pc, bp, context, 0, 0, false); + } + } +#endif // SANITIZER_WINDOWS +} + // ------------------ Interface -------------- {{{1 extern "C" { diff --git a/lib/asan/asan_stack.h b/lib/asan/asan_stack.h index 81cc5a922..3480d91c6 100644 --- a/lib/asan/asan_stack.h +++ b/lib/asan/asan_stack.h @@ -26,37 +26,6 @@ static const u32 kDefaultMallocContextSize = 30; void SetMallocContextSize(u32 size); u32 GetMallocContextSize(); -// Get the stack trace with the given pc and bp. -// The pc will be in the position 0 of the resulting stack trace. -// The bp may refer to the current frame or to the caller's frame. -ALWAYS_INLINE -void GetStackTrace(BufferedStackTrace *stack, uptr max_depth, uptr pc, uptr bp, - void *context, bool fast) { -#if SANITIZER_WINDOWS - stack->Unwind(max_depth, pc, 0, context, 0, 0, false); -#else - AsanThread *t; - stack->size = 0; - if (LIKELY(asan_inited)) { - if ((t = GetCurrentThread()) && !t->isUnwinding()) { - uptr stack_top = t->stack_top(); - uptr stack_bottom = t->stack_bottom(); - ScopedUnwinding unwind_scope(t); - if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { - if (StackTrace::WillUseFastUnwind(fast)) - stack->Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, - true); - else - stack->Unwind(max_depth, pc, 0, context, 0, 0, false); - } - } else if (!t && !fast) { - /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ - stack->Unwind(max_depth, pc, bp, context, 0, 0, false); - } - } -#endif // SANITIZER_WINDOWS -} - } // namespace __asan // NOTE: A Rule of thumb is to retrieve stack trace in the interceptors -- cgit v1.2.1 From 0679ae46f0e5a214dec9cab55ee7ffba159feb84 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Wed, 27 Feb 2019 22:23:51 +0000 Subject: [sanitizer] Fix compilation errors in r355030. Disable hwasan interceptor on non-linux, non-x86-or-arm platforms. Add @plt to the asm call that clang intergrated-as infers but gcc does not. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355041 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/CMakeLists.txt | 2 +- lib/asan/asan_interceptors.cc | 4 ++-- lib/asan/asan_interceptors.h | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/CMakeLists.txt b/lib/asan/CMakeLists.txt index 3fbd7204c..3c4434690 100644 --- a/lib/asan/CMakeLists.txt +++ b/lib/asan/CMakeLists.txt @@ -32,7 +32,7 @@ set(ASAN_SOURCES asan_thread.cc asan_win.cc) -if (NOT WIN32) +if (NOT WIN32 AND NOT APPLE) list(APPEND ASAN_SOURCES asan_interceptors_vfork.S) endif() diff --git a/lib/asan/asan_interceptors.cc b/lib/asan/asan_interceptors.cc index 5622f1da3..234cabce1 100644 --- a/lib/asan/asan_interceptors.cc +++ b/lib/asan/asan_interceptors.cc @@ -579,7 +579,7 @@ INTERCEPTOR(int, __cxa_atexit, void (*func)(void *), void *arg, } #endif // ASAN_INTERCEPT___CXA_ATEXIT -#if defined(__linux__) +#if ASAN_INTERCEPT_VFORK DEFINE_REAL(int, vfork); DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork); #endif @@ -661,7 +661,7 @@ void InitializeAsanInterceptors() { ASAN_INTERCEPT_FUNC(__cxa_atexit); #endif -#if defined(__linux__) +#if ASAN_INTERCEPT_VFORK ASAN_INTERCEPT_FUNC(vfork); #endif diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h index 271f373cd..903ab5991 100644 --- a/lib/asan/asan_interceptors.h +++ b/lib/asan/asan_interceptors.h @@ -105,6 +105,13 @@ void InitializePlatformInterceptors(); # define ASAN_INTERCEPT___STRDUP 0 #endif +#if SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__) || \ + defined(__i386__) || defined(__x86_64__)) +# define ASAN_INTERCEPT_VFORK 1 +#else +# define ASAN_INTERCEPT_VFORK 0 +#endif + DECLARE_REAL(int, memcmp, const void *a1, const void *a2, uptr size) DECLARE_REAL(char*, strchr, const char *str, int c) DECLARE_REAL(SIZE_T, strlen, const char *s) -- cgit v1.2.1 From a80a802a68343bc7f2e676d786fe1902d36d8340 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Fri, 1 Mar 2019 03:08:34 +0000 Subject: [NFC][Sanitizer] Add new BufferedStackTrace::Unwind API Add new Unwind API. This is the final envisioned API with the correct abstraction level. It hides/slow fast unwinder selection from the caller and doesn't take any arguments that would leak that abstraction (i.e., arguments like stack_top/stack_bottom). GetStackTrace will become an implementation detail (private method) of the BufferedStackTrace class. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58741 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355168 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_errors.cc | 2 +- lib/asan/asan_stack.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_errors.cc b/lib/asan/asan_errors.cc index 6fd465d61..16a300967 100644 --- a/lib/asan/asan_errors.cc +++ b/lib/asan/asan_errors.cc @@ -35,7 +35,7 @@ static void OnStackUnwind(const SignalContext &sig, // corresponding code in the sanitizer_common and we use this callback to // print it. static_cast(callback_context)->Print(); - GetStackTrace(stack, kStackTraceMax, sig.pc, sig.bp, sig.context, fast); + stack->Unwind(sig.pc, sig.bp, sig.context, fast); } void ErrorDeadlySignal::Print() { diff --git a/lib/asan/asan_stack.h b/lib/asan/asan_stack.h index 3480d91c6..3a4b3cefc 100644 --- a/lib/asan/asan_stack.h +++ b/lib/asan/asan_stack.h @@ -42,19 +42,19 @@ u32 GetMallocContextSize(); if (max_size > 1) stack.trace_buffer[1] = GET_CALLER_PC(); \ } \ } else { \ - GetStackTrace(&stack, max_size, StackTrace::GetCurrentPc(), \ - GET_CURRENT_FRAME(), 0, fast); \ + stack.Unwind(StackTrace::GetCurrentPc(), \ + GET_CURRENT_FRAME(), nullptr, fast, max_size); \ } #define GET_STACK_TRACE_FATAL(pc, bp) \ BufferedStackTrace stack; \ - GetStackTrace(&stack, kStackTraceMax, pc, bp, 0, \ - common_flags()->fast_unwind_on_fatal) + stack.Unwind(pc, bp, nullptr, \ + common_flags()->fast_unwind_on_fatal) #define GET_STACK_TRACE_SIGNAL(sig) \ BufferedStackTrace stack; \ - GetStackTrace(&stack, kStackTraceMax, (sig).pc, (sig).bp, (sig).context, \ - common_flags()->fast_unwind_on_fatal) + stack.Unwind((sig).pc, (sig).bp, (sig).context, \ + common_flags()->fast_unwind_on_fatal) #define GET_STACK_TRACE_FATAL_HERE \ GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal) -- cgit v1.2.1 From f868cf800339c50fb704c76e1d1349bc4faf2871 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Fri, 1 Mar 2019 03:35:05 +0000 Subject: Revert "[NFC][Sanitizer] Add new BufferedStackTrace::Unwind API" This reverts commit 6112f37e758ebf2405955e091a745f5003c1f562. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355171 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_errors.cc | 2 +- lib/asan/asan_stack.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_errors.cc b/lib/asan/asan_errors.cc index 16a300967..6fd465d61 100644 --- a/lib/asan/asan_errors.cc +++ b/lib/asan/asan_errors.cc @@ -35,7 +35,7 @@ static void OnStackUnwind(const SignalContext &sig, // corresponding code in the sanitizer_common and we use this callback to // print it. static_cast(callback_context)->Print(); - stack->Unwind(sig.pc, sig.bp, sig.context, fast); + GetStackTrace(stack, kStackTraceMax, sig.pc, sig.bp, sig.context, fast); } void ErrorDeadlySignal::Print() { diff --git a/lib/asan/asan_stack.h b/lib/asan/asan_stack.h index 3a4b3cefc..3480d91c6 100644 --- a/lib/asan/asan_stack.h +++ b/lib/asan/asan_stack.h @@ -42,19 +42,19 @@ u32 GetMallocContextSize(); if (max_size > 1) stack.trace_buffer[1] = GET_CALLER_PC(); \ } \ } else { \ - stack.Unwind(StackTrace::GetCurrentPc(), \ - GET_CURRENT_FRAME(), nullptr, fast, max_size); \ + GetStackTrace(&stack, max_size, StackTrace::GetCurrentPc(), \ + GET_CURRENT_FRAME(), 0, fast); \ } #define GET_STACK_TRACE_FATAL(pc, bp) \ BufferedStackTrace stack; \ - stack.Unwind(pc, bp, nullptr, \ - common_flags()->fast_unwind_on_fatal) + GetStackTrace(&stack, kStackTraceMax, pc, bp, 0, \ + common_flags()->fast_unwind_on_fatal) #define GET_STACK_TRACE_SIGNAL(sig) \ BufferedStackTrace stack; \ - stack.Unwind((sig).pc, (sig).bp, (sig).context, \ - common_flags()->fast_unwind_on_fatal) + GetStackTrace(&stack, kStackTraceMax, (sig).pc, (sig).bp, (sig).context, \ + common_flags()->fast_unwind_on_fatal) #define GET_STACK_TRACE_FATAL_HERE \ GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal) -- cgit v1.2.1 From 27f8cfe7f25cdb667703d8c1f7e10473d167239e Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Fri, 1 Mar 2019 04:03:38 +0000 Subject: [NFC][Sanitizer] Add new BufferedStackTrace::Unwind API Retrying without replacing call sites in sanitizer_common (which might not have a symbol definition). Add new Unwind API. This is the final envisioned API with the correct abstraction level. It hides/slow fast unwinder selection from the caller and doesn't take any arguments that would leak that abstraction (i.e., arguments like stack_top/stack_bottom). GetStackTrace will become an implementation detail (private method) of the BufferedStackTrace class. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D58741 llvm-svn: 355168 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355172 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_errors.cc | 2 +- lib/asan/asan_stack.h | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_errors.cc b/lib/asan/asan_errors.cc index 6fd465d61..16a300967 100644 --- a/lib/asan/asan_errors.cc +++ b/lib/asan/asan_errors.cc @@ -35,7 +35,7 @@ static void OnStackUnwind(const SignalContext &sig, // corresponding code in the sanitizer_common and we use this callback to // print it. static_cast(callback_context)->Print(); - GetStackTrace(stack, kStackTraceMax, sig.pc, sig.bp, sig.context, fast); + stack->Unwind(sig.pc, sig.bp, sig.context, fast); } void ErrorDeadlySignal::Print() { diff --git a/lib/asan/asan_stack.h b/lib/asan/asan_stack.h index 3480d91c6..3a4b3cefc 100644 --- a/lib/asan/asan_stack.h +++ b/lib/asan/asan_stack.h @@ -42,19 +42,19 @@ u32 GetMallocContextSize(); if (max_size > 1) stack.trace_buffer[1] = GET_CALLER_PC(); \ } \ } else { \ - GetStackTrace(&stack, max_size, StackTrace::GetCurrentPc(), \ - GET_CURRENT_FRAME(), 0, fast); \ + stack.Unwind(StackTrace::GetCurrentPc(), \ + GET_CURRENT_FRAME(), nullptr, fast, max_size); \ } #define GET_STACK_TRACE_FATAL(pc, bp) \ BufferedStackTrace stack; \ - GetStackTrace(&stack, kStackTraceMax, pc, bp, 0, \ - common_flags()->fast_unwind_on_fatal) + stack.Unwind(pc, bp, nullptr, \ + common_flags()->fast_unwind_on_fatal) #define GET_STACK_TRACE_SIGNAL(sig) \ BufferedStackTrace stack; \ - GetStackTrace(&stack, kStackTraceMax, (sig).pc, (sig).bp, (sig).context, \ - common_flags()->fast_unwind_on_fatal) + stack.Unwind((sig).pc, (sig).bp, (sig).context, \ + common_flags()->fast_unwind_on_fatal) #define GET_STACK_TRACE_FATAL_HERE \ GET_STACK_TRACE(kStackTraceMax, common_flags()->fast_unwind_on_fatal) -- cgit v1.2.1 From 10b5efbee8ff86bb2e9a830f0d54667dfe1a5736 Mon Sep 17 00:00:00 2001 From: Clement Courbet Date: Fri, 1 Mar 2019 16:42:08 +0000 Subject: Reland "[compiler-rt] Intercept the bcmp() function." Fix test issues on darwin: The REQUIRES for the test should be the same as the guard for whether we intercept bcmp. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355204 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/tests/asan_mem_test.cc | 42 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/tests/asan_mem_test.cc b/lib/asan/tests/asan_mem_test.cc index b4d3b16ec..1339c1271 100644 --- a/lib/asan/tests/asan_mem_test.cc +++ b/lib/asan/tests/asan_mem_test.cc @@ -9,7 +9,11 @@ // This file is a part of AddressSanitizer, an address sanity checker. // //===----------------------------------------------------------------------===// +#include #include "asan_test_utils.h" +#if defined(_GNU_SOURCE) +#include // for bcmp +#endif #include template @@ -205,37 +209,43 @@ TEST(AddressSanitizer, MemMoveOOBTest) { MemTransferOOBTestTemplate(1024); } - -TEST(AddressSanitizer, MemCmpOOBTest) { +template +void CmpOOBTestCommon() { size_t size = Ident(100); char *s1 = MallocAndMemsetString(size); char *s2 = MallocAndMemsetString(size); - // Normal memcmp calls. - Ident(memcmp(s1, s2, size)); - Ident(memcmp(s1 + size - 1, s2 + size - 1, 1)); - Ident(memcmp(s1 - 1, s2 - 1, 0)); + // Normal cmpfn calls. + Ident(cmpfn(s1, s2, size)); + Ident(cmpfn(s1 + size - 1, s2 + size - 1, 1)); + Ident(cmpfn(s1 - 1, s2 - 1, 0)); // One of arguments points to not allocated memory. - EXPECT_DEATH(Ident(memcmp)(s1 - 1, s2, 1), LeftOOBReadMessage(1)); - EXPECT_DEATH(Ident(memcmp)(s1, s2 - 1, 1), LeftOOBReadMessage(1)); - EXPECT_DEATH(Ident(memcmp)(s1 + size, s2, 1), RightOOBReadMessage(0)); - EXPECT_DEATH(Ident(memcmp)(s1, s2 + size, 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1 - 1, s2, 1), LeftOOBReadMessage(1)); + EXPECT_DEATH(Ident(cmpfn)(s1, s2 - 1, 1), LeftOOBReadMessage(1)); + EXPECT_DEATH(Ident(cmpfn)(s1 + size, s2, 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1, s2 + size, 1), RightOOBReadMessage(0)); // Hit unallocated memory and die. - EXPECT_DEATH(Ident(memcmp)(s1 + 1, s2 + 1, size), RightOOBReadMessage(0)); - EXPECT_DEATH(Ident(memcmp)(s1 + size - 1, s2, 2), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1 + 1, s2 + 1, size), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1 + size - 1, s2, 2), RightOOBReadMessage(0)); // Zero bytes are not terminators and don't prevent from OOB. s1[size - 1] = '\0'; s2[size - 1] = '\0'; - EXPECT_DEATH(Ident(memcmp)(s1, s2, size + 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1, s2, size + 1), RightOOBReadMessage(0)); // Even if the buffers differ in the first byte, we still assume that - // memcmp may access the whole buffer and thus reporting the overflow here: + // cmpfn may access the whole buffer and thus reporting the overflow here: s1[0] = 1; s2[0] = 123; - EXPECT_DEATH(Ident(memcmp)(s1, s2, size + 1), RightOOBReadMessage(0)); + EXPECT_DEATH(Ident(cmpfn)(s1, s2, size + 1), RightOOBReadMessage(0)); free(s1); free(s2); } +TEST(AddressSanitizer, MemCmpOOBTest) { CmpOOBTestCommon(); } - +TEST(AddressSanitizer, BCmpOOBTest) { +#if (defined(__linux__) && !defined(__ANDROID__) && defined(_GNU_SOURCE)) || \ + defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) + CmpOOBTestCommon(); +#endif +} -- cgit v1.2.1 From 1ef42ba3dfa46c13bcba83638750aebf30cf6e0d Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Fri, 1 Mar 2019 20:54:16 +0000 Subject: [sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors. They return void, unlike memset/memcpy/memmove. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355225 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_interceptors_memintrinsics.cc | 3 +++ lib/asan/asan_interceptors_memintrinsics.h | 12 +++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_interceptors_memintrinsics.cc b/lib/asan/asan_interceptors_memintrinsics.cc index e17f9ba4a..349578697 100644 --- a/lib/asan/asan_interceptors_memintrinsics.cc +++ b/lib/asan/asan_interceptors_memintrinsics.cc @@ -20,14 +20,17 @@ using namespace __asan; // NOLINT void *__asan_memcpy(void *to, const void *from, uptr size) { ASAN_MEMCPY_IMPL(nullptr, to, from, size); + return to; } void *__asan_memset(void *block, int c, uptr size) { ASAN_MEMSET_IMPL(nullptr, block, c, size); + return block; } void *__asan_memmove(void *to, const void *from, uptr size) { ASAN_MEMMOVE_IMPL(nullptr, to, from, size); + return to; } #if SANITIZER_FUCHSIA || SANITIZER_RTEMS diff --git a/lib/asan/asan_interceptors_memintrinsics.h b/lib/asan/asan_interceptors_memintrinsics.h index 1fd65fe24..092ddbce6 100644 --- a/lib/asan/asan_interceptors_memintrinsics.h +++ b/lib/asan/asan_interceptors_memintrinsics.h @@ -82,7 +82,8 @@ struct AsanInterceptorContext { do { \ if (UNLIKELY(!asan_inited)) return internal_memcpy(to, from, size); \ if (asan_init_is_running) { \ - return REAL(memcpy)(to, from, size); \ + REAL(memcpy)(to, from, size); \ + break; \ } \ ENSURE_ASAN_INITED(); \ if (flags()->replace_intrin) { \ @@ -92,7 +93,7 @@ struct AsanInterceptorContext { ASAN_READ_RANGE(ctx, from, size); \ ASAN_WRITE_RANGE(ctx, to, size); \ } \ - return REAL(memcpy)(to, from, size); \ + REAL(memcpy)(to, from, size); \ } while (0) // memset is called inside Printf. @@ -100,13 +101,14 @@ struct AsanInterceptorContext { do { \ if (UNLIKELY(!asan_inited)) return internal_memset(block, c, size); \ if (asan_init_is_running) { \ - return REAL(memset)(block, c, size); \ + REAL(memset)(block, c, size); \ + break; \ } \ ENSURE_ASAN_INITED(); \ if (flags()->replace_intrin) { \ ASAN_WRITE_RANGE(ctx, block, size); \ } \ - return REAL(memset)(block, c, size); \ + REAL(memset)(block, c, size); \ } while (0) #define ASAN_MEMMOVE_IMPL(ctx, to, from, size) \ @@ -117,7 +119,7 @@ struct AsanInterceptorContext { ASAN_READ_RANGE(ctx, from, size); \ ASAN_WRITE_RANGE(ctx, to, size); \ } \ - return internal_memmove(to, from, size); \ + internal_memmove(to, from, size); \ } while (0) #define ASAN_READ_RANGE(ctx, offset, size) \ -- cgit v1.2.1 From da78a1578037b535e27e0ac0a3cebf4783df4b6c Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Fri, 1 Mar 2019 21:49:40 +0000 Subject: Revert "[sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors." This change is incomplete. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355230 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_interceptors_memintrinsics.cc | 3 --- lib/asan/asan_interceptors_memintrinsics.h | 12 +++++------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_interceptors_memintrinsics.cc b/lib/asan/asan_interceptors_memintrinsics.cc index 349578697..e17f9ba4a 100644 --- a/lib/asan/asan_interceptors_memintrinsics.cc +++ b/lib/asan/asan_interceptors_memintrinsics.cc @@ -20,17 +20,14 @@ using namespace __asan; // NOLINT void *__asan_memcpy(void *to, const void *from, uptr size) { ASAN_MEMCPY_IMPL(nullptr, to, from, size); - return to; } void *__asan_memset(void *block, int c, uptr size) { ASAN_MEMSET_IMPL(nullptr, block, c, size); - return block; } void *__asan_memmove(void *to, const void *from, uptr size) { ASAN_MEMMOVE_IMPL(nullptr, to, from, size); - return to; } #if SANITIZER_FUCHSIA || SANITIZER_RTEMS diff --git a/lib/asan/asan_interceptors_memintrinsics.h b/lib/asan/asan_interceptors_memintrinsics.h index 092ddbce6..1fd65fe24 100644 --- a/lib/asan/asan_interceptors_memintrinsics.h +++ b/lib/asan/asan_interceptors_memintrinsics.h @@ -82,8 +82,7 @@ struct AsanInterceptorContext { do { \ if (UNLIKELY(!asan_inited)) return internal_memcpy(to, from, size); \ if (asan_init_is_running) { \ - REAL(memcpy)(to, from, size); \ - break; \ + return REAL(memcpy)(to, from, size); \ } \ ENSURE_ASAN_INITED(); \ if (flags()->replace_intrin) { \ @@ -93,7 +92,7 @@ struct AsanInterceptorContext { ASAN_READ_RANGE(ctx, from, size); \ ASAN_WRITE_RANGE(ctx, to, size); \ } \ - REAL(memcpy)(to, from, size); \ + return REAL(memcpy)(to, from, size); \ } while (0) // memset is called inside Printf. @@ -101,14 +100,13 @@ struct AsanInterceptorContext { do { \ if (UNLIKELY(!asan_inited)) return internal_memset(block, c, size); \ if (asan_init_is_running) { \ - REAL(memset)(block, c, size); \ - break; \ + return REAL(memset)(block, c, size); \ } \ ENSURE_ASAN_INITED(); \ if (flags()->replace_intrin) { \ ASAN_WRITE_RANGE(ctx, block, size); \ } \ - REAL(memset)(block, c, size); \ + return REAL(memset)(block, c, size); \ } while (0) #define ASAN_MEMMOVE_IMPL(ctx, to, from, size) \ @@ -119,7 +117,7 @@ struct AsanInterceptorContext { ASAN_READ_RANGE(ctx, from, size); \ ASAN_WRITE_RANGE(ctx, to, size); \ } \ - internal_memmove(to, from, size); \ + return internal_memmove(to, from, size); \ } while (0) #define ASAN_READ_RANGE(ctx, offset, size) \ -- cgit v1.2.1 From 7907e445f2e3e44eb941b693fcd65fd978577e69 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Fri, 1 Mar 2019 21:59:18 +0000 Subject: [sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355231 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_interceptors_memintrinsics.cc | 3 ++ lib/asan/asan_interceptors_memintrinsics.h | 81 ++++++++++++++++------------- 2 files changed, 49 insertions(+), 35 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_interceptors_memintrinsics.cc b/lib/asan/asan_interceptors_memintrinsics.cc index e17f9ba4a..349578697 100644 --- a/lib/asan/asan_interceptors_memintrinsics.cc +++ b/lib/asan/asan_interceptors_memintrinsics.cc @@ -20,14 +20,17 @@ using namespace __asan; // NOLINT void *__asan_memcpy(void *to, const void *from, uptr size) { ASAN_MEMCPY_IMPL(nullptr, to, from, size); + return to; } void *__asan_memset(void *block, int c, uptr size) { ASAN_MEMSET_IMPL(nullptr, block, c, size); + return block; } void *__asan_memmove(void *to, const void *from, uptr size) { ASAN_MEMMOVE_IMPL(nullptr, to, from, size); + return to; } #if SANITIZER_FUCHSIA || SANITIZER_RTEMS diff --git a/lib/asan/asan_interceptors_memintrinsics.h b/lib/asan/asan_interceptors_memintrinsics.h index 1fd65fe24..805736677 100644 --- a/lib/asan/asan_interceptors_memintrinsics.h +++ b/lib/asan/asan_interceptors_memintrinsics.h @@ -78,46 +78,57 @@ struct AsanInterceptorContext { // memcpy is called during __asan_init() from the internals of printf(...). // We do not treat memcpy with to==from as a bug. // See http://llvm.org/bugs/show_bug.cgi?id=11763. -#define ASAN_MEMCPY_IMPL(ctx, to, from, size) \ - do { \ - if (UNLIKELY(!asan_inited)) return internal_memcpy(to, from, size); \ - if (asan_init_is_running) { \ - return REAL(memcpy)(to, from, size); \ - } \ - ENSURE_ASAN_INITED(); \ - if (flags()->replace_intrin) { \ - if (to != from) { \ - CHECK_RANGES_OVERLAP("memcpy", to, size, from, size); \ - } \ - ASAN_READ_RANGE(ctx, from, size); \ - ASAN_WRITE_RANGE(ctx, to, size); \ - } \ - return REAL(memcpy)(to, from, size); \ +#define ASAN_MEMCPY_IMPL(ctx, to, from, size) \ + do { \ + if (UNLIKELY(!asan_inited)) { \ + internal_memcpy(to, from, size); \ + break; \ + } \ + if (asan_init_is_running) { \ + REAL(memcpy)(to, from, size); \ + break; \ + } \ + ENSURE_ASAN_INITED(); \ + if (flags()->replace_intrin) { \ + if (to != from) { \ + CHECK_RANGES_OVERLAP("memcpy", to, size, from, size); \ + } \ + ASAN_READ_RANGE(ctx, from, size); \ + ASAN_WRITE_RANGE(ctx, to, size); \ + } \ + REAL(memcpy)(to, from, size); \ } while (0) // memset is called inside Printf. -#define ASAN_MEMSET_IMPL(ctx, block, c, size) \ - do { \ - if (UNLIKELY(!asan_inited)) return internal_memset(block, c, size); \ - if (asan_init_is_running) { \ - return REAL(memset)(block, c, size); \ - } \ - ENSURE_ASAN_INITED(); \ - if (flags()->replace_intrin) { \ - ASAN_WRITE_RANGE(ctx, block, size); \ - } \ - return REAL(memset)(block, c, size); \ +#define ASAN_MEMSET_IMPL(ctx, block, c, size) \ + do { \ + if (UNLIKELY(!asan_inited)) { \ + internal_memset(block, c, size); \ + break; \ + } \ + if (asan_init_is_running) { \ + REAL(memset)(block, c, size); \ + break; \ + } \ + ENSURE_ASAN_INITED(); \ + if (flags()->replace_intrin) { \ + ASAN_WRITE_RANGE(ctx, block, size); \ + } \ + REAL(memset)(block, c, size); \ } while (0) -#define ASAN_MEMMOVE_IMPL(ctx, to, from, size) \ - do { \ - if (UNLIKELY(!asan_inited)) return internal_memmove(to, from, size); \ - ENSURE_ASAN_INITED(); \ - if (flags()->replace_intrin) { \ - ASAN_READ_RANGE(ctx, from, size); \ - ASAN_WRITE_RANGE(ctx, to, size); \ - } \ - return internal_memmove(to, from, size); \ +#define ASAN_MEMMOVE_IMPL(ctx, to, from, size) \ + do { \ + if (UNLIKELY(!asan_inited)) { \ + internal_memmove(to, from, size); \ + break; \ + } \ + ENSURE_ASAN_INITED(); \ + if (flags()->replace_intrin) { \ + ASAN_READ_RANGE(ctx, from, size); \ + ASAN_WRITE_RANGE(ctx, to, size); \ + } \ + internal_memmove(to, from, size); \ } while (0) #define ASAN_READ_RANGE(ctx, offset, size) \ -- cgit v1.2.1 From 194ef3aa7e9c7ffa9fe13527983128673e1e2aed Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Fri, 1 Mar 2019 22:10:49 +0000 Subject: [NFC][Sanitizer] Make GetStackTrace a private method of BufferedStackTrace GetStackTrace is a implementation detail of BufferedStackTrace. Make it a private method. Reviewed By: vitalybuka Differential-Revision: https://reviews.llvm.org/D58753 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355232 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index e4bc424e5..039261cf2 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -28,29 +28,28 @@ u32 GetMallocContextSize() { } // namespace __asan -void __sanitizer::GetStackTrace(BufferedStackTrace *stack, uptr max_depth, - uptr pc, uptr bp, void *context, bool fast) { +void __sanitizer::BufferedStackTrace::UnwindImpl( + uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) { using namespace __asan; #if SANITIZER_WINDOWS stack->Unwind(max_depth, pc, 0, context, 0, 0, false); #else AsanThread *t; - stack->size = 0; + size = 0; if (LIKELY(asan_inited)) { if ((t = GetCurrentThread()) && !t->isUnwinding()) { uptr stack_top = t->stack_top(); uptr stack_bottom = t->stack_bottom(); ScopedUnwinding unwind_scope(t); if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { - if (StackTrace::WillUseFastUnwind(fast)) - stack->Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, - true); + if (StackTrace::WillUseFastUnwind(request_fast)) + Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); else - stack->Unwind(max_depth, pc, 0, context, 0, 0, false); + Unwind(max_depth, pc, 0, context, 0, 0, false); } - } else if (!t && !fast) { + } else if (!t && !request_fast) { /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ - stack->Unwind(max_depth, pc, bp, context, 0, 0, false); + Unwind(max_depth, pc, bp, context, 0, 0, false); } } #endif // SANITIZER_WINDOWS -- cgit v1.2.1 From 5d7c65d342d0cd3e392ce0d85f1bb546f53e6442 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Fri, 1 Mar 2019 22:26:45 +0000 Subject: [NFC][Sanitizer][Windows] Fix refactoring oversight Fix mistake in previous commit: 9fe3b4906f351292691cd594b30fe6cf7230b94d git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355234 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index 039261cf2..72caf1f8b 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -32,7 +32,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) { using namespace __asan; #if SANITIZER_WINDOWS - stack->Unwind(max_depth, pc, 0, context, 0, 0, false); + Unwind(max_depth, pc, 0, context, 0, 0, false); #else AsanThread *t; size = 0; -- cgit v1.2.1 From f6c9cee809111718d8baf47671dc516bbce3ba4c Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Sat, 2 Mar 2019 01:33:52 +0000 Subject: Revert "[sanitizer] Fix return type of __bzero and __aeabi_mem* interceptors." Breaks TSan on Mac, which does return REAL(func)(... in COMMON_INTERCEPTOR_ENTER, which is not OK when REAL(func) has return type of void. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355256 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_interceptors_memintrinsics.cc | 3 -- lib/asan/asan_interceptors_memintrinsics.h | 81 +++++++++++++---------------- 2 files changed, 35 insertions(+), 49 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_interceptors_memintrinsics.cc b/lib/asan/asan_interceptors_memintrinsics.cc index 349578697..e17f9ba4a 100644 --- a/lib/asan/asan_interceptors_memintrinsics.cc +++ b/lib/asan/asan_interceptors_memintrinsics.cc @@ -20,17 +20,14 @@ using namespace __asan; // NOLINT void *__asan_memcpy(void *to, const void *from, uptr size) { ASAN_MEMCPY_IMPL(nullptr, to, from, size); - return to; } void *__asan_memset(void *block, int c, uptr size) { ASAN_MEMSET_IMPL(nullptr, block, c, size); - return block; } void *__asan_memmove(void *to, const void *from, uptr size) { ASAN_MEMMOVE_IMPL(nullptr, to, from, size); - return to; } #if SANITIZER_FUCHSIA || SANITIZER_RTEMS diff --git a/lib/asan/asan_interceptors_memintrinsics.h b/lib/asan/asan_interceptors_memintrinsics.h index 805736677..1fd65fe24 100644 --- a/lib/asan/asan_interceptors_memintrinsics.h +++ b/lib/asan/asan_interceptors_memintrinsics.h @@ -78,57 +78,46 @@ struct AsanInterceptorContext { // memcpy is called during __asan_init() from the internals of printf(...). // We do not treat memcpy with to==from as a bug. // See http://llvm.org/bugs/show_bug.cgi?id=11763. -#define ASAN_MEMCPY_IMPL(ctx, to, from, size) \ - do { \ - if (UNLIKELY(!asan_inited)) { \ - internal_memcpy(to, from, size); \ - break; \ - } \ - if (asan_init_is_running) { \ - REAL(memcpy)(to, from, size); \ - break; \ - } \ - ENSURE_ASAN_INITED(); \ - if (flags()->replace_intrin) { \ - if (to != from) { \ - CHECK_RANGES_OVERLAP("memcpy", to, size, from, size); \ - } \ - ASAN_READ_RANGE(ctx, from, size); \ - ASAN_WRITE_RANGE(ctx, to, size); \ - } \ - REAL(memcpy)(to, from, size); \ +#define ASAN_MEMCPY_IMPL(ctx, to, from, size) \ + do { \ + if (UNLIKELY(!asan_inited)) return internal_memcpy(to, from, size); \ + if (asan_init_is_running) { \ + return REAL(memcpy)(to, from, size); \ + } \ + ENSURE_ASAN_INITED(); \ + if (flags()->replace_intrin) { \ + if (to != from) { \ + CHECK_RANGES_OVERLAP("memcpy", to, size, from, size); \ + } \ + ASAN_READ_RANGE(ctx, from, size); \ + ASAN_WRITE_RANGE(ctx, to, size); \ + } \ + return REAL(memcpy)(to, from, size); \ } while (0) // memset is called inside Printf. -#define ASAN_MEMSET_IMPL(ctx, block, c, size) \ - do { \ - if (UNLIKELY(!asan_inited)) { \ - internal_memset(block, c, size); \ - break; \ - } \ - if (asan_init_is_running) { \ - REAL(memset)(block, c, size); \ - break; \ - } \ - ENSURE_ASAN_INITED(); \ - if (flags()->replace_intrin) { \ - ASAN_WRITE_RANGE(ctx, block, size); \ - } \ - REAL(memset)(block, c, size); \ +#define ASAN_MEMSET_IMPL(ctx, block, c, size) \ + do { \ + if (UNLIKELY(!asan_inited)) return internal_memset(block, c, size); \ + if (asan_init_is_running) { \ + return REAL(memset)(block, c, size); \ + } \ + ENSURE_ASAN_INITED(); \ + if (flags()->replace_intrin) { \ + ASAN_WRITE_RANGE(ctx, block, size); \ + } \ + return REAL(memset)(block, c, size); \ } while (0) -#define ASAN_MEMMOVE_IMPL(ctx, to, from, size) \ - do { \ - if (UNLIKELY(!asan_inited)) { \ - internal_memmove(to, from, size); \ - break; \ - } \ - ENSURE_ASAN_INITED(); \ - if (flags()->replace_intrin) { \ - ASAN_READ_RANGE(ctx, from, size); \ - ASAN_WRITE_RANGE(ctx, to, size); \ - } \ - internal_memmove(to, from, size); \ +#define ASAN_MEMMOVE_IMPL(ctx, to, from, size) \ + do { \ + if (UNLIKELY(!asan_inited)) return internal_memmove(to, from, size); \ + ENSURE_ASAN_INITED(); \ + if (flags()->replace_intrin) { \ + ASAN_READ_RANGE(ctx, from, size); \ + ASAN_WRITE_RANGE(ctx, to, size); \ + } \ + return internal_memmove(to, from, size); \ } while (0) #define ASAN_READ_RANGE(ctx, offset, size) \ -- cgit v1.2.1 From 75d9c8300b6183f074e659b6adc94460f8bc0341 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Tue, 5 Mar 2019 00:41:15 +0000 Subject: [NFC][Sanitizer] Cleanup ASan's GetStackTrace implementation Cleanup ASan's __sanitizer::BufferedStackTrace::UnwindImpl (formerly GetStackTrace) implementation. Start with ASan because it is the most complex implementation. GetStackTrace implementations seem to have started out as exact copies of the original implementation in ASan, but have diverged in subtle ways. My goal is to parameterize this algorithm (via templating or callbacks) so we can share the implementation and get rid of the inversed dependency (sanitizer_common depends on concrete implementations in asan, ubsan, etc.). This should also help us to avoid those pesky linker errors caused by undefined, duplicate, and weak symbols on Windows. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D58861 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355355 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index 72caf1f8b..0bcba419d 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -31,28 +31,23 @@ u32 GetMallocContextSize() { void __sanitizer::BufferedStackTrace::UnwindImpl( uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) { using namespace __asan; -#if SANITIZER_WINDOWS - Unwind(max_depth, pc, 0, context, 0, 0, false); -#else - AsanThread *t; size = 0; - if (LIKELY(asan_inited)) { - if ((t = GetCurrentThread()) && !t->isUnwinding()) { - uptr stack_top = t->stack_top(); - uptr stack_bottom = t->stack_bottom(); - ScopedUnwinding unwind_scope(t); - if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { - if (StackTrace::WillUseFastUnwind(request_fast)) - Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); - else - Unwind(max_depth, pc, 0, context, 0, 0, false); - } - } else if (!t && !request_fast) { - /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ - Unwind(max_depth, pc, bp, context, 0, 0, false); + if (UNLIKELY(!asan_inited)) return; + + AsanThread *t = GetCurrentThread(); + if (t && !t->isUnwinding() && WillUseFastUnwind(request_fast)) { + uptr top = t->stack_top(); + uptr bottom = t->stack_bottom(); + ScopedUnwinding unwind_scope(t); + if (!SANITIZER_MIPS || IsValidFrame(bp, top, bottom)) { + UnwindFast(pc, bp, top, bottom, max_depth); + return; } } -#endif // SANITIZER_WINDOWS + +#if SANITIZER_CAN_SLOW_UNWIND + UnwindSlowWithOptionalContext(pc, context, max_depth); +#endif } // ------------------ Interface -------------- {{{1 -- cgit v1.2.1 From 1c651df8e13b22d3134a93cfd79f92a845e6885d Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 5 Mar 2019 02:35:49 +0000 Subject: Revert "[NFC][Sanitizer] Cleanup ASan's GetStackTrace implementation" I've missed that UnwindSlow was removed from ScopedUnwinding. This reverts commit 4ce918e3942f0333ccb7d65d6265f4fc5f5324be. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355369 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index 0bcba419d..72caf1f8b 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -31,23 +31,28 @@ u32 GetMallocContextSize() { void __sanitizer::BufferedStackTrace::UnwindImpl( uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) { using namespace __asan; +#if SANITIZER_WINDOWS + Unwind(max_depth, pc, 0, context, 0, 0, false); +#else + AsanThread *t; size = 0; - if (UNLIKELY(!asan_inited)) return; - - AsanThread *t = GetCurrentThread(); - if (t && !t->isUnwinding() && WillUseFastUnwind(request_fast)) { - uptr top = t->stack_top(); - uptr bottom = t->stack_bottom(); - ScopedUnwinding unwind_scope(t); - if (!SANITIZER_MIPS || IsValidFrame(bp, top, bottom)) { - UnwindFast(pc, bp, top, bottom, max_depth); - return; + if (LIKELY(asan_inited)) { + if ((t = GetCurrentThread()) && !t->isUnwinding()) { + uptr stack_top = t->stack_top(); + uptr stack_bottom = t->stack_bottom(); + ScopedUnwinding unwind_scope(t); + if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { + if (StackTrace::WillUseFastUnwind(request_fast)) + Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); + else + Unwind(max_depth, pc, 0, context, 0, 0, false); + } + } else if (!t && !request_fast) { + /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ + Unwind(max_depth, pc, bp, context, 0, 0, false); } } - -#if SANITIZER_CAN_SLOW_UNWIND - UnwindSlowWithOptionalContext(pc, context, max_depth); -#endif +#endif // SANITIZER_WINDOWS } // ------------------ Interface -------------- {{{1 -- cgit v1.2.1 From 070b090cfd447a2fae864f5478133182d1259a9c Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 5 Mar 2019 02:50:49 +0000 Subject: [NFC] Move asan_inited and size reset on top of ::UnwindImpl git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355370 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index 72caf1f8b..ff904f6e0 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -31,26 +31,26 @@ u32 GetMallocContextSize() { void __sanitizer::BufferedStackTrace::UnwindImpl( uptr pc, uptr bp, void *context, bool request_fast, u32 max_depth) { using namespace __asan; + size = 0; + if (UNLIKELY(!asan_inited)) + return; #if SANITIZER_WINDOWS Unwind(max_depth, pc, 0, context, 0, 0, false); #else - AsanThread *t; - size = 0; - if (LIKELY(asan_inited)) { - if ((t = GetCurrentThread()) && !t->isUnwinding()) { - uptr stack_top = t->stack_top(); - uptr stack_bottom = t->stack_bottom(); - ScopedUnwinding unwind_scope(t); - if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { - if (StackTrace::WillUseFastUnwind(request_fast)) - Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); - else - Unwind(max_depth, pc, 0, context, 0, 0, false); - } - } else if (!t && !request_fast) { - /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ - Unwind(max_depth, pc, bp, context, 0, 0, false); + AsanThread *t = GetCurrentThread(); + if (t && !t->isUnwinding()) { + uptr stack_top = t->stack_top(); + uptr stack_bottom = t->stack_bottom(); + ScopedUnwinding unwind_scope(t); + if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { + if (StackTrace::WillUseFastUnwind(request_fast)) + Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); + else + Unwind(max_depth, pc, 0, context, 0, 0, false); } + } else if (!t && !request_fast) { + /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ + Unwind(max_depth, pc, bp, context, 0, 0, false); } #endif // SANITIZER_WINDOWS } -- cgit v1.2.1 From 95b421158a990ce51c497ea61ff246dc78d83d83 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 5 Mar 2019 02:50:57 +0000 Subject: [NFC] Put bp into Unwind(.. false) for consistency It's not used there anyway git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355371 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index ff904f6e0..c76b43109 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -35,7 +35,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( if (UNLIKELY(!asan_inited)) return; #if SANITIZER_WINDOWS - Unwind(max_depth, pc, 0, context, 0, 0, false); + Unwind(max_depth, pc, bp, context, 0, 0, false); #else AsanThread *t = GetCurrentThread(); if (t && !t->isUnwinding()) { @@ -46,7 +46,7 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( if (StackTrace::WillUseFastUnwind(request_fast)) Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); else - Unwind(max_depth, pc, 0, context, 0, 0, false); + Unwind(max_depth, pc, bp, context, 0, 0, false); } } else if (!t && !request_fast) { /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ -- cgit v1.2.1 From fe1cd20a9606a09deb44e370e9cd4d89b9a427c5 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 5 Mar 2019 02:51:04 +0000 Subject: [NFC] Return on SANITIZER_MIPS && !IsValidFrame git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355372 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index c76b43109..2c034623e 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -42,12 +42,12 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( uptr stack_top = t->stack_top(); uptr stack_bottom = t->stack_bottom(); ScopedUnwinding unwind_scope(t); - if (!SANITIZER_MIPS || IsValidFrame(bp, stack_top, stack_bottom)) { - if (StackTrace::WillUseFastUnwind(request_fast)) - Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); - else - Unwind(max_depth, pc, bp, context, 0, 0, false); - } + if (SANITIZER_MIPS && !IsValidFrame(bp, stack_top, stack_bottom)) + return; + if (StackTrace::WillUseFastUnwind(request_fast)) + Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); + else + Unwind(max_depth, pc, bp, context, 0, 0, false); } else if (!t && !request_fast) { /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ Unwind(max_depth, pc, bp, context, 0, 0, false); -- cgit v1.2.1 From ea0184abfa8532fa44c332b2aa92c8e4407bf849 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 5 Mar 2019 04:36:49 +0000 Subject: [NFC] Reorder ifs in BufferedStackTrace::UnwindImpl git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355376 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index 2c034623e..664f0d056 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -38,20 +38,24 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( Unwind(max_depth, pc, bp, context, 0, 0, false); #else AsanThread *t = GetCurrentThread(); - if (t && !t->isUnwinding()) { - uptr stack_top = t->stack_top(); - uptr stack_bottom = t->stack_bottom(); - ScopedUnwinding unwind_scope(t); - if (SANITIZER_MIPS && !IsValidFrame(bp, stack_top, stack_bottom)) - return; - if (StackTrace::WillUseFastUnwind(request_fast)) - Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); - else + if (!t) { + if (!request_fast) { + /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ Unwind(max_depth, pc, bp, context, 0, 0, false); - } else if (!t && !request_fast) { - /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ - Unwind(max_depth, pc, bp, context, 0, 0, false); + } + return; } + if (t->isUnwinding()) + return; + uptr stack_top = t->stack_top(); + uptr stack_bottom = t->stack_bottom(); + ScopedUnwinding unwind_scope(t); + if (SANITIZER_MIPS && !IsValidFrame(bp, stack_top, stack_bottom)) + return; + if (StackTrace::WillUseFastUnwind(request_fast)) + Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); + else + Unwind(max_depth, pc, bp, context, 0, 0, false); #endif // SANITIZER_WINDOWS } -- cgit v1.2.1 From 08a11d9c684b143eb81b930dea3694bb8fb5c5e3 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 5 Mar 2019 04:36:56 +0000 Subject: [NFC] Move ScopedUnwinding from .h to .cc git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355377 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 14 ++++++++++++++ lib/asan/asan_thread.h | 12 ------------ 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index 664f0d056..f5a8e813b 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -26,6 +26,20 @@ u32 GetMallocContextSize() { return atomic_load(&malloc_context_size, memory_order_acquire); } +namespace { + +// ScopedUnwinding is a scope for stacktracing member of a context +class ScopedUnwinding { + public: + explicit ScopedUnwinding(AsanThread *t) : thread(t) { t->setUnwinding(true); } + ~ScopedUnwinding() { thread->setUnwinding(false); } + + private: + AsanThread *thread; +}; + +} // namespace + } // namespace __asan void __sanitizer::BufferedStackTrace::UnwindImpl( diff --git a/lib/asan/asan_thread.h b/lib/asan/asan_thread.h index 5a6010e85..d725e8886 100644 --- a/lib/asan/asan_thread.h +++ b/lib/asan/asan_thread.h @@ -170,18 +170,6 @@ class AsanThread { uptr extra_spill_area_; }; -// ScopedUnwinding is a scope for stacktracing member of a context -class ScopedUnwinding { - public: - explicit ScopedUnwinding(AsanThread *t) : thread(t) { - t->setUnwinding(true); - } - ~ScopedUnwinding() { thread->setUnwinding(false); } - - private: - AsanThread *thread; -}; - // Returns a single instance of registry. ThreadRegistry &asanThreadRegistry(); -- cgit v1.2.1 From ddacbae97bbf4579709dd8bbb283d68650f46753 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 5 Mar 2019 05:40:05 +0000 Subject: [NFC] Move isUnwinding check into ScopedUnwinding git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355380 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index f5a8e813b..dde8f7f0e 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -31,11 +31,22 @@ namespace { // ScopedUnwinding is a scope for stacktracing member of a context class ScopedUnwinding { public: - explicit ScopedUnwinding(AsanThread *t) : thread(t) { t->setUnwinding(true); } - ~ScopedUnwinding() { thread->setUnwinding(false); } + explicit ScopedUnwinding(AsanThread *t) : thread(t) { + if (thread) { + can_unwind = !thread->isUnwinding(); + thread->setUnwinding(true); + } + } + ~ScopedUnwinding() { + if (thread) + thread->setUnwinding(false); + } + + bool CanUnwind() const { return can_unwind; } private: - AsanThread *thread; + AsanThread *thread = nullptr; + bool can_unwind = true; }; } // namespace @@ -52,6 +63,9 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( Unwind(max_depth, pc, bp, context, 0, 0, false); #else AsanThread *t = GetCurrentThread(); + ScopedUnwinding unwind_scope(t); + if (!unwind_scope.CanUnwind()) + return; if (!t) { if (!request_fast) { /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ @@ -59,11 +73,10 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( } return; } - if (t->isUnwinding()) - return; + uptr stack_top = t->stack_top(); uptr stack_bottom = t->stack_bottom(); - ScopedUnwinding unwind_scope(t); + if (SANITIZER_MIPS && !IsValidFrame(bp, stack_top, stack_bottom)) return; if (StackTrace::WillUseFastUnwind(request_fast)) -- cgit v1.2.1 From c1cf41f7592eed7c51a1ac79233ce9f028ac2338 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 5 Mar 2019 05:52:34 +0000 Subject: [NFC] Simplify BufferedStackTrace::UnwindImpl git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355381 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_stack.cc | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_stack.cc b/lib/asan/asan_stack.cc index dde8f7f0e..b244da4fa 100644 --- a/lib/asan/asan_stack.cc +++ b/lib/asan/asan_stack.cc @@ -59,31 +59,22 @@ void __sanitizer::BufferedStackTrace::UnwindImpl( size = 0; if (UNLIKELY(!asan_inited)) return; -#if SANITIZER_WINDOWS - Unwind(max_depth, pc, bp, context, 0, 0, false); -#else + request_fast = StackTrace::WillUseFastUnwind(request_fast); AsanThread *t = GetCurrentThread(); ScopedUnwinding unwind_scope(t); if (!unwind_scope.CanUnwind()) return; - if (!t) { - if (!request_fast) { - /* If GetCurrentThread() has failed, try to do slow unwind anyways. */ - Unwind(max_depth, pc, bp, context, 0, 0, false); + if (request_fast) { + if (t) { + Unwind(max_depth, pc, bp, nullptr, t->stack_top(), t->stack_bottom(), + true); } return; } - - uptr stack_top = t->stack_top(); - uptr stack_bottom = t->stack_bottom(); - - if (SANITIZER_MIPS && !IsValidFrame(bp, stack_top, stack_bottom)) + if (SANITIZER_MIPS && t && + !IsValidFrame(bp, t->stack_top(), t->stack_bottom())) return; - if (StackTrace::WillUseFastUnwind(request_fast)) - Unwind(max_depth, pc, bp, nullptr, stack_top, stack_bottom, true); - else - Unwind(max_depth, pc, bp, context, 0, 0, false); -#endif // SANITIZER_WINDOWS + Unwind(max_depth, pc, bp, context, 0, 0, false); } // ------------------ Interface -------------- {{{1 -- cgit v1.2.1 From 811f7417f6fbcb3cbfcec671f3ff6e362408d420 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Mon, 11 Mar 2019 21:50:10 +0000 Subject: Remove ASan asm instrumentation. Summary: It is incomplete and has no users AFAIK. Reviewers: pcc, vitalybuka Subscribers: srhines, kubamracek, mgorny, krytarowski, eraman, hiraditya, jdoerfert, #sanitizers, llvm-commits, thakis Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D59154 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355870 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/tests/CMakeLists.txt | 5 - lib/asan/tests/asan_asm_test.cc | 273 ---------------------------------------- 2 files changed, 278 deletions(-) delete mode 100644 lib/asan/tests/asan_asm_test.cc (limited to 'lib/asan') diff --git a/lib/asan/tests/CMakeLists.txt b/lib/asan/tests/CMakeLists.txt index 9e640d1d8..d7116f7ff 100644 --- a/lib/asan/tests/CMakeLists.txt +++ b/lib/asan/tests/CMakeLists.txt @@ -74,10 +74,6 @@ set(ASAN_UNITTEST_INSTRUMENTED_CFLAGS -fsanitize=address "-fsanitize-blacklist=${ASAN_BLACKLIST_FILE}" ) -if(CAN_TARGET_x86_64 OR CAN_TARGET_i386) - list(APPEND ASAN_UNITTEST_INSTRUMENTED_CFLAGS -mllvm -asan-instrument-assembly) -endif() - if(NOT MSVC) list(APPEND ASAN_UNITTEST_COMMON_LINK_FLAGS --driver-mode=g++) endif() @@ -142,7 +138,6 @@ set(ASAN_NOINST_TEST_SOURCES set(ASAN_INST_TEST_SOURCES ${COMPILER_RT_GTEST_SOURCE} - asan_asm_test.cc asan_globals_test.cc asan_interface_test.cc asan_internal_interface_test.cc diff --git a/lib/asan/tests/asan_asm_test.cc b/lib/asan/tests/asan_asm_test.cc deleted file mode 100644 index a3c599f28..000000000 --- a/lib/asan/tests/asan_asm_test.cc +++ /dev/null @@ -1,273 +0,0 @@ -//===-- asan_asm_test.cc --------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file is a part of AddressSanitizer, an address sanity checker. -// -//===----------------------------------------------------------------------===// -#include "asan_test_utils.h" - -#if defined(__linux__) && \ - (!defined(ASAN_SHADOW_SCALE) || ASAN_SHADOW_SCALE == 3) - -// Assembly instrumentation is broken on x86 Android (x86 + PIC + shared runtime -// library). See https://github.com/google/sanitizers/issues/353 -#if defined(__x86_64__) || \ - (defined(__i386__) && defined(__SSE2__) && !defined(__ANDROID__)) - -#include - -namespace { - -template void asm_write(T *ptr, T val); -template T asm_read(T *ptr); -template void asm_rep_movs(T *dst, T *src, size_t n); - -} // End of anonymous namespace - -#endif // defined(__x86_64__) || (defined(__i386__) && defined(__SSE2__)) - -#if defined(__x86_64__) - -namespace { - -#define DECLARE_ASM_WRITE(Type, Size, Mov, Reg) \ -template<> void asm_write(Type *ptr, Type val) { \ - __asm__( \ - Mov " %[val], (%[ptr]) \n\t" \ - : \ - : [ptr] "r" (ptr), [val] Reg (val) \ - : "memory" \ - ); \ -} - -#define DECLARE_ASM_READ(Type, Size, Mov, Reg) \ -template<> Type asm_read(Type *ptr) { \ - Type res; \ - __asm__( \ - Mov " (%[ptr]), %[res] \n\t" \ - : [res] Reg (res) \ - : [ptr] "r" (ptr) \ - : "memory" \ - ); \ - return res; \ -} - -#define DECLARE_ASM_REP_MOVS(Type, Movs) \ - template <> \ - void asm_rep_movs(Type * dst, Type * src, size_t size) { \ - __asm__("rep " Movs " \n\t" \ - : "+D"(dst), "+S"(src), "+c"(size) \ - : \ - : "memory"); \ - } - -DECLARE_ASM_WRITE(U8, "8", "movq", "r"); -DECLARE_ASM_READ(U8, "8", "movq", "=r"); -DECLARE_ASM_REP_MOVS(U8, "movsq"); - -} // End of anonymous namespace - -#endif // defined(__x86_64__) - -#if defined(__i386__) && defined(__SSE2__) && !defined(__ANDROID__) - -namespace { - -#define DECLARE_ASM_WRITE(Type, Size, Mov, Reg) \ -template<> void asm_write(Type *ptr, Type val) { \ - __asm__( \ - Mov " %[val], (%[ptr]) \n\t" \ - : \ - : [ptr] "r" (ptr), [val] Reg (val) \ - : "memory" \ - ); \ -} - -#define DECLARE_ASM_READ(Type, Size, Mov, Reg) \ -template<> Type asm_read(Type *ptr) { \ - Type res; \ - __asm__( \ - Mov " (%[ptr]), %[res] \n\t" \ - : [res] Reg (res) \ - : [ptr] "r" (ptr) \ - : "memory" \ - ); \ - return res; \ -} - -#define DECLARE_ASM_REP_MOVS(Type, Movs) \ - template <> \ - void asm_rep_movs(Type * dst, Type * src, size_t size) { \ - __asm__("rep " Movs " \n\t" \ - : "+D"(dst), "+S"(src), "+c"(size) \ - : \ - : "memory"); \ - } - -} // End of anonymous namespace - -#endif // defined(__i386__) && defined(__SSE2__) - -#if defined(__x86_64__) || \ - (defined(__i386__) && defined(__SSE2__) && !defined(__ANDROID__)) - -namespace { - -DECLARE_ASM_WRITE(U1, "1", "movb", "r"); -DECLARE_ASM_WRITE(U2, "2", "movw", "r"); -DECLARE_ASM_WRITE(U4, "4", "movl", "r"); -DECLARE_ASM_WRITE(__m128i, "16", "movaps", "x"); - -DECLARE_ASM_READ(U1, "1", "movb", "=r"); -DECLARE_ASM_READ(U2, "2", "movw", "=r"); -DECLARE_ASM_READ(U4, "4", "movl", "=r"); -DECLARE_ASM_READ(__m128i, "16", "movaps", "=x"); - -DECLARE_ASM_REP_MOVS(U1, "movsb"); -DECLARE_ASM_REP_MOVS(U2, "movsw"); -DECLARE_ASM_REP_MOVS(U4, "movsl"); - -template void TestAsmWrite(const char *DeathPattern) { - T *buf = new T; - EXPECT_DEATH(asm_write(&buf[1], static_cast(0)), DeathPattern); - T var = 0x12; - asm_write(&var, static_cast(0x21)); - ASSERT_EQ(static_cast(0x21), var); - delete buf; -} - -template<> void TestAsmWrite<__m128i>(const char *DeathPattern) { - char *buf = new char[16]; - char *p = buf + 16; - if (((uintptr_t) p % 16) != 0) - p = buf + 8; - assert(((uintptr_t) p % 16) == 0); - __m128i val = _mm_set1_epi16(0x1234); - EXPECT_DEATH(asm_write<__m128i>((__m128i*) p, val), DeathPattern); - __m128i var = _mm_set1_epi16(0x4321); - asm_write(&var, val); - ASSERT_EQ(0x1234, _mm_extract_epi16(var, 0)); - delete [] buf; -} - -template void TestAsmRead(const char *DeathPattern) { - T *buf = new T; - EXPECT_DEATH(asm_read(&buf[1]), DeathPattern); - T var = 0x12; - ASSERT_EQ(static_cast(0x12), asm_read(&var)); - delete buf; -} - -template<> void TestAsmRead<__m128i>(const char *DeathPattern) { - char *buf = new char[16]; - char *p = buf + 16; - if (((uintptr_t) p % 16) != 0) - p = buf + 8; - assert(((uintptr_t) p % 16) == 0); - EXPECT_DEATH(asm_read<__m128i>((__m128i*) p), DeathPattern); - __m128i val = _mm_set1_epi16(0x1234); - ASSERT_EQ(0x1234, _mm_extract_epi16(asm_read(&val), 0)); - delete [] buf; -} - -U4 AsmLoad(U4 *a) { - U4 r; - __asm__("movl (%[a]), %[r] \n\t" : [r] "=r" (r) : [a] "r" (a) : "memory"); - return r; -} - -void AsmStore(U4 r, U4 *a) { - __asm__("movl %[r], (%[a]) \n\t" : : [a] "r" (a), [r] "r" (r) : "memory"); -} - -template -void TestAsmRepMovs(const char *DeathPatternRead, - const char *DeathPatternWrite) { - T src_good[4] = { 0x0, 0x1, 0x2, 0x3 }; - T dst_good[4] = {}; - asm_rep_movs(dst_good, src_good, 4); - ASSERT_EQ(static_cast(0x0), dst_good[0]); - ASSERT_EQ(static_cast(0x1), dst_good[1]); - ASSERT_EQ(static_cast(0x2), dst_good[2]); - ASSERT_EQ(static_cast(0x3), dst_good[3]); - - T dst_bad[3]; - EXPECT_DEATH(asm_rep_movs(dst_bad, src_good, 4), DeathPatternWrite); - - T src_bad[3] = { 0x0, 0x1, 0x2 }; - EXPECT_DEATH(asm_rep_movs(dst_good, src_bad, 4), DeathPatternRead); - - T* dp = dst_bad + 4; - T* sp = src_bad + 4; - asm_rep_movs(dp, sp, 0); -} - -} // End of anonymous namespace - -TEST(AddressSanitizer, asm_load_store) { - U4* buf = new U4[2]; - EXPECT_DEATH(AsmLoad(&buf[3]), "READ of size 4"); - EXPECT_DEATH(AsmStore(0x1234, &buf[3]), "WRITE of size 4"); - delete [] buf; -} - -TEST(AddressSanitizer, asm_rw) { - TestAsmWrite("WRITE of size 1"); - TestAsmWrite("WRITE of size 2"); - TestAsmWrite("WRITE of size 4"); -#if defined(__x86_64__) - TestAsmWrite("WRITE of size 8"); -#endif // defined(__x86_64__) - TestAsmWrite<__m128i>("WRITE of size 16"); - - TestAsmRead("READ of size 1"); - TestAsmRead("READ of size 2"); - TestAsmRead("READ of size 4"); -#if defined(__x86_64__) - TestAsmRead("READ of size 8"); -#endif // defined(__x86_64__) - TestAsmRead<__m128i>("READ of size 16"); -} - -TEST(AddressSanitizer, asm_flags) { - long magic = 0x1234; - long r = 0x0; - -#if defined(__x86_64__) && !defined(__ILP32__) - __asm__("xorq %%rax, %%rax \n\t" - "movq (%[p]), %%rax \n\t" - "sete %%al \n\t" - "movzbq %%al, %[r] \n\t" - : [r] "=r"(r) - : [p] "r"(&magic) - : "rax", "memory"); -#else - __asm__("xorl %%eax, %%eax \n\t" - "movl (%[p]), %%eax \n\t" - "sete %%al \n\t" - "movzbl %%al, %[r] \n\t" - : [r] "=r"(r) - : [p] "r"(&magic) - : "eax", "memory"); -#endif // defined(__x86_64__) && !defined(__ILP32__) - - ASSERT_EQ(0x1, r); -} - -TEST(AddressSanitizer, asm_rep_movs) { - TestAsmRepMovs("READ of size 1", "WRITE of size 1"); - TestAsmRepMovs("READ of size 2", "WRITE of size 2"); - TestAsmRepMovs("READ of size 4", "WRITE of size 4"); -#if defined(__x86_64__) - TestAsmRepMovs("READ of size 8", "WRITE of size 8"); -#endif // defined(__x86_64__) -} - -#endif // defined(__x86_64__) || (defined(__i386__) && defined(__SSE2__)) - -#endif // defined(__linux__) -- cgit v1.2.1 From 8c62dad052ef0a703f72d67fd2291e393449abb4 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 12 Mar 2019 21:02:15 +0000 Subject: AddressSanitizer: fix for SPARC with GCC Summary: This patch contains a fixlet for the AddressSanitizer on the SPARC with GCC, which would otherwise generate a problematic call to the intercepted memcpy routine. It was tested with GCC on SPARC/Solaris and SPARC/Linux. Patch by Eric Botcazou. Reviewers: #sanitizers, vitalybuka Reviewed By: #sanitizers, vitalybuka Subscribers: vitalybuka, ro, jyknight, kubamracek, fedor.sergeev, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58433 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355979 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_globals.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/asan') diff --git a/lib/asan/asan_globals.cc b/lib/asan/asan_globals.cc index d9c875550..8b2fdb214 100644 --- a/lib/asan/asan_globals.cc +++ b/lib/asan/asan_globals.cc @@ -115,7 +115,11 @@ int GetGlobalsForAddress(uptr addr, Global *globals, u32 *reg_sites, if (flags()->report_globals >= 2) ReportGlobal(g, "Search"); if (IsAddressNearGlobal(addr, g)) { +#if defined(__GNUC__) && defined(__sparc__) + internal_memcpy(&globals[res], &g, sizeof(g)); +#else globals[res] = g; +#endif if (reg_sites) reg_sites[res] = FindRegistrationSite(&g); res++; -- cgit v1.2.1 From a0c8d98e1c90f4d0b7370835cce399cb9bf54ceb Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Tue, 12 Mar 2019 21:02:24 +0000 Subject: AddressSanitizer: 64-bit SPARC/Linux port Summary: This patch contains the bits required to make the AddressSanitizer work on SPARC64/Linux (SPARC-T4 and later). Patch by Eric Botcazou. Reviewers: #sanitizers, vitalybuka, krytarowski Reviewed By: #sanitizers, vitalybuka Subscribers: brad, vitalybuka, ro, jyknight, kubamracek, fedor.sergeev, jdoerfert, llvm-commits, #sanitizers Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D58434 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@355980 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_allocator.h | 6 ++- lib/asan/asan_mapping.h | 12 +++++ lib/asan/asan_mapping_sparc64.h | 101 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 lib/asan/asan_mapping_sparc64.h (limited to 'lib/asan') diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h index c8987ac9e..f00776c94 100644 --- a/lib/asan/asan_allocator.h +++ b/lib/asan/asan_allocator.h @@ -133,11 +133,15 @@ const uptr kAllocatorSpace = ~(uptr)0; const uptr kAllocatorSize = 0x2000000000ULL; // 128G. typedef VeryCompactSizeClassMap SizeClassMap; # elif defined(__aarch64__) -// AArch64/SANITIZER_CAN_USER_ALLOCATOR64 is only for 42-bit VMA +// AArch64/SANITIZER_CAN_USE_ALLOCATOR64 is only for 42-bit VMA // so no need to different values for different VMA. const uptr kAllocatorSpace = 0x10000000000ULL; const uptr kAllocatorSize = 0x10000000000ULL; // 3T. typedef DefaultSizeClassMap SizeClassMap; +#elif defined(__sparc__) +const uptr kAllocatorSpace = ~(uptr)0; +const uptr kAllocatorSize = 0x20000000000ULL; // 2T. +typedef DefaultSizeClassMap SizeClassMap; # elif SANITIZER_WINDOWS const uptr kAllocatorSpace = ~(uptr)0; const uptr kAllocatorSize = 0x8000000000ULL; // 500G diff --git a/lib/asan/asan_mapping.h b/lib/asan/asan_mapping.h index c8b00299f..2a32a23e1 100644 --- a/lib/asan/asan_mapping.h +++ b/lib/asan/asan_mapping.h @@ -100,6 +100,13 @@ // || `[0x10000000000000, 0x11ffffffffffff]` || LowShadow || // || `[0x00000000000000, 0x0fffffffffffff]` || LowMem || // +// Default Linux/SPARC64 (52-bit VMA) mapping: +// || `[0x8000000000000, 0xfffffffffffff]` || HighMem || +// || `[0x1080000000000, 0x207ffffffffff]` || HighShadow || +// || `[0x0090000000000, 0x107ffffffffff]` || ShadowGap || +// || `[0x0080000000000, 0x008ffffffffff]` || LowShadow || +// || `[0x0000000000000, 0x007ffffffffff]` || LowMem || +// // Shadow mapping on FreeBSD/x86-64 with SHADOW_OFFSET == 0x400000000000: // || `[0x500000000000, 0x7fffffffffff]` || HighMem || // || `[0x4a0000000000, 0x4fffffffffff]` || HighShadow || @@ -162,6 +169,7 @@ static const u64 kMIPS32_ShadowOffset32 = 0x0aaa0000; static const u64 kMIPS64_ShadowOffset64 = 1ULL << 37; 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 static const u64 kFreeBSD_ShadowOffset64 = 1ULL << 46; // 0x400000000000 static const u64 kNetBSD_ShadowOffset32 = 1ULL << 30; // 0x40000000 @@ -224,6 +232,8 @@ static const u64 kMyriadCacheBitMask32 = 0x40000000ULL; # define SHADOW_OFFSET kDefaultShadowOffset64 # elif defined(__mips64) # define SHADOW_OFFSET kMIPS64_ShadowOffset64 +#elif defined(__sparc__) +#define SHADOW_OFFSET kSPARC64_ShadowOffset64 # elif SANITIZER_WINDOWS64 # define SHADOW_OFFSET __asan_shadow_memory_dynamic_address # else @@ -270,6 +280,8 @@ extern uptr kHighMemEnd, kMidMemBeg, kMidMemEnd; // Initialized in __asan_init. #if SANITIZER_MYRIAD2 #include "asan_mapping_myriad.h" +#elif defined(__sparc__) && SANITIZER_WORDSIZE == 64 +#include "asan_mapping_sparc64.h" #else #define MEM_TO_SHADOW(mem) (((mem) >> SHADOW_SCALE) + (SHADOW_OFFSET)) diff --git a/lib/asan/asan_mapping_sparc64.h b/lib/asan/asan_mapping_sparc64.h new file mode 100644 index 000000000..432a1816f --- /dev/null +++ b/lib/asan/asan_mapping_sparc64.h @@ -0,0 +1,101 @@ +//===-- asan_mapping_sparc64.h ----------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// SPARC64-specific definitions for ASan memory mapping. +//===----------------------------------------------------------------------===// +#ifndef ASAN_MAPPING_SPARC64_H +#define ASAN_MAPPING_SPARC64_H + +// This is tailored to the 52-bit VM layout on SPARC-T4 and later. +// The VM space is split into two 51-bit halves at both ends: the low part +// has all the bits above the 51st cleared, while the high part has them set. +// 0xfff8000000000000 - 0xffffffffffffffff +// 0x0000000000000000 - 0x0007ffffffffffff + +#define VMA_BITS 52 +#define HIGH_BITS (64 - VMA_BITS) + +// The idea is to chop the high bits before doing the scaling, so the two +// parts become contiguous again and the usual scheme can be applied. + +#define MEM_TO_SHADOW(mem) \ + ((((mem) << HIGH_BITS) >> (HIGH_BITS + (SHADOW_SCALE))) + (SHADOW_OFFSET)) + +#define kLowMemBeg 0 +#define kLowMemEnd (SHADOW_OFFSET - 1) + +#define kLowShadowBeg SHADOW_OFFSET +#define kLowShadowEnd MEM_TO_SHADOW(kLowMemEnd) + +// But of course there is the huge hole between the high shadow memory, +// which is in the low part, and the beginning of the high part. + +#define kHighMemBeg (-(1ULL << (VMA_BITS - 1))) + +#define kHighShadowBeg MEM_TO_SHADOW(kHighMemBeg) +#define kHighShadowEnd MEM_TO_SHADOW(kHighMemEnd) + +#define kMidShadowBeg 0 +#define kMidShadowEnd 0 + +// With the zero shadow base we can not actually map pages starting from 0. +// This constant is somewhat arbitrary. +#define kZeroBaseShadowStart 0 +#define kZeroBaseMaxShadowStart (1 << 18) + +#define kShadowGapBeg (kLowShadowEnd + 1) +#define kShadowGapEnd (kHighShadowBeg - 1) + +#define kShadowGap2Beg 0 +#define kShadowGap2End 0 + +#define kShadowGap3Beg 0 +#define kShadowGap3End 0 + +namespace __asan { + +static inline bool AddrIsInLowMem(uptr a) { + PROFILE_ASAN_MAPPING(); + return a <= kLowMemEnd; +} + +static inline bool AddrIsInLowShadow(uptr a) { + PROFILE_ASAN_MAPPING(); + return a >= kLowShadowBeg && a <= kLowShadowEnd; +} + +static inline bool AddrIsInMidMem(uptr a) { + PROFILE_ASAN_MAPPING(); + return false; +} + +static inline bool AddrIsInMidShadow(uptr a) { + PROFILE_ASAN_MAPPING(); + return false; +} + +static inline bool AddrIsInHighMem(uptr a) { + PROFILE_ASAN_MAPPING(); + return kHighMemBeg && a >= kHighMemBeg && a <= kHighMemEnd; +} + +static inline bool AddrIsInHighShadow(uptr a) { + PROFILE_ASAN_MAPPING(); + return kHighMemBeg && a >= kHighShadowBeg && a <= kHighShadowEnd; +} + +static inline bool AddrIsInShadowGap(uptr a) { + PROFILE_ASAN_MAPPING(); + return a >= kShadowGapBeg && a <= kShadowGapEnd; +} + +} // namespace __asan + +#endif // ASAN_MAPPING_SPARC64_H -- cgit v1.2.1 From 6501387ab1311ccf724bb5c5de499465110442b1 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Mon, 8 Apr 2019 22:28:27 +0000 Subject: [asan_symbolize] Use proper logging infrastructure. Summary: The previous logging infrastructure had several problems: * Debugging output was emitted to standard output which is also where the symbolized output would go. Interleaving these two separate bits of information makes inspecting the output difficult and could potentially break tests. * Enabling debugging output requires modifying the script which is not very conveninent. * When debugging it isn't immediately obvious where the output is coming from. This patch uses the Python standard library logging infrastructure which fixes all of the above problems. Logging is controlled using two new options. * `--log-level` - Sets the logging level, default is `info`. * `--log-dest` - Set the logging destination, default is standard error. Some simple test cases for the feature are included. rdar://problem/49476995 Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D60343 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@357951 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/scripts/asan_symbolize.py | 63 +++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 14 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/scripts/asan_symbolize.py b/lib/asan/scripts/asan_symbolize.py index 5cb42c656..840e90128 100755 --- a/lib/asan/scripts/asan_symbolize.py +++ b/lib/asan/scripts/asan_symbolize.py @@ -9,13 +9,13 @@ import argparse import bisect import getopt +import logging import os import re import subprocess import sys symbolizers = {} -DEBUG = False demangle = False binutils_prefix = None sysroot_path = None @@ -87,8 +87,7 @@ class LLVMSymbolizer(Symbolizer): if self.system == 'Darwin': for hint in self.dsym_hints: cmd.append('--dsym-hint=%s' % hint) - if DEBUG: - print(' '.join(cmd)) + logging.debug(' '.join(cmd)) try: result = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, @@ -105,8 +104,7 @@ class LLVMSymbolizer(Symbolizer): result = [] try: symbolizer_input = '"%s" %s' % (binary, offset) - if DEBUG: - print(symbolizer_input) + logging.debug(symbolizer_input) self.pipe.stdin.write("%s\n" % symbolizer_input) while True: function_name = self.pipe.stdout.readline().rstrip() @@ -151,8 +149,7 @@ class Addr2LineSymbolizer(Symbolizer): if demangle: cmd += ['--demangle'] cmd += ['-e', self.binary] - if DEBUG: - print(' '.join(cmd)) + logging.debug(' '.join(cmd)) return subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, bufsize=0, @@ -221,8 +218,7 @@ class DarwinSymbolizer(Symbolizer): self.open_atos() def open_atos(self): - if DEBUG: - print('atos -o %s -arch %s' % (self.binary, self.arch)) + logging.debug('atos -o %s -arch %s', self.binary, self.arch) cmdline = ['atos', '-o', self.binary, '-arch', self.arch] self.atos = UnbufferedLineConverter(cmdline, close_stderr=True) @@ -240,8 +236,7 @@ class DarwinSymbolizer(Symbolizer): # A well-formed atos response looks like this: # foo(type1, type2) (in object.name) (filename.cc:80) match = re.match('^(.*) \(in (.*)\) \((.*:\d*)\)$', atos_line) - if DEBUG: - print('atos_line: ', atos_line) + logging.debug('atos_line: %s', atos_line) if match: function_name = match.group(1) function_name = re.sub('\(.*?\)', '', function_name) @@ -454,8 +449,7 @@ class SymbolizationLoop(object): match = re.match(stack_trace_line_format, line) if not match: return [self.current_line] - if DEBUG: - print(line) + logging.debug(line) _, frameno_str, addr, binary, offset = match.groups() arch = "" # Arch can be embedded in the filename, e.g.: "libabc.dylib:x86_64h" @@ -479,8 +473,47 @@ class SymbolizationLoop(object): symbolized_line = self.symbolize_address(addr, original_binary, offset, arch) return self.get_symbolized_lines(symbolized_line) +def add_logging_args(parser): + parser.add_argument('--log-dest', + default=None, + help='Destination path for script logging (default stderr).', + ) + parser.add_argument('--log-level', + choices=['debug', 'info', 'warning', 'error', 'critical'], + default='info', + help='Log level for script (default: %(default)s).' + ) + +def setup_logging(): + # Set up a parser just for parsing the logging arguments. + # This is necessary because logging should be configured before we + # perform the main argument parsing. + parser = argparse.ArgumentParser(add_help=False) + add_logging_args(parser) + pargs, unparsed_args = parser.parse_known_args() + + log_level = getattr(logging, pargs.log_level.upper()) + if log_level == logging.DEBUG: + log_format = '%(levelname)s: [%(funcName)s() %(filename)s:%(lineno)d] %(message)s' + else: + log_format = '%(levelname)s: %(message)s' + basic_config = { + 'level': log_level, + 'format': log_format + } + log_dest = pargs.log_dest + if log_dest: + basic_config['filename'] = log_dest + logging.basicConfig(**basic_config) + logging.debug('Logging level set to "{}" and directing output to "{}"'.format( + pargs.log_level, + 'stderr' if log_dest is None else log_dest) + ) + return unparsed_args + if __name__ == '__main__': + remaining_args = setup_logging() parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description='ASan symbolization script', @@ -500,7 +533,9 @@ if __name__ == '__main__': help='set log file name to parse, default is stdin') parser.add_argument('--force-system-symbolizer', action='store_true', help='don\'t use llvm-symbolizer') - args = parser.parse_args() + # Add logging arguments so that `--help` shows them. + add_logging_args(parser) + args = parser.parse_args(remaining_args) if args.path_to_cut: fix_filename_patterns = args.path_to_cut if args.demangle: -- cgit v1.2.1 From 75e6f6652f6b35852e64570a93312ab1e9480855 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 9 Apr 2019 08:30:43 +0000 Subject: [asan_symbolize] Move argument parser epilog text into script doc comment. Summary: This will make it easier to expand on the documentation in the future that avoids cluttering the code. rdar://problem/49476995 Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D60398 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@357978 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/scripts/asan_symbolize.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/scripts/asan_symbolize.py b/lib/asan/scripts/asan_symbolize.py index 840e90128..c96fb380b 100755 --- a/lib/asan/scripts/asan_symbolize.py +++ b/lib/asan/scripts/asan_symbolize.py @@ -6,6 +6,10 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # #===------------------------------------------------------------------------===# +""" +Example of use: + asan_symbolize.py -c "$HOME/opt/cross/bin/arm-linux-gnueabi-" -s "$HOME/SymbolFiles" < asan.log +""" import argparse import bisect import getopt @@ -517,9 +521,7 @@ if __name__ == '__main__': parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, description='ASan symbolization script', - epilog='Example of use:\n' - 'asan_symbolize.py -c "$HOME/opt/cross/bin/arm-linux-gnueabi-" ' - '-s "$HOME/SymbolFiles" < asan.log') + epilog=__doc__) parser.add_argument('path_to_cut', nargs='*', help='pattern to be cut from the result file path ') parser.add_argument('-d','--demangle', action='store_true', -- cgit v1.2.1 From 1ba1ef620add382f8cc371019eb0bb1ab3fc1b54 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 18 Apr 2019 11:34:31 +0000 Subject: [asan_symbolize] Add a simple plugin architecture Summary: This change adds a simple plugin architecture to `asan_symbolize.py`. The motivation here is that sometimes it's necessary to perform extra work to figure out where binaries with debug symbols can actually be found. For example it might be the case that a remote service needs to be queried for binaries and then copied to the local system. This "extra work" can be extremely site-specific such that adding the code directly into the `asan_symbolize.py` would just clutter the code for a very niche use case. To avoid this, the `asan_symbolize.py` can now load external code via a new `--plugins` command line option. These plugins are loaded before main command line argument parsing so that they can add their own command line options. Right now the only hook into the behaviour of symbolization is the `filter_binary_path()` function which assumes a very similar role to the `binary_name_filter` function that was previously in the code. We can add more hooks as necessary. Code in the `asan_symbolize.py` script does not call plugin code directly. Instead it uses a `AsanSymbolizerPlugInProxy` object. This object * Loads plugins from files. * Manages the lifetime of the plugins. * Provides an interface for calling into plugin functions and handles calling into multiple plugins. To unify the way binary paths are filtered the old `sysroot_path_filter` function (and associated code) has been turned into a simple plugin (`SysRootFilterPlugIn`) that is always loaded. The plugin unloads itself if the `-s` option is not present on the command line. Users should not see any functional change relating to this command line option. Some simple tests are provided to illustrate what plugin code looks like and also to check the functionality continues to work. rdar://problem/49476995 Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka Subscribers: srhines, #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D60529 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@358657 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/scripts/asan_symbolize.py | 283 ++++++++++++++++++++++++++++++------- 1 file changed, 235 insertions(+), 48 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/scripts/asan_symbolize.py b/lib/asan/scripts/asan_symbolize.py index c96fb380b..d3025e3cc 100755 --- a/lib/asan/scripts/asan_symbolize.py +++ b/lib/asan/scripts/asan_symbolize.py @@ -9,6 +9,15 @@ """ Example of use: asan_symbolize.py -c "$HOME/opt/cross/bin/arm-linux-gnueabi-" -s "$HOME/SymbolFiles" < asan.log + +PLUGINS + +This script provides a way for external plug-ins to hook into the behaviour of +various parts of this script (see `--plugins`). This is useful for situations +where it is necessary to handle site-specific quirks (e.g. binaries with debug +symbols only accessible via a remote service) without having to modify the +script itself. + """ import argparse import bisect @@ -22,8 +31,6 @@ import sys symbolizers = {} demangle = False binutils_prefix = None -sysroot_path = None -binary_name_filter = None fix_filename_patterns = None logfile = sys.stdin allow_system_symbolizer = True @@ -38,9 +45,6 @@ def fix_filename(file_name): file_name = re.sub('.*crtstuff.c:0', '???:0', file_name) return file_name -def sysroot_path_filter(binary_name): - return sysroot_path + binary_name - def is_valid_arch(s): return s in ["i386", "x86_64", "x86_64h", "arm", "armv6", "armv7", "armv7s", "armv7k", "arm64", "powerpc64", "powerpc64le", "s390x", "s390"] @@ -361,7 +365,8 @@ class BreakpadSymbolizer(Symbolizer): class SymbolizationLoop(object): - def __init__(self, binary_name_filter=None, dsym_hint_producer=None): + def __init__(self, plugin_proxy=None, dsym_hint_producer=None): + self.plugin_proxy = plugin_proxy if sys.platform == 'win32': # ASan on Windows uses dbghelp.dll to symbolize in-process, which works # even in sandboxed processes. Nothing needs to be done here. @@ -369,7 +374,6 @@ class SymbolizationLoop(object): else: # Used by clients who may want to supply a different binary name. # E.g. in Chrome several binaries may share a single .dSYM. - self.binary_name_filter = binary_name_filter self.dsym_hint_producer = dsym_hint_producer self.system = os.uname()[0] if self.system not in ['Linux', 'Darwin', 'FreeBSD', 'NetBSD','SunOS']: @@ -469,14 +473,183 @@ class SymbolizationLoop(object): # Assume that frame #0 is the first frame of new stack trace. self.frame_no = 0 original_binary = binary - if self.binary_name_filter: - binary = self.binary_name_filter(binary) + binary = self.plugin_proxy.filter_binary_path(binary) + if binary is None: + # The binary filter has told us this binary can't be symbolized. + logging.debug('Skipping symbolication of binary "%s"', original_binary) + return [self.current_line] symbolized_line = self.symbolize_address(addr, binary, offset, arch) if not symbolized_line: if original_binary != binary: symbolized_line = self.symbolize_address(addr, original_binary, offset, arch) return self.get_symbolized_lines(symbolized_line) +class AsanSymbolizerPlugInProxy(object): + """ + Serves several purposes: + - Manages the lifetime of plugins (must be used a `with` statement). + - Provides interface for calling into plugins from within this script. + """ + def __init__(self): + self._plugins = [ ] + self._plugin_names = set() + + def load_plugin_from_file(self, file_path): + logging.info('Loading plugins from "{}"'.format(file_path)) + globals_space = dict(globals()) + # Provide function to register plugins + def register_plugin(plugin): + logging.info('Registering plugin %s', plugin.get_name()) + self.add_plugin(plugin) + globals_space['register_plugin'] = register_plugin + if sys.version_info.major < 3: + execfile(file_path, globals_space, None) + else: + with open(file_path, 'r') as f: + exec(f.read(), globals_space, None) + + def add_plugin(self, plugin): + assert isinstance(plugin, AsanSymbolizerPlugIn) + self._plugins.append(plugin) + self._plugin_names.add(plugin.get_name()) + plugin._receive_proxy(self) + + def remove_plugin(self, plugin): + assert isinstance(plugin, AsanSymbolizerPlugIn) + self._plugins.remove(plugin) + self._plugin_names.remove(plugin.get_name()) + logging.debug('Removing plugin %s', plugin.get_name()) + plugin.destroy() + + def has_plugin(self, name): + """ + Returns true iff the plugin name is currently + being managed by AsanSymbolizerPlugInProxy. + """ + return name in self._plugin_names + + def register_cmdline_args(self, parser): + plugins = list(self._plugins) + for plugin in plugins: + plugin.register_cmdline_args(parser) + + def process_cmdline_args(self, pargs): + # Use copy so we can remove items as we iterate. + plugins = list(self._plugins) + for plugin in plugins: + keep = plugin.process_cmdline_args(pargs) + assert isinstance(keep, bool) + if not keep: + self.remove_plugin(plugin) + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_val, exc_tb): + for plugin in self._plugins: + plugin.destroy() + # Don't suppress raised exceptions + return False + + def _filter_single_value(self, function_name, input_value): + """ + Helper for filter style plugin functions. + """ + new_value = input_value + for plugin in self._plugins: + result = getattr(plugin, function_name)(new_value) + if result is None: + return None + new_value = result + return new_value + + def filter_binary_path(self, binary_path): + """ + Consult available plugins to filter the path to a binary + to make it suitable for symbolication. + + Returns `None` if symbolication should not be attempted for this + binary. + """ + return self._filter_single_value('filter_binary_path', binary_path) + +class AsanSymbolizerPlugIn(object): + """ + This is the interface the `asan_symbolize.py` code uses to talk + to plugins. + """ + @classmethod + def get_name(cls): + """ + Returns the name of the plugin. + """ + return cls.__name__ + + def _receive_proxy(self, proxy): + assert isinstance(proxy, AsanSymbolizerPlugInProxy) + self.proxy = proxy + + def register_cmdline_args(self, parser): + """ + Hook for registering command line arguments to be + consumed in `process_cmdline_args()`. + + `parser` - Instance of `argparse.ArgumentParser`. + """ + pass + + def process_cmdline_args(self, pargs): + """ + Hook for handling parsed arguments. Implementations + should not modify `pargs`. + + `pargs` - Instance of `argparse.Namespace` containing + parsed command line arguments. + + Return `True` if plug-in should be used, otherwise + return `False`. + """ + return True + + def destroy(self): + """ + Hook called when a plugin is about to be destroyed. + Implementations should free any allocated resources here. + """ + pass + + # Symbolization hooks + def filter_binary_path(self, binary_path): + """ + Given a binary path return a binary path suitable for symbolication. + + Implementations should return `None` if symbolication of this binary + should be skipped. + """ + return binary_path + +class SysRootFilterPlugIn(AsanSymbolizerPlugIn): + """ + Simple plug-in to add sys root prefix to all binary paths + used for symbolication. + """ + def __init__(self): + self.sysroot_path = "" + + def register_cmdline_args(self, parser): + parser.add_argument('-s', dest='sys_root', metavar='SYSROOT', + help='set path to sysroot for sanitized binaries') + + def process_cmdline_args(self, pargs): + if pargs.sys_root is None: + # Not being used so remove ourselves. + return False + self.sysroot_path = pargs.sys_root + return True + + def filter_binary_path(self, path): + return self.sysroot_path + path + def add_logging_args(parser): parser.add_argument('--log-dest', default=None, @@ -515,45 +688,59 @@ def setup_logging(): ) return unparsed_args +def add_load_plugin_args(parser): + parser.add_argument('-p', '--plugins', + help='Load plug-in', nargs='+', default=[]) + +def setup_plugins(plugin_proxy, args): + parser = argparse.ArgumentParser(add_help=False) + add_load_plugin_args(parser) + pargs , unparsed_args = parser.parse_known_args() + for plugin_path in pargs.plugins: + plugin_proxy.load_plugin_from_file(plugin_path) + # Add built-in plugins. + plugin_proxy.add_plugin(SysRootFilterPlugIn()) + return unparsed_args if __name__ == '__main__': remaining_args = setup_logging() - parser = argparse.ArgumentParser( - formatter_class=argparse.RawDescriptionHelpFormatter, - description='ASan symbolization script', - epilog=__doc__) - parser.add_argument('path_to_cut', nargs='*', - help='pattern to be cut from the result file path ') - parser.add_argument('-d','--demangle', action='store_true', - help='demangle function names') - parser.add_argument('-s', metavar='SYSROOT', - help='set path to sysroot for sanitized binaries') - parser.add_argument('-c', metavar='CROSS_COMPILE', - help='set prefix for binutils') - parser.add_argument('-l','--logfile', default=sys.stdin, - type=argparse.FileType('r'), - help='set log file name to parse, default is stdin') - parser.add_argument('--force-system-symbolizer', action='store_true', - help='don\'t use llvm-symbolizer') - # Add logging arguments so that `--help` shows them. - add_logging_args(parser) - args = parser.parse_args(remaining_args) - if args.path_to_cut: - fix_filename_patterns = args.path_to_cut - if args.demangle: - demangle = True - if args.s: - binary_name_filter = sysroot_path_filter - sysroot_path = args.s - if args.c: - binutils_prefix = args.c - if args.logfile: - logfile = args.logfile - else: - logfile = sys.stdin - if args.force_system_symbolizer: - force_system_symbolizer = True - if force_system_symbolizer: - assert(allow_system_symbolizer) - loop = SymbolizationLoop(binary_name_filter) - loop.process_logfile() + with AsanSymbolizerPlugInProxy() as plugin_proxy: + remaining_args = setup_plugins(plugin_proxy, remaining_args) + parser = argparse.ArgumentParser( + formatter_class=argparse.RawDescriptionHelpFormatter, + description='ASan symbolization script', + epilog=__doc__) + parser.add_argument('path_to_cut', nargs='*', + help='pattern to be cut from the result file path ') + parser.add_argument('-d','--demangle', action='store_true', + help='demangle function names') + parser.add_argument('-c', metavar='CROSS_COMPILE', + help='set prefix for binutils') + parser.add_argument('-l','--logfile', default=sys.stdin, + type=argparse.FileType('r'), + help='set log file name to parse, default is stdin') + parser.add_argument('--force-system-symbolizer', action='store_true', + help='don\'t use llvm-symbolizer') + # Add logging arguments so that `--help` shows them. + add_logging_args(parser) + # Add load plugin arguments so that `--help` shows them. + add_load_plugin_args(parser) + plugin_proxy.register_cmdline_args(parser) + args = parser.parse_args(remaining_args) + plugin_proxy.process_cmdline_args(args) + if args.path_to_cut: + fix_filename_patterns = args.path_to_cut + if args.demangle: + demangle = True + if args.c: + binutils_prefix = args.c + if args.logfile: + logfile = args.logfile + else: + logfile = sys.stdin + if args.force_system_symbolizer: + force_system_symbolizer = True + if force_system_symbolizer: + assert(allow_system_symbolizer) + loop = SymbolizationLoop(plugin_proxy) + loop.process_logfile() -- cgit v1.2.1 From 80bfad5126fd9e41dd3aa03f8cde6642789c5962 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 18 Apr 2019 16:22:55 +0000 Subject: [asan_symbolize] Workaround bug in old Python 2 versions. The change landed in r358657 broke some of the buildbots because they use an older version of Python 2 that raises this error. ``` File "/Volumes/data/dev/llvm/upstream/master/src/projects/compiler-rt/lib/asan/scripts/asan_symbolize.py", line 509 exec(f.read(), globals_space, None) SyntaxError: unqualified exec is not allowed in function 'load_plugin_from_file' it contains a nested function with free variables ``` I can reproduce this problem when using Python 2.7.6. To workaround this some indirection has been added to prevent the broken (the line at fault would never be executed) SyntaxError error in old Python versions from being raised. rdar://problem/49476995 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@358682 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/scripts/asan_symbolize.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/scripts/asan_symbolize.py b/lib/asan/scripts/asan_symbolize.py index d3025e3cc..01b816cf6 100755 --- a/lib/asan/scripts/asan_symbolize.py +++ b/lib/asan/scripts/asan_symbolize.py @@ -494,6 +494,10 @@ class AsanSymbolizerPlugInProxy(object): self._plugins = [ ] self._plugin_names = set() + def _load_plugin_from_file_impl_py_gt_2(self, file_path, globals_space): + with open(file_path, 'r') as f: + exec(f.read(), globals_space, None) + def load_plugin_from_file(self, file_path): logging.info('Loading plugins from "{}"'.format(file_path)) globals_space = dict(globals()) @@ -505,8 +509,9 @@ class AsanSymbolizerPlugInProxy(object): if sys.version_info.major < 3: execfile(file_path, globals_space, None) else: - with open(file_path, 'r') as f: - exec(f.read(), globals_space, None) + # Indirection here is to avoid a bug in older Python 2 versions: + # `SyntaxError: unqualified exec is not allowed in function ...` + self._load_plugin_from_file_impl_py_gt_2(file_path, globals_space) def add_plugin(self, plugin): assert isinstance(plugin, AsanSymbolizerPlugIn) -- cgit v1.2.1 From 4a1c068085b733a4c08b5980a7967f47c3df3509 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Fri, 26 Apr 2019 16:54:09 +0000 Subject: [asan_symbolize] Teach `asan_symbolize.py` to symbolicate using a module map Summary: The use case here is to be able get the UUIDs of the modules that need to be symbolicated so that external plugins can see them. This information can be extracted from ASan reports if the `print_module_map` ASan option is enabled. Currently printing of the module map is only implemented on Darwin and so this is effectively a Darwin only feature right now. The module map hooks into symbolization using the new plugin infrastructure. A new hook in `AsanSymbolizerPlugInProxy` (and in `AsanSymbolizerPlugIn`) is also provided to allow external plugins to hook into the module look up process. This will allow external plugins to look up modules with knowledge of their UUID. The new plug-in is currently stored in the `asan_symbolize.py` script. We could potentially move this into a separate file in the future (to reduce clutter) if we can come up with a policy for where to search for plugins that should always get loaded. rdar://problem/49476995 Reviewers: kubamracek, yln, samsonov, dvyukov, vitalybuka Subscribers: #sanitizers, llvm-commits Tags: #llvm, #sanitizers Differential Revision: https://reviews.llvm.org/D60531 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359322 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/scripts/asan_symbolize.py | 243 +++++++++++++++++++++++++++++++++++++ 1 file changed, 243 insertions(+) (limited to 'lib/asan') diff --git a/lib/asan/scripts/asan_symbolize.py b/lib/asan/scripts/asan_symbolize.py index 01b816cf6..4fb3355d7 100755 --- a/lib/asan/scripts/asan_symbolize.py +++ b/lib/asan/scripts/asan_symbolize.py @@ -578,6 +578,16 @@ class AsanSymbolizerPlugInProxy(object): """ return self._filter_single_value('filter_binary_path', binary_path) + def filter_module_desc(self, module_desc): + """ + Consult available plugins to determine the module + description suitable for symbolication. + + Returns `None` if symbolication should not be attempted for this module. + """ + assert isinstance(module_desc, ModuleDesc) + return self._filter_single_value('filter_module_desc', module_desc) + class AsanSymbolizerPlugIn(object): """ This is the interface the `asan_symbolize.py` code uses to talk @@ -633,6 +643,213 @@ class AsanSymbolizerPlugIn(object): """ return binary_path + def filter_module_desc(self, module_desc): + """ + Given a ModuleDesc object (`module_desc`) return + a ModuleDesc suitable for symbolication. + + Implementations should return `None` if symbolication of this binary + should be skipped. + """ + return module_desc + +class ModuleDesc(object): + def __init__(self, name, arch, start_addr, end_addr, module_path, uuid): + self.name = name + self.arch = arch + self.start_addr = start_addr + self.end_addr = end_addr + # Module path from an ASan report. + self.module_path = module_path + # Module for performing symbolization, by default same as above. + self.module_path_for_symbolization = module_path + self.uuid = uuid + assert self.is_valid() + + def __str__(self): + assert self.is_valid() + return "{name} {arch} {start_addr:#016x}-{end_addr:#016x} {module_path} {uuid}".format( + name=self.name, + arch=self.arch, + start_addr=self.start_addr, + end_addr=self.end_addr, + module_path=self.module_path if self.module_path == self.module_path_for_symbolization else '{} ({})'.format(self.module_path_for_symbolization, self.module_path), + uuid=self.uuid + ) + + def is_valid(self): + if not isinstance(self.name, str): + return False + if not isinstance(self.arch, str): + return False + if not isinstance(self.start_addr, int): + return False + if self.start_addr < 0: + return False + if not isinstance(self.end_addr, int): + return False + if self.end_addr <= self.start_addr: + return False + if not isinstance(self.module_path, str): + return False + if not os.path.isabs(self.module_path): + return False + if not isinstance(self.module_path_for_symbolization, str): + return False + if not os.path.isabs(self.module_path_for_symbolization): + return False + if not isinstance(self.uuid, str): + return False + return True + +class GetUUIDFromBinaryException(Exception): + def __init__(self, msg): + super(GetUUIDFromBinaryException, self).__init__(msg) + +_get_uuid_from_binary_cache = dict() + +def get_uuid_from_binary(path_to_binary, arch=None): + cache_key = (path_to_binary, arch) + cached_value = _get_uuid_from_binary_cache.get(cache_key) + if cached_value: + return cached_value + if not os.path.exists(path_to_binary): + raise GetUUIDFromBinaryException('Binary "{}" does not exist'.format(path_to_binary)) + cmd = [ '/usr/bin/otool', '-l'] + if arch: + cmd.extend(['-arch', arch]) + cmd.append(path_to_binary) + output = subprocess.check_output(cmd, stderr=subprocess.STDOUT) + # Look for this output: + # cmd LC_UUID + # cmdsize 24 + # uuid 4CA778FE-5BF9-3C45-AE59-7DF01B2BE83F + if isinstance(output, str): + output_str = output + else: + assert isinstance(output, bytes) + output_str = output.decode() + assert isinstance(output_str, str) + lines = output_str.split('\n') + uuid = None + for index, line in enumerate(lines): + stripped_line = line.strip() + if not stripped_line.startswith('cmd LC_UUID'): + continue + uuid_line = lines[index+2].strip() + if not uuid_line.startswith('uuid'): + raise GetUUIDFromBinaryException('Malformed output: "{}"'.format(uuid_line)) + split_uuid_line = uuid_line.split() + uuid = split_uuid_line[1] + break + if uuid is None: + raise GetUUIDFromBinaryException('Failed to retrieve UUID') + else: + # Update cache + _get_uuid_from_binary_cache[cache_key] = uuid + return uuid + +class ModuleMap(object): + def __init__(self): + self._module_name_to_description_map = dict() + + def add_module(self, desc): + assert isinstance(desc, ModuleDesc) + assert desc.name not in self._module_name_to_description_map + self._module_name_to_description_map[desc.name] = desc + + def find_module_by_name(self, name): + return self._module_name_to_description_map.get(name, None) + + def __str__(self): + s = '{} modules:\n'.format(self.num_modules) + for module_desc in sorted(self._module_name_to_description_map.values(), key=lambda v: v.start_addr): + s += str(module_desc) + '\n' + return s + + @property + def num_modules(self): + return len(self._module_name_to_description_map) + + @property + def modules(self): + return set(self._module_name_to_description_map.values()) + + def get_module_path_for_symbolication(self, module_name, proxy): + module_desc = self.find_module_by_name(module_name) + if module_desc is None: + return None + # Allow a plug-in to change the module description to make it + # suitable for symbolication or avoid symbolication altogether. + module_desc = proxy.filter_module_desc(module_desc) + if module_desc is None: + return None + try: + uuid = get_uuid_from_binary(module_desc.module_path_for_symbolization, arch = module_desc.arch) + if uuid != module_desc.uuid: + logging.warning("Detected UUID mismatch {} != {}".format(uuid, module_desc.uuid)) + # UUIDs don't match. Tell client to not symbolize this. + return None + except GetUUIDFromBinaryException as e: + logging.error('Failed to binary from UUID: %s', str(e)) + return None + return module_desc.module_path_for_symbolization + + @staticmethod + def parse_from_file(module_map_path): + if not os.path.exists(module_map_path): + raise Exception('module map "{}" does not exist'.format(module_map_path)) + with open(module_map_path, 'r') as f: + mm = None + # E.g. + # 0x2db4000-0x102ddc000 /path/to (arm64) <0D6BBDE0-FF90-3680-899D-8E6F9528E04C> + hex_regex = lambda name: r'0x(?P<' + name + r'>[0-9a-f]+)' + module_path_regex = r'(?P.+)' + arch_regex = r'\((?P.+)\)' + uuid_regex = r'<(?P[0-9A-Z-]+)>' + line_regex = r'^{}-{}\s+{}\s+{}\s+{}'.format( + hex_regex('start_addr'), + hex_regex('end_addr'), + module_path_regex, + arch_regex, + uuid_regex + ) + matcher = re.compile(line_regex) + line_num = 0 + line = 'dummy' + while line != '': + line = f.readline() + line_num += 1 + if mm is None: + if line.startswith('Process module map:'): + mm = ModuleMap() + continue + if line.startswith('End of module map'): + break + m_obj = matcher.match(line) + if not m_obj: + raise Exception('Failed to parse line {} "{}"'.format(line_num, line)) + arch = m_obj.group('arch') + start_addr = int(m_obj.group('start_addr'), base=16) + end_addr = int(m_obj.group('end_addr'), base=16) + module_path = m_obj.group('path') + uuid = m_obj.group('uuid') + module_desc = ModuleDesc( + name=os.path.basename(module_path), + arch=arch, + start_addr=start_addr, + end_addr=end_addr, + module_path=module_path, + uuid=uuid + ) + mm.add_module(module_desc) + if mm is not None: + logging.debug('Loaded Module map from "{}":\n{}'.format( + f.name, + str(mm)) + ) + return mm + class SysRootFilterPlugIn(AsanSymbolizerPlugIn): """ Simple plug-in to add sys root prefix to all binary paths @@ -655,6 +872,31 @@ class SysRootFilterPlugIn(AsanSymbolizerPlugIn): def filter_binary_path(self, path): return self.sysroot_path + path +class ModuleMapPlugIn(AsanSymbolizerPlugIn): + def __init__(self): + self._module_map = None + def register_cmdline_args(self, parser): + parser.add_argument('--module-map', + help='Path to text file containing module map' + 'output. See print_module_map ASan option.') + def process_cmdline_args(self, pargs): + if not pargs.module_map: + return False + self._module_map = ModuleMap.parse_from_file(args.module_map) + if self._module_map is None: + msg = 'Failed to find module map' + logging.error(msg) + raise Exception(msg) + return True + def filter_binary_path(self, binary_path): + if os.path.isabs(binary_path): + # This is a binary path so transform into + # a module name + module_name = os.path.basename(binary_path) + else: + module_name = binary_path + return self._module_map.get_module_path_for_symbolication(module_name, self.proxy) + def add_logging_args(parser): parser.add_argument('--log-dest', default=None, @@ -704,6 +946,7 @@ def setup_plugins(plugin_proxy, args): for plugin_path in pargs.plugins: plugin_proxy.load_plugin_from_file(plugin_path) # Add built-in plugins. + plugin_proxy.add_plugin(ModuleMapPlugIn()) plugin_proxy.add_plugin(SysRootFilterPlugIn()) return unparsed_args -- cgit v1.2.1 From b6811a15fa4ccc1da6576b4ad654ad05ddbd2f11 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Fri, 26 Apr 2019 17:29:22 +0000 Subject: [NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to void This temporary change tells us about all the places where the return value of the INTERCEPT_FUNCTION macro is actually used. In the next patch I will cleanup the macro and remove GetRealFuncAddress. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D61145 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359325 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_interceptors.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h index 903ab5991..d4a68e267 100644 --- a/lib/asan/asan_interceptors.h +++ b/lib/asan/asan_interceptors.h @@ -122,12 +122,16 @@ DECLARE_REAL(char*, strstr, const char *s1, const char *s2) #if !SANITIZER_MAC #define ASAN_INTERCEPT_FUNC(name) \ do { \ - if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \ + INTERCEPT_FUNCTION(name); \ + bool same = (& (name) == & WRAP(name)); \ + if ((!same || !REAL(name))) \ VReport(1, "AddressSanitizer: failed to intercept '" #name "'\n"); \ } while (0) #define ASAN_INTERCEPT_FUNC_VER(name, ver) \ do { \ - if ((!INTERCEPT_FUNCTION_VER(name, ver) || !REAL(name))) \ + INTERCEPT_FUNCTION_VER(name, ver); \ + name##_type ptr = (::__interception::real_##name); \ + if ((!ptr || !REAL(name))) \ VReport( \ 1, "AddressSanitizer: failed to intercept '" #name "@@" #ver "'\n"); \ } while (0) -- cgit v1.2.1 From 956b2fea134341c8ee1060824fcacc370a4a1130 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Fri, 26 Apr 2019 19:06:55 +0000 Subject: [Sanitizer][Windows] Speculative fix for broken build on Windows git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359339 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_win.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc index 3eee845ee..adf4d78f5 100644 --- a/lib/asan/asan_win.cc +++ b/lib/asan/asan_win.cc @@ -166,11 +166,16 @@ void InitializePlatformInterceptors() { (LPCWSTR)&InitializePlatformInterceptors, &pinned)); - ASAN_INTERCEPT_FUNC(CreateThread); + // FIXME: ASAN_INTERCEPT_FUNC has some sanity checking that currently does + // not compile, i.e., it compares `(&CreateThread) != WRAP(&CreateThread)`, + // but the type of the interceptor does not match. + // ASAN_INTERCEPT_FUNC(CreateThread); + INTERCEPT_FUNCTION(CreateThread); ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter); #ifdef _WIN64 - ASAN_INTERCEPT_FUNC(__C_specific_handler); + // ASAN_INTERCEPT_FUNC(__C_specific_handler); // FIXME: same as above + INTERCEPT_FUNCTION(__C_specific_handler); #else ASAN_INTERCEPT_FUNC(_except_handler3); ASAN_INTERCEPT_FUNC(_except_handler4); -- cgit v1.2.1 From f87d73402ed5e8f4de24441dce25b808df1cd73f Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Sat, 27 Apr 2019 06:30:52 +0000 Subject: [sanitizer] Calculate SizeClassAllocator32::ByteMap type from Params::kSpaceSize and Params::kRegionSizeLog Reviewers: eugenis Subscribers: kubamracek, cryptoad, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61206 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359374 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_allocator.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h index f00776c94..7b9e73066 100644 --- a/lib/asan/asan_allocator.h +++ b/lib/asan/asan_allocator.h @@ -166,16 +166,6 @@ template using PrimaryAllocatorASVT = SizeClassAllocator64>; using PrimaryAllocator = PrimaryAllocatorASVT; #else // Fallback to SizeClassAllocator32. -static const uptr kRegionSizeLog = 20; -static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog; -# if SANITIZER_WORDSIZE == 32 -template -using ByteMapASVT = FlatByteMap; -# elif SANITIZER_WORDSIZE == 64 -template -using ByteMapASVT = - TwoLevelByteMap<(kNumRegions >> 12), 1 << 12, AddressSpaceView>; -# endif typedef CompactSizeClassMap SizeClassMap; template struct AP32 { @@ -183,9 +173,8 @@ struct AP32 { static const u64 kSpaceSize = SANITIZER_MMAP_RANGE_SIZE; static const uptr kMetadataSize = 16; typedef __asan::SizeClassMap SizeClassMap; - static const uptr kRegionSizeLog = __asan::kRegionSizeLog; + static const uptr kRegionSizeLog = 20; using AddressSpaceView = AddressSpaceViewTy; - using ByteMap = __asan::ByteMapASVT; typedef AsanMapUnmapCallback MapUnmapCallback; static const uptr kFlags = 0; }; -- cgit v1.2.1 From b33a9ba70c193d96cbe696d565d8b6e7874929b6 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Mon, 29 Apr 2019 16:39:18 +0000 Subject: [Sanitizer] Cleanup {ASAN, MSAN}_INTERCEPT_FUNC[_VER] macro Note that this change is not strictly NFC since we add the `(&(name) != &WRAP(name)` part to the conditional for the `_VER` variant of the macro. Reviewers: vitalybuka Differential Revision: https://reviews.llvm.org/D61204 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359466 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_interceptors.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h index d4a68e267..f0deea391 100644 --- a/lib/asan/asan_interceptors.h +++ b/lib/asan/asan_interceptors.h @@ -123,15 +123,13 @@ DECLARE_REAL(char*, strstr, const char *s1, const char *s2) #define ASAN_INTERCEPT_FUNC(name) \ do { \ INTERCEPT_FUNCTION(name); \ - bool same = (& (name) == & WRAP(name)); \ - if ((!same || !REAL(name))) \ + if (&(name) != &WRAP(name) || !REAL(name)) \ VReport(1, "AddressSanitizer: failed to intercept '" #name "'\n"); \ } while (0) #define ASAN_INTERCEPT_FUNC_VER(name, ver) \ do { \ INTERCEPT_FUNCTION_VER(name, ver); \ - name##_type ptr = (::__interception::real_##name); \ - if ((!ptr || !REAL(name))) \ + if (&(name) != &WRAP(name) || !REAL(name)) \ VReport( \ 1, "AddressSanitizer: failed to intercept '" #name "@@" #ver "'\n"); \ } while (0) -- cgit v1.2.1 From 89cc6f2230ae2e1052693aea3921945d92ce814f Mon Sep 17 00:00:00 2001 From: Matthew G McGovern Date: Mon, 29 Apr 2019 20:26:19 +0000 Subject: [AddressSanitizer] [Windows] Fix HeapReAlloc and _recalloc bugs in asan_malloc_win.cc HeapReAlloc should allow for 0 sized reallocations without freeing the memory block provided by the user. _recalloc previously did not zero new memory after reallocation. https://reviews.llvm.org/D61268 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359498 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_malloc_win.cc | 57 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 14 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_malloc_win.cc b/lib/asan/asan_malloc_win.cc index 752976567..c16ed9b34 100644 --- a/lib/asan/asan_malloc_win.cc +++ b/lib/asan/asan_malloc_win.cc @@ -47,6 +47,19 @@ using namespace __asan; // NOLINT #endif extern "C" { + +ALLOCATION_FUNCTION_ATTRIBUTE +size_t _msize(void *ptr) { + GET_CURRENT_PC_BP_SP; + (void)sp; + return asan_malloc_usable_size(ptr, pc, bp); +} + +ALLOCATION_FUNCTION_ATTRIBUTE +size_t _msize_base(void *ptr) { + return _msize(ptr); +} + ALLOCATION_FUNCTION_ATTRIBUTE void free(void *ptr) { GET_STACK_TRACE_FREE; @@ -124,7 +137,16 @@ void *_recalloc(void *p, size_t n, size_t elem_size) { const size_t size = n * elem_size; if (elem_size != 0 && size / elem_size != n) return 0; - return realloc(p, size); + + size_t old_size = _msize(p); + void *new_alloc = malloc(size); + if (new_alloc) { + REAL(memcpy)(new_alloc, p, Min(size, old_size)); + if (old_size < size) + REAL(memset)(((u8 *)new_alloc) + old_size, 0, size - old_size); + free(p); + } + return new_alloc; } ALLOCATION_FUNCTION_ATTRIBUTE @@ -132,18 +154,6 @@ void *_recalloc_base(void *p, size_t n, size_t elem_size) { return _recalloc(p, n, elem_size); } -ALLOCATION_FUNCTION_ATTRIBUTE -size_t _msize(void *ptr) { - GET_CURRENT_PC_BP_SP; - (void)sp; - return asan_malloc_usable_size(ptr, pc, bp); -} - -ALLOCATION_FUNCTION_ATTRIBUTE -size_t _msize_base(void *ptr) { - return _msize(ptr); -} - ALLOCATION_FUNCTION_ATTRIBUTE void *_expand(void *memblock, size_t size) { // _expand is used in realloc-like functions to resize the buffer if possible. @@ -198,11 +208,30 @@ INTERCEPTOR_WINAPI(BOOL, HeapFree, HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) { INTERCEPTOR_WINAPI(LPVOID, HeapReAlloc, HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes) { GET_STACK_TRACE_MALLOC; + GET_CURRENT_PC_BP_SP; // Realloc should never reallocate in place. if (dwFlags & HEAP_REALLOC_IN_PLACE_ONLY) return nullptr; CHECK(dwFlags == 0 && "unsupported heap flags"); - return asan_realloc(lpMem, dwBytes, &stack); + // HeapReAlloc and HeapAlloc both happily accept 0 sized allocations. + // passing a 0 size into asan_realloc will free the allocation. + // To avoid this and keep behavior consistent, fudge the size if 0. + // (asan_malloc already does this) + if (dwBytes == 0) + dwBytes = 1; + size_t old_size; + if (dwFlags & HEAP_ZERO_MEMORY) + old_size = asan_malloc_usable_size(lpMem, pc, bp); + void *ptr = asan_realloc(lpMem, dwBytes, &stack); + if (ptr == nullptr) + return nullptr; + + if (dwFlags & HEAP_ZERO_MEMORY) { + size_t new_size = asan_malloc_usable_size(ptr, pc, bp); + if (old_size < new_size) + REAL(memset)(((u8 *)ptr) + old_size, 0, new_size - old_size); + } + return ptr; } INTERCEPTOR_WINAPI(SIZE_T, HeapSize, HANDLE hHeap, DWORD dwFlags, -- cgit v1.2.1 From 45fad2fe3524ecee10465b6e20a0e6fc7007121f Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Mon, 29 Apr 2019 20:40:08 +0000 Subject: Pacify sanitizer lint script after r359498 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359499 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_malloc_win.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_malloc_win.cc b/lib/asan/asan_malloc_win.cc index c16ed9b34..a45c5a102 100644 --- a/lib/asan/asan_malloc_win.cc +++ b/lib/asan/asan_malloc_win.cc @@ -47,7 +47,6 @@ using namespace __asan; // NOLINT #endif extern "C" { - ALLOCATION_FUNCTION_ATTRIBUTE size_t _msize(void *ptr) { GET_CURRENT_PC_BP_SP; -- cgit v1.2.1 From d201961150fe163d41c4e0bf9c296ed69780d3b2 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Mon, 29 Apr 2019 20:44:26 +0000 Subject: Fix FIXME added in r359339 We have windows.h in asan_win.cc, so we can just use the correct prototypes for these EH-related interceptors without worrying. Also fix an unused variable warning while I'm here. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359500 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_malloc_win.cc | 1 + lib/asan/asan_win.cc | 26 +++++++++++--------------- 2 files changed, 12 insertions(+), 15 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_malloc_win.cc b/lib/asan/asan_malloc_win.cc index a45c5a102..b13d798a3 100644 --- a/lib/asan/asan_malloc_win.cc +++ b/lib/asan/asan_malloc_win.cc @@ -208,6 +208,7 @@ INTERCEPTOR_WINAPI(LPVOID, HeapReAlloc, HANDLE hHeap, DWORD dwFlags, LPVOID lpMem, SIZE_T dwBytes) { GET_STACK_TRACE_MALLOC; GET_CURRENT_PC_BP_SP; + (void)sp; // Realloc should never reallocate in place. if (dwFlags & HEAP_REALLOC_IN_PLACE_ONLY) return nullptr; diff --git a/lib/asan/asan_win.cc b/lib/asan/asan_win.cc index adf4d78f5..c9b81fa8f 100644 --- a/lib/asan/asan_win.cc +++ b/lib/asan/asan_win.cc @@ -104,7 +104,9 @@ INTERCEPTOR_WINAPI(void, RaiseException, void *a, void *b, void *c, void *d) { #ifdef _WIN64 -INTERCEPTOR_WINAPI(int, __C_specific_handler, void *a, void *b, void *c, void *d) { // NOLINT +INTERCEPTOR_WINAPI(EXCEPTION_DISPOSITION, __C_specific_handler, + _EXCEPTION_RECORD *a, void *b, _CONTEXT *c, + _DISPATCHER_CONTEXT *d) { // NOLINT CHECK(REAL(__C_specific_handler)); __asan_handle_no_return(); return REAL(__C_specific_handler)(a, b, c, d); @@ -135,10 +137,9 @@ static thread_return_t THREAD_CALLING_CONV asan_thread_start(void *arg) { return t->ThreadStart(GetTid(), /* signal_thread_is_registered */ nullptr); } -INTERCEPTOR_WINAPI(DWORD, CreateThread, - void* security, uptr stack_size, - DWORD (__stdcall *start_routine)(void*), void* arg, - DWORD thr_flags, void* tid) { +INTERCEPTOR_WINAPI(HANDLE, CreateThread, LPSECURITY_ATTRIBUTES security, + SIZE_T stack_size, LPTHREAD_START_ROUTINE start_routine, + void *arg, DWORD thr_flags, DWORD *tid) { // Strict init-order checking is thread-hostile. if (flags()->strict_init_order) StopInitOrderChecking(); @@ -148,9 +149,9 @@ INTERCEPTOR_WINAPI(DWORD, CreateThread, bool detached = false; // FIXME: how can we determine it on Windows? u32 current_tid = GetCurrentTidOrInvalid(); AsanThread *t = - AsanThread::Create(start_routine, arg, current_tid, &stack, detached); - return REAL(CreateThread)(security, stack_size, - asan_thread_start, t, thr_flags, tid); + AsanThread::Create(start_routine, arg, current_tid, &stack, detached); + return REAL(CreateThread)(security, stack_size, asan_thread_start, t, + thr_flags, tid); } // }}} @@ -166,16 +167,11 @@ void InitializePlatformInterceptors() { (LPCWSTR)&InitializePlatformInterceptors, &pinned)); - // FIXME: ASAN_INTERCEPT_FUNC has some sanity checking that currently does - // not compile, i.e., it compares `(&CreateThread) != WRAP(&CreateThread)`, - // but the type of the interceptor does not match. - // ASAN_INTERCEPT_FUNC(CreateThread); - INTERCEPT_FUNCTION(CreateThread); + ASAN_INTERCEPT_FUNC(CreateThread); ASAN_INTERCEPT_FUNC(SetUnhandledExceptionFilter); #ifdef _WIN64 - // ASAN_INTERCEPT_FUNC(__C_specific_handler); // FIXME: same as above - INTERCEPT_FUNCTION(__C_specific_handler); + ASAN_INTERCEPT_FUNC(__C_specific_handler); #else ASAN_INTERCEPT_FUNC(_except_handler3); ASAN_INTERCEPT_FUNC(_except_handler4); -- cgit v1.2.1 From 56d59bd9cdbd18d00d2b487812e19ff7302201c7 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 30 Apr 2019 20:59:56 +0000 Subject: Revert r359325 "[NFC][Sanitizer] Change "return type" of INTERCEPT_FUNCTION to void" Changing INTERCEPT_FUNCTION to return void is not functionally correct. IMO the best way to communicate failure or success of interception is with a return value, not some external address comparison. This change was also creating link errors for _except_handler4_common, which is exported from ucrtbase.dll in 32-bit Windows. Also revert dependent changes r359362 and r359466. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359611 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_interceptors.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h index f0deea391..903ab5991 100644 --- a/lib/asan/asan_interceptors.h +++ b/lib/asan/asan_interceptors.h @@ -122,14 +122,12 @@ DECLARE_REAL(char*, strstr, const char *s1, const char *s2) #if !SANITIZER_MAC #define ASAN_INTERCEPT_FUNC(name) \ do { \ - INTERCEPT_FUNCTION(name); \ - if (&(name) != &WRAP(name) || !REAL(name)) \ + if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \ VReport(1, "AddressSanitizer: failed to intercept '" #name "'\n"); \ } while (0) #define ASAN_INTERCEPT_FUNC_VER(name, ver) \ do { \ - INTERCEPT_FUNCTION_VER(name, ver); \ - if (&(name) != &WRAP(name) || !REAL(name)) \ + if ((!INTERCEPT_FUNCTION_VER(name, ver) || !REAL(name))) \ VReport( \ 1, "AddressSanitizer: failed to intercept '" #name "@@" #ver "'\n"); \ } while (0) -- cgit v1.2.1 From cfcbff0d73bea1fece9c213fb7ed9eab27c125a6 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Wed, 1 May 2019 17:33:01 +0000 Subject: [sanitizer] Implement reallocarray. Summary: It's a cross of calloc and realloc. Sanitizers implement calloc-like check for size overflow. Reviewers: vitalybuka, kcc Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61108 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359708 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_allocator.cc | 11 +++++++++++ lib/asan/asan_allocator.h | 2 ++ lib/asan/asan_errors.cc | 13 +++++++++++++ lib/asan/asan_errors.h | 16 ++++++++++++++++ lib/asan/asan_malloc_linux.cc | 8 ++++++++ lib/asan/asan_report.cc | 7 +++++++ lib/asan/asan_report.h | 2 ++ 7 files changed, 59 insertions(+) (limited to 'lib/asan') diff --git a/lib/asan/asan_allocator.cc b/lib/asan/asan_allocator.cc index 64813eb4b..2ca6220d8 100644 --- a/lib/asan/asan_allocator.cc +++ b/lib/asan/asan_allocator.cc @@ -879,6 +879,17 @@ void *asan_calloc(uptr nmemb, uptr size, BufferedStackTrace *stack) { return SetErrnoOnNull(instance.Calloc(nmemb, size, stack)); } +void *asan_reallocarray(void *p, uptr nmemb, uptr size, + BufferedStackTrace *stack) { + if (UNLIKELY(CheckForCallocOverflow(size, nmemb))) { + errno = errno_ENOMEM; + if (AllocatorMayReturnNull()) + return nullptr; + ReportReallocArrayOverflow(nmemb, size, stack); + } + return asan_realloc(p, nmemb * size, stack); +} + void *asan_realloc(void *p, uptr size, BufferedStackTrace *stack) { if (!p) return SetErrnoOnNull(instance.Allocate(size, 8, stack, FROM_MALLOC, true)); diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h index 7b9e73066..a3c3cda8e 100644 --- a/lib/asan/asan_allocator.h +++ b/lib/asan/asan_allocator.h @@ -219,6 +219,8 @@ void asan_delete(void *ptr, uptr size, uptr alignment, void *asan_malloc(uptr size, BufferedStackTrace *stack); void *asan_calloc(uptr nmemb, uptr size, BufferedStackTrace *stack); void *asan_realloc(void *p, uptr size, BufferedStackTrace *stack); +void *asan_reallocarray(void *p, uptr nmemb, uptr size, + BufferedStackTrace *stack); void *asan_valloc(uptr size, BufferedStackTrace *stack); void *asan_pvalloc(uptr size, BufferedStackTrace *stack); diff --git a/lib/asan/asan_errors.cc b/lib/asan/asan_errors.cc index 16a300967..d598e37b9 100644 --- a/lib/asan/asan_errors.cc +++ b/lib/asan/asan_errors.cc @@ -177,6 +177,19 @@ void ErrorCallocOverflow::Print() { ReportErrorSummary(scariness.GetDescription(), stack); } +void ErrorReallocArrayOverflow::Print() { + Decorator d; + Printf("%s", d.Error()); + Report( + "ERROR: AddressSanitizer: reallocarray parameters overflow: count * size " + "(%zd * %zd) cannot be represented in type size_t (thread %s)\n", + count, size, AsanThreadIdAndName(tid).c_str()); + Printf("%s", d.Default()); + stack->Print(); + PrintHintAllocatorCannotReturnNull(); + ReportErrorSummary(scariness.GetDescription(), stack); +} + void ErrorPvallocOverflow::Print() { Decorator d; Printf("%s", d.Error()); diff --git a/lib/asan/asan_errors.h b/lib/asan/asan_errors.h index 9c54d0759..f0939ae32 100644 --- a/lib/asan/asan_errors.h +++ b/lib/asan/asan_errors.h @@ -163,6 +163,21 @@ struct ErrorCallocOverflow : ErrorBase { void Print(); }; +struct ErrorReallocArrayOverflow : ErrorBase { + const BufferedStackTrace *stack; + uptr count; + uptr size; + + ErrorReallocArrayOverflow() = default; // (*) + ErrorReallocArrayOverflow(u32 tid, BufferedStackTrace *stack_, uptr count_, + uptr size_) + : ErrorBase(tid, 10, "reallocarray-overflow"), + stack(stack_), + count(count_), + size(size_) {} + void Print(); +}; + struct ErrorPvallocOverflow : ErrorBase { const BufferedStackTrace *stack; uptr size; @@ -371,6 +386,7 @@ struct ErrorGeneric : ErrorBase { macro(MallocUsableSizeNotOwned) \ macro(SanitizerGetAllocatedSizeNotOwned) \ macro(CallocOverflow) \ + macro(ReallocArrayOverflow) \ macro(PvallocOverflow) \ macro(InvalidAllocationAlignment) \ macro(InvalidAlignedAllocAlignment) \ diff --git a/lib/asan/asan_malloc_linux.cc b/lib/asan/asan_malloc_linux.cc index 998a4f35f..86fcd3b12 100644 --- a/lib/asan/asan_malloc_linux.cc +++ b/lib/asan/asan_malloc_linux.cc @@ -165,6 +165,14 @@ INTERCEPTOR(void*, realloc, void *ptr, uptr size) { return asan_realloc(ptr, size, &stack); } +#if SANITIZER_INTERCEPT_REALLOCARRAY +INTERCEPTOR(void*, reallocarray, void *ptr, uptr nmemb, uptr size) { + ENSURE_ASAN_INITED(); + GET_STACK_TRACE_MALLOC; + return asan_reallocarray(ptr, nmemb, size, &stack); +} +#endif // SANITIZER_INTERCEPT_REALLOCARRAY + #if SANITIZER_INTERCEPT_MEMALIGN INTERCEPTOR(void*, memalign, uptr boundary, uptr size) { GET_STACK_TRACE_MALLOC; diff --git a/lib/asan/asan_report.cc b/lib/asan/asan_report.cc index ad6b12e6d..551753b4a 100644 --- a/lib/asan/asan_report.cc +++ b/lib/asan/asan_report.cc @@ -263,6 +263,13 @@ void ReportCallocOverflow(uptr count, uptr size, BufferedStackTrace *stack) { in_report.ReportError(error); } +void ReportReallocArrayOverflow(uptr count, uptr size, + BufferedStackTrace *stack) { + ScopedInErrorReport in_report(/*fatal*/ true); + ErrorReallocArrayOverflow error(GetCurrentTidOrInvalid(), stack, count, size); + in_report.ReportError(error); +} + void ReportPvallocOverflow(uptr size, BufferedStackTrace *stack) { ScopedInErrorReport in_report(/*fatal*/ true); ErrorPvallocOverflow error(GetCurrentTidOrInvalid(), stack, size); diff --git a/lib/asan/asan_report.h b/lib/asan/asan_report.h index 653fc948d..dcf60894e 100644 --- a/lib/asan/asan_report.h +++ b/lib/asan/asan_report.h @@ -61,6 +61,8 @@ void ReportMallocUsableSizeNotOwned(uptr addr, BufferedStackTrace *stack); void ReportSanitizerGetAllocatedSizeNotOwned(uptr addr, BufferedStackTrace *stack); void ReportCallocOverflow(uptr count, uptr size, BufferedStackTrace *stack); +void ReportReallocArrayOverflow(uptr count, uptr size, + BufferedStackTrace *stack); void ReportPvallocOverflow(uptr size, BufferedStackTrace *stack); void ReportInvalidAllocationAlignment(uptr alignment, BufferedStackTrace *stack); -- cgit v1.2.1 From 8b0927fbbaa2dd437b3f189b357990dd3d06c694 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Wed, 1 May 2019 19:30:49 +0000 Subject: [sanitizer][NFC] Get type of AllocatorCache from CombinedAllocator Reviewers: eugenis, cryptoad, kcc Reviewed By: kcc Subscribers: kcc, kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61155 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359715 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_allocator.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h index a3c3cda8e..63dbfd604 100644 --- a/lib/asan/asan_allocator.h +++ b/lib/asan/asan_allocator.h @@ -184,10 +184,6 @@ using PrimaryAllocator = PrimaryAllocatorASVT; #endif // SANITIZER_CAN_USE_ALLOCATOR64 static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses; -template -using AllocatorCacheASVT = - SizeClassAllocatorLocalCache>; -using AllocatorCache = AllocatorCacheASVT; template using SecondaryAllocatorASVT = @@ -196,10 +192,10 @@ using SecondaryAllocatorASVT = template using AsanAllocatorASVT = CombinedAllocator, - AllocatorCacheASVT, SecondaryAllocatorASVT, AddressSpaceView>; using AsanAllocator = AsanAllocatorASVT; +using AllocatorCache = AsanAllocator::AllocatorCache; struct AsanThreadLocalMallocStorage { uptr quarantine_cache[16]; -- cgit v1.2.1 From 99cd89c106a10f18ccbaeda9a920d28ae3e943cf Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Wed, 1 May 2019 19:41:54 +0000 Subject: [sanitizer][NFC] Set LargeMmapAllocator type from PrimaryAllocator They need to have same AddressSpaceView and MapUnmapCallback. Reviewers: eugenis Subscribers: kubamracek, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D61168 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359719 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_allocator.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_allocator.h b/lib/asan/asan_allocator.h index 63dbfd604..6add47be2 100644 --- a/lib/asan/asan_allocator.h +++ b/lib/asan/asan_allocator.h @@ -185,15 +185,9 @@ using PrimaryAllocator = PrimaryAllocatorASVT; static const uptr kNumberOfSizeClasses = SizeClassMap::kNumClasses; -template -using SecondaryAllocatorASVT = - LargeMmapAllocator; template using AsanAllocatorASVT = - CombinedAllocator, - SecondaryAllocatorASVT, - AddressSpaceView>; + CombinedAllocator>; using AsanAllocator = AsanAllocatorASVT; using AllocatorCache = AsanAllocator::AllocatorCache; -- cgit v1.2.1 From 91448959dae346b8ccb85693f3f94f79f9e0b33d Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Wed, 1 May 2019 20:57:59 +0000 Subject: [Sanitizer] Reland "Cleanup INTERCEPT_FUNCTION macro" On Linux both version of the INTERCEPT_FUNCTION macro now return true when interception was successful. Adapt and cleanup some usages. Also note that `&(func) == &WRAP(func)` is a link-time property, but we do a runtime check. Tested on Linux and macOS. Previous attempt reverted by: 5642c3feb03d020dc06a62e3dc54f3206a97a391 This attempt to bring order to the interceptor macro goes the other direction and aligns the Linux implementation with the way things are done on Windows. Reviewed By: vitalybuka, rnk Differential Revision: https://reviews.llvm.org/D61358 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@359725 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/asan/asan_interceptors.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/asan') diff --git a/lib/asan/asan_interceptors.h b/lib/asan/asan_interceptors.h index 903ab5991..2792e2f14 100644 --- a/lib/asan/asan_interceptors.h +++ b/lib/asan/asan_interceptors.h @@ -122,12 +122,12 @@ DECLARE_REAL(char*, strstr, const char *s1, const char *s2) #if !SANITIZER_MAC #define ASAN_INTERCEPT_FUNC(name) \ do { \ - if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \ + if (!INTERCEPT_FUNCTION(name)) \ VReport(1, "AddressSanitizer: failed to intercept '" #name "'\n"); \ } while (0) #define ASAN_INTERCEPT_FUNC_VER(name, ver) \ do { \ - if ((!INTERCEPT_FUNCTION_VER(name, ver) || !REAL(name))) \ + if (!INTERCEPT_FUNCTION_VER(name, ver)) \ VReport( \ 1, "AddressSanitizer: failed to intercept '" #name "@@" #ver "'\n"); \ } while (0) -- cgit v1.2.1