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,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 5ACD1C433E0 for ; Fri, 15 May 2020 15:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3B6CF207BB for ; Fri, 15 May 2020 15:03:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ppjy+eUs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726624AbgEOPDv (ORCPT ); Fri, 15 May 2020 11:03:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726144AbgEOPDs (ORCPT ); Fri, 15 May 2020 11:03:48 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F14C061A0C for ; Fri, 15 May 2020 08:03:48 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id q16so2825293ybg.18 for ; Fri, 15 May 2020 08:03:48 -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=ppjy+eUszCIjHMv2y1VNMLdz4INtsshcg6LC7YKwwdSCF4nrDHKAIkaunBJKpu53Wm CdqE/IfFCNtdHfH/B1f1IkW3LRH/px9S7zwHqNV+dWl/OM8J7VFjkH+P/qXzTonyKk6n Vx9oF/JBHieMwEykO/ClbUrmonI4pxSgjjPttkA7cda+oG2sAEFIvphxyaqhGWe9IhLR HdmDHiIh4OkKUmVM90q9tjXXK5DKVlGWh0L4sBpvP4j15deqw2jETxcu+cxHl4R+BM9Y ybEScMJchKUnFYrRy8Hh8LQfQOA/8qrZJZ73c4yEgpOvaW4QD5k0fB4czvgMj6TFjeWI WjlQ== 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=loF41cFPPtoAAowhXg+ID4SuJdyL9xqbP9bQjMeJRQlCqgjmYhJG6tt6ghvrBiVa/+ B0/GCYBkYwQh+AfuxFVMEq1+jGN2u9GTR6YUHxds55yjKwWtv0BjGdv7drD5kS+k1LZh lEbih1OL3fhC1SFSXcnbpQA7yzKUdI97EZTBBm/bfeTxuDyqULzaj64dw/CxpdcpuZi9 HfwQg2nxLWqyUwCdIFT2PubwkoGaRuVYdT+tt+InmS3KEcDgaY5MdXEnkQF41b3OzqUA sl63UY9hi+ZYjuRnjqP28c7VujOpNl5kw8O0UZKNIcpXn+YHZzn5BzBWS1+OMFkaolV5 8h/A== X-Gm-Message-State: AOAM533jva5uP9X6JLpk26q7Ue5LQIfC+Bgi1bSGIMtnb7tveLWKqxz9 2PNaLPobWtSme44pouV0kiafdRzZ8A== X-Google-Smtp-Source: ABdhPJxRUysCvFRWde5u2Oy8c8WyvgCzFWpEPOZ/1+FG9if+ZCojdkKaWfQUz69Li4qI1nqFXWyZBD0wNw== X-Received: by 2002:a25:60d6:: with SMTP id u205mr6281104ybb.440.1589555027743; Fri, 15 May 2020 08:03:47 -0700 (PDT) Date: Fri, 15 May 2020 17:03:29 +0200 In-Reply-To: <20200515150338.190344-1-elver@google.com> Message-Id: <20200515150338.190344-2-elver@google.com> Mime-Version: 1.0 References: <20200515150338.190344-1-elver@google.com> X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog Subject: [PATCH -tip 01/10] 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, 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