From owner-svn-src-all@freebsd.org Mon Sep 2 17:49:17 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4640CE414A; Mon, 2 Sep 2019 17:49:17 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46Mcz06mgCz44xT; Mon, 2 Sep 2019 17:49:16 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BC83D1DB9A; Mon, 2 Sep 2019 17:49:16 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x82HnGHu019756; Mon, 2 Sep 2019 17:49:16 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x82HnGql019753; Mon, 2 Sep 2019 17:49:16 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201909021749.x82HnGql019753@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 2 Sep 2019 17:49:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r351713 - in vendor/compiler-rt/dist-release_90/lib: asan msan sanitizer_common X-SVN-Group: vendor X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in vendor/compiler-rt/dist-release_90/lib: asan msan sanitizer_common X-SVN-Commit-Revision: 351713 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Sep 2019 17:49:17 -0000 Author: dim Date: Mon Sep 2 17:49:15 2019 New Revision: 351713 URL: https://svnweb.freebsd.org/changeset/base/351713 Log: Vendor import of compiler-rt release_90 branch r370514: https://llvm.org/svn/llvm-project/compiler-rt/branches/release_90@370514 Modified: vendor/compiler-rt/dist-release_90/lib/asan/asan_rtl.cc vendor/compiler-rt/dist-release_90/lib/msan/msan.cc vendor/compiler-rt/dist-release_90/lib/sanitizer_common/sanitizer_linux.cc Modified: vendor/compiler-rt/dist-release_90/lib/asan/asan_rtl.cc ============================================================================== --- vendor/compiler-rt/dist-release_90/lib/asan/asan_rtl.cc Mon Sep 2 17:49:13 2019 (r351712) +++ vendor/compiler-rt/dist-release_90/lib/asan/asan_rtl.cc Mon Sep 2 17:49:15 2019 (r351713) @@ -402,7 +402,6 @@ static void AsanInitInternal() { asan_init_is_running = true; CacheBinaryName(); - CheckASLR(); // Initialize flags. This must be done early, because most of the // initialization steps look at flags(). @@ -450,6 +449,7 @@ static void AsanInitInternal() { SetLowLevelAllocateCallback(OnLowLevelAllocate); InitializeAsanInterceptors(); + CheckASLR(); // Enable system log ("adb logcat") on Android. // Doing this before interceptors are initialized crashes in: Modified: vendor/compiler-rt/dist-release_90/lib/msan/msan.cc ============================================================================== --- vendor/compiler-rt/dist-release_90/lib/msan/msan.cc Mon Sep 2 17:49:13 2019 (r351712) +++ vendor/compiler-rt/dist-release_90/lib/msan/msan.cc Mon Sep 2 17:49:15 2019 (r351713) @@ -403,7 +403,6 @@ void __msan_init() { AvoidCVE_2016_2143(); CacheBinaryName(); - CheckASLR(); InitializeFlags(); // Install tool-specific callbacks in sanitizer_common. @@ -412,6 +411,7 @@ void __msan_init() { __sanitizer_set_report_path(common_flags()->log_path); InitializeInterceptors(); + CheckASLR(); InitTlsSize(); InstallDeadlySignalHandlers(MsanOnDeadlySignal); InstallAtExitHandler(); // Needs __cxa_atexit interceptor. Modified: vendor/compiler-rt/dist-release_90/lib/sanitizer_common/sanitizer_linux.cc ============================================================================== --- vendor/compiler-rt/dist-release_90/lib/sanitizer_common/sanitizer_linux.cc Mon Sep 2 17:49:13 2019 (r351712) +++ vendor/compiler-rt/dist-release_90/lib/sanitizer_common/sanitizer_linux.cc Mon Sep 2 17:49:15 2019 (r351713) @@ -2011,6 +2011,35 @@ void CheckASLR() { CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1); ReExec(); } +#elif SANITIZER_FREEBSD + int aslr_pie; + uptr len = sizeof(aslr_pie); +#if SANITIZER_WORDSIZE == 64 + if (UNLIKELY(internal_sysctlbyname("kern.elf64.aslr.pie_enable", + &aslr_pie, &len, NULL, 0) == -1)) { + // We're making things less 'dramatic' here since + // the OID is not necessarily guaranteed to be here + // just yet regarding FreeBSD release + return; + } + + if (aslr_pie > 0) { + Printf("This sanitizer is not compatible with enabled ASLR " + "and binaries compiled with PIE\n"); + Die(); + } +#endif + // there might be 32 bits compat for 64 bits + if (UNLIKELY(internal_sysctlbyname("kern.elf32.aslr.pie_enable", + &aslr_pie, &len, NULL, 0) == -1)) { + return; + } + + if (aslr_pie > 0) { + Printf("This sanitizer is not compatible with enabled ASLR " + "and binaries compiled with PIE\n"); + Die(); + } #else // Do nothing #endif