Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp572365ybk; Fri, 15 May 2020 08:05:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTdC4qMzvwI6LgTRi7Ja9x7uEoNeVn3PM5DwypslpDpUDKM72G9zrcxL7z4FxnyNlssV5D X-Received: by 2002:a05:6402:74b:: with SMTP id p11mr2278540edy.229.1589555150444; Fri, 15 May 2020 08:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589555150; cv=none; d=google.com; s=arc-20160816; b=t7R+uw7TjdoXMUB+2dbgzYlmA02XyN9TbMTHtZvRCqk2NKVpwDDya6FaBGBWVK6vGH H9ZEKaXhE7RcE4kiPEFd9PBkiwOFzyNgg78bjijyYLXaeJnv0kEbpbVNbkuOYdL2aqIL B6lyFUbGnuu9MnW7+scdo71UD/txysaqyoH1le6wcYWdENHx9rSv04hRAFctUua9R+2H Cd8pWq1K7+PP5VwdSuesWCaAt0sp/c+km08uAjNg7eZaE5lkawbwXPeIkpE7NXnjLol6 vNEW+GAVSo193cZpNifRpsPf+8C3Y6OOmNcOSVULiMMtWBye5U3J6p6nQ+L3lRCGFyZW Jj/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=Rd50Ui3HZ2EL9EcMGbbjqrEeCeIHgbARzkGzMmh8b1c=; b=MtGFowZj95NvClTEvkPVxmnwLEVylWznT6KkIL4o5WkKR2WQh8qZKklFnkpn2BjpCE 5i8v2ELqrJS0WIe6Y5BMWbqIj7+cbt0L+0sBmsC7Ssn1Nvh155m5Z86NtRbTJgmnC4hE NzgwiLs1L5ApWx7Nxk1PSo1wb3xX62Y9a/b8IwR8cbDf8seNxtQjJa/yplAeAgVFB1dX 9S31nIoXYkxSdxjE9GafqMK1eGYDdTxtOngzBeRSBl4FxfPLajH+i9ype4fWLUuz1LY4 O/IHzpDLxb4XQAJSaREBQs/k5UhV/n4jORclOIeA0Y96tOnaEpmT++xA3i3zMxkbCYhU 7hnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ppjy+eUs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d19si1395948ejc.396.2020.05.15.08.05.25; Fri, 15 May 2020 08:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ppjy+eUs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726465AbgEOPDv (ORCPT + 99 others); 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-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