From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADB67C433E0 for ; Thu, 21 May 2020 14:22:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F6192083E for ; Thu, 21 May 2020 14:22:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Iok4xGuH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729520AbgEUOW1 (ORCPT ); Thu, 21 May 2020 10:22:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726965AbgEUOWX (ORCPT ); Thu, 21 May 2020 10:22:23 -0400 Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 614ADC061A0E for ; Thu, 21 May 2020 07:22:23 -0700 (PDT) Received: by mail-qk1-x749.google.com with SMTP id g20so7182867qkl.11 for ; Thu, 21 May 2020 07:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Rd50Ui3HZ2EL9EcMGbbjqrEeCeIHgbARzkGzMmh8b1c=; b=Iok4xGuH0WP3oA4XUa5D2frlLrArGEi30c5MEZDityPxIw29HWZ9NPrJtiH6huRMZ0 OrkRNZHCOMCa5Yk8zZvifkjxs7QUBzSple+g2E/xN6zuy5S+LOYGzzfDkrP/k2EZwWP+ tEyPaB6rtwoBCQVdos8yS8xBtTwUdHuGtP+Q2vio7JfsOMQ88OhdP2D5SPOi1Pl7o+aO 0yOn51OK1ns79doIvYxkW2OP3hAr81HKaXLp6tcPUEtL3hnOaFHnt1WXKbN3cjpefvOG GD23M4YUx0yLfTDueQdeN0OZbMwO6WSfSxxbu3bO7SieqKGz/iTQBEygRJ3J0uGwsc+I tA4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Rd50Ui3HZ2EL9EcMGbbjqrEeCeIHgbARzkGzMmh8b1c=; b=Af0gc7ODxQ7F5JKzdERVysRnANu7jPuV0WhWNc+SumaW+1LiuiFj0mHOKGOGACe6Dd mmYdSba0w6t3KZADBfyffP/66ZRDXk1C19LqSQVgxYTWYITWX1tToWlPljxfYOw9ts8i CVMTGA5GjRhVsbb+HKS+PcQpWZsMDt3luAHo63NJw80DbJ9ZTXTalaBwfzeZgLFooq/j VB31OM9Y0IuNIO29mQ8otuQ5KZBusWIo+EBr3/KCaM4P+MlCZT3Rf+4185afVPWJjj+v L/BxMdFVXippynxgCc7gt+i7RslM0Nb9oudUSXzyTTZVv8QV165upPqhPMf2i084bHWu HRxA== X-Gm-Message-State: AOAM531uzImXdWriJWY4P4PC8WbW15dejbkaCDXrEEy4HPUMoRlvyzKs SlEIxUtQU9iObTJhS/rr+HlsCcSiKw== X-Google-Smtp-Source: ABdhPJx7Is4EKC/PZCd/bHE3oOcLYlI46uCAgxPXkayOPTHHYUXjvj1bK3zSwxTzeGahY/8G2eDHWVkm4g== X-Received: by 2002:a0c:9141:: with SMTP id q59mr9942670qvq.58.1590070942466; Thu, 21 May 2020 07:22:22 -0700 (PDT) Date: Thu, 21 May 2020 16:20:37 +0200 In-Reply-To: <20200521142047.169334-1-elver@google.com> Message-Id: <20200521142047.169334-2-elver@google.com> Mime-Version: 1.0 References: <20200521142047.169334-1-elver@google.com> X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog Subject: [PATCH -tip v3 01/11] ubsan, kcsan: don't combine sanitizer with kcov on clang From: Marco Elver To: elver@google.com Cc: paulmck@kernel.org, dvyukov@google.com, glider@google.com, andreyknvl@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, will@kernel.org, clang-built-linux@googlegroups.com, bp@alien8.de, Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann Clang does not allow -fsanitize-coverage=trace-{pc,cmp} together with -fsanitize=bounds or with ubsan: clang: error: argument unused during compilation: '-fsanitize-coverage=trace-pc' [-Werror,-Wunused-command-line-argument] clang: error: argument unused during compilation: '-fsanitize-coverage=trace-cmp' [-Werror,-Wunused-command-line-argument] To avoid the warning, check whether clang can handle this correctly or disallow ubsan and kcsan when kcov is enabled. Link: https://bugs.llvm.org/show_bug.cgi?id=45831 Link: https://lore.kernel.org/lkml/20200505142341.1096942-1-arnd@arndb.de Acked-by: Marco Elver Signed-off-by: Arnd Bergmann Signed-off-by: Marco Elver --- This patch is already in -rcu tree, but since since the series is based on -tip, to avoid conflict it is required for the subsequent patches. --- lib/Kconfig.kcsan | 11 +++++++++++ lib/Kconfig.ubsan | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/lib/Kconfig.kcsan b/lib/Kconfig.kcsan index ea28245c6c1d..a7276035ca0d 100644 --- a/lib/Kconfig.kcsan +++ b/lib/Kconfig.kcsan @@ -3,9 +3,20 @@ config HAVE_ARCH_KCSAN bool +config KCSAN_KCOV_BROKEN + def_bool KCOV && CC_HAS_SANCOV_TRACE_PC + depends on CC_IS_CLANG + depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=thread -fsanitize-coverage=trace-pc) + help + Some versions of clang support either KCSAN and KCOV but not the + combination of the two. + See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status + in newer releases. + menuconfig KCSAN bool "KCSAN: dynamic data race detector" depends on HAVE_ARCH_KCSAN && DEBUG_KERNEL && !KASAN + depends on !KCSAN_KCOV_BROKEN select STACKTRACE help The Kernel Concurrency Sanitizer (KCSAN) is a dynamic diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan index 48469c95d78e..3baea77bf37f 100644 --- a/lib/Kconfig.ubsan +++ b/lib/Kconfig.ubsan @@ -26,9 +26,20 @@ config UBSAN_TRAP the system. For some system builders this is an acceptable trade-off. +config UBSAN_KCOV_BROKEN + def_bool KCOV && CC_HAS_SANCOV_TRACE_PC + depends on CC_IS_CLANG + depends on !$(cc-option,-Werror=unused-command-line-argument -fsanitize=bounds -fsanitize-coverage=trace-pc) + help + Some versions of clang support either UBSAN or KCOV but not the + combination of the two. + See https://bugs.llvm.org/show_bug.cgi?id=45831 for the status + in newer releases. + config UBSAN_BOUNDS bool "Perform array index bounds checking" default UBSAN + depends on !UBSAN_KCOV_BROKEN help This option enables detection of directly indexed out of bounds array accesses, where the array size is known at compile time. -- 2.26.2.761.g0e0b3e54be-goog