From nobody Sat Dec 25 11:55:10 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F3E5318F23F8; Sat, 25 Dec 2021 11:55:12 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JLj6R1wTgz4kmd; Sat, 25 Dec 2021 11:55:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8132016CC9; Sat, 25 Dec 2021 11:55:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BPBtAn9006139; Sat, 25 Dec 2021 11:55:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BPBtAHU006138; Sat, 25 Dec 2021 11:55:10 GMT (envelope-from git) Date: Sat, 25 Dec 2021 11:55:10 GMT Message-Id: <202112251155.1BPBtAHU006138@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: b916d2b31c4c - stable/12 - Merge llvm commits for kernel address and memory sanitizer support List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b916d2b31c4ca1b52ffb1170280212685675880d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1640433311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=cgTDQMVH1YhUSb2LqhwZloOyzMSWyE4oPeMh3ksd6DI=; b=J0e0THMchC8eOecUa/RcxSJmSR+FUb7pwggns/TiA7xsLJWGjESySIXYNrq+yF6ERjDb9L UMXWNjC3cy8RlGyebzTL0E8gMsE6/WxrNj0SyT5eQBz7PzbmQ+VRQfMecM5/d/T+rsHvwD ICh6WrMv38wxH7EHBzHeBDpeoNkLal86iZyfwUePuwndwVY/YA2WedOAR8CX3teBg1hgQm vLAMQqJPeyU75mc7AopfuLWJwB4Qmv0njbCoycOHf1yGpp9ZfgiQ82WumzZPnJEpn6EOjK C4uGqpIkin6WdVat1zL0vxbx0bbfDZ5j7vhDznHc+zmxtMrVOrOi58RBgtwIaw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1640433311; a=rsa-sha256; cv=none; b=ahVbxAfnphnf+nf3/tAK3HCdHjce/sTZzUUSx4MPyjvVNoypJT0oNOETVNdZLu2ccimKyb EOhI9oC3OBuSGqpF8gyDpboz52eLT6l/CZ0sJwmKA7bsWqAZ9mCNpYLyBnEnUxkp6gRLqJ BGSMXaujtbvtCyKRbTDNSSBWFMOLA+Wvt4lNv7fOjeP/6Ahb/oTlDJwKYgO8uk+AmCkpnd vk1+grUEveVqAQW2HWtHF57/QqO+jar9Ip/CrUIHmHGk3Jx+SgXYFGEaQQ2u6EPYWIXx3X 0H3oO0apfLvI2NSyxKnm/uzqWfYrUp8BVsE+4+Sjzld6UPJEzj6aPZAR7GmaWQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=b916d2b31c4ca1b52ffb1170280212685675880d commit b916d2b31c4ca1b52ffb1170280212685675880d Author: Dimitry Andric AuthorDate: 2021-04-27 19:18:13 +0000 Commit: Dimitry Andric CommitDate: 2021-12-25 11:51:00 +0000 Merge llvm commits for kernel address and memory sanitizer support Merge commit 99eca1bd9c7a from llvm git (by Mark Johnston): [Driver] Enable kernel address and memory sanitizers on FreeBSD Test Plan: using kernel ASAN and MSAN implementations in FreeBSD Reviewed By: emaste, dim, arichardson Differential Revision: https://reviews.llvm.org/D98286 Merge commit f511dc75e4c1 from llvm git (by Mark Johnston): [asan] Add an offset for the kernel address sanitizer on FreeBSD This is based on a port of the sanitizer runtime to the FreeBSD kernel that has been commited as https://cgit.freebsd.org/src/commit/?id=38da497a4dfcf1979c8c2b0e9f3fa0564035c147 and the following commits. Reviewed By: emaste, dim Differential Revision: https://reviews.llvm.org/D98285 Requested by: markj MFC after: 3 days (cherry picked from commit 1b00608b264f1fac846e571e23d8ef7134834638) --- contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp | 8 +++++++- .../llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp index 57744bac37da..c14f34b6107c 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -462,6 +462,7 @@ bool FreeBSD::IsUnwindTablesDefault(const ArgList &Args) const { return true; } bool FreeBSD::isPIEDefault() const { return getSanitizerArgs().requiresPIE(); } SanitizerMask FreeBSD::getSupportedSanitizers() const { + const bool IsAArch64 = getTriple().getArch() == llvm::Triple::aarch64; const bool IsX86 = getTriple().getArch() == llvm::Triple::x86; const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64; const bool IsMIPS64 = getTriple().isMIPS64(); @@ -480,8 +481,13 @@ SanitizerMask FreeBSD::getSupportedSanitizers() const { Res |= SanitizerKind::Fuzzer; Res |= SanitizerKind::FuzzerNoLink; } - if (IsX86_64) + if (IsAArch64 || IsX86_64) { + Res |= SanitizerKind::KernelAddress; + Res |= SanitizerKind::KernelMemory; + } + if (IsX86_64) { Res |= SanitizerKind::Memory; + } return Res; } diff --git a/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 1557fad4d372..5ce21cc3616a 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -107,6 +107,7 @@ static const uint64_t kMIPS64_ShadowOffset64 = 1ULL << 37; static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36; static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30; static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46; +static const uint64_t kFreeBSDKasan_ShadowOffset64 = 0xdffff7c000000000; static const uint64_t kNetBSD_ShadowOffset32 = 1ULL << 30; static const uint64_t kNetBSD_ShadowOffset64 = 1ULL << 46; static const uint64_t kNetBSDKasan_ShadowOffset64 = 0xdfff900000000000; @@ -489,9 +490,12 @@ static ShadowMapping getShadowMapping(Triple &TargetTriple, int LongSize, Mapping.Offset = kPPC64_ShadowOffset64; else if (IsSystemZ) Mapping.Offset = kSystemZ_ShadowOffset64; - else if (IsFreeBSD && !IsMIPS64) - Mapping.Offset = kFreeBSD_ShadowOffset64; - else if (IsNetBSD) { + else if (IsFreeBSD && !IsMIPS64) { + if (IsKasan) + Mapping.Offset = kFreeBSDKasan_ShadowOffset64; + else + Mapping.Offset = kFreeBSD_ShadowOffset64; + } else if (IsNetBSD) { if (IsKasan) Mapping.Offset = kNetBSDKasan_ShadowOffset64; else