Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp842009ybj; Tue, 5 May 2020 08:22:37 -0700 (PDT) X-Google-Smtp-Source: APiQypK4sFr7r4BQ37bSv6qOGIhNEqZThDdgfWYPrFQMedHzulG8PXi8WVSGNImjd/DEC9v/Q1py X-Received: by 2002:a05:6402:3136:: with SMTP id dd22mr3068025edb.165.1588692157019; Tue, 05 May 2020 08:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588692157; cv=none; d=google.com; s=arc-20160816; b=Tcu0Imehr/dugET3FHNPv159evEet2ORRDWXRvii5AfOAinq27SBHRw7p8AWpZJ7eZ GP6Wj2y4lW45UdERlMxWyxHJH/bnBdfbQzfdKbWaHoPHbjqjcWLloLwCXSo7k9Zv1qvn 9/nhkqDr3T5qbT21vQs4eiWmPii+XYtydbHAWKi/s95WlZP0ZJdSlZdUjMiFb1HiLMie spQaMaa4g9gubM/q/T0Yyz8v5P7kc7TwH+fhBVNCpWhwOpk+fiGMlcazY6TcCai6Ovkd pKwm/abktrP/NJxWyTRPegId+kqx3UdQ8H2qXpx/LY+RfDJHt6n+/gUCdkFTAxP1jJSY UlCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=V8efal+sgU1en3J4nQ9rg/ceJ49rrnhyDi/kAbpO9w0=; b=xGKD1KKZ0AWZJGPVvTorg2biAwk+FS3XQlj+LS/eikJIM6RNhflxdIdmSXQyzl19g3 vbeOv0M3HmNl0sB+jJcGyGYtvwwa02aUmy2xBJNA3tWjX5OSrQP9rNN/3DRTCeK3Aq5B gqwfTUg8fjWuwvivbrA+JcfzghCjMZKG++Sg0Kz30B8lB7wt6N33r+vqLYubissf2mKr lMF9UN1akt5Exu3525CfTRllgtt6F5n/fZjpVS9mSgppHZz92LTkrwZmywdjseiLlmiO Wz8nAjltJakShhgAoJVgufJcIfZnS+D1NWqKsreN6MEuzmxQxoG7FqnCvF6NgFy2Tq0i pRJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lxBGwppW; 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 gv6si1331029ejb.388.2020.05.05.08.21.53; Tue, 05 May 2020 08:22:37 -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=lxBGwppW; 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 S1730006AbgEEPUQ (ORCPT + 99 others); Tue, 5 May 2020 11:20:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729951AbgEEPUO (ORCPT ); Tue, 5 May 2020 11:20:14 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 924F9C061A0F for ; Tue, 5 May 2020 08:20:14 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id j4so1923170otr.11 for ; Tue, 05 May 2020 08:20:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=V8efal+sgU1en3J4nQ9rg/ceJ49rrnhyDi/kAbpO9w0=; b=lxBGwppWljXJZO33BcCG8KoqAAmjWhtBl+eWw/n4r5atXyD/OKHd5SxYHZx5Sn8phF JDk/tpvNCpaXGAo2Bv8uB1pDdzg72+GOZQVnmEcBcuzaPt242hiYIcMeYeNoV4EV4G9f NwKVxQ0zuL3cSe8AzienovyKPEGN0k3RabrTMc8LqClPjwWx5E5BM+vva5UQvF2+Mh7M DjkxjvIJuUFOr+lbK8Evyk10L4jkQ0QwxPfSPPvPZgbCgmgGhrvDRZnpK1wSnnIgzJbs VHS5rDEJ7wRbfQSE1cwPrFJbYMbrZQ/gbC8AoXgsxjm2E3JaRKEhsC/f6AI8D6rS+OMy kJqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=V8efal+sgU1en3J4nQ9rg/ceJ49rrnhyDi/kAbpO9w0=; b=jp+ARHxqjiVtOtCDx+eSMYFCs9ce1fYCpkUu0CeG942EfmX4jriSEn0OlDNngAo0Yy ONvan5HbIys4rPoBScbBnCopR79qVrPu7qZZ0SPYe4ChkPM2Gk5Hhl9S+A84FR5KR60r 9PONTdIYTgtGp0n/02Ycl+tGEbSrxguTQzeuuBpJLDa2Yg4S9UHi1+JnPYCPd+IQwWWF /E0zYcDoqhJsXMPE8VAqAJ8SHZVcWUCN9u7acJ8hl6QQ5EQYcs1TeuKYcsJLnCAlvSwp krDFMneXAKnFMXl0IJWEcBZ5w3f4B40QFNejMbRFJq1mKlgZVisNwJkM4+Z64OTGXkjU iQOw== X-Gm-Message-State: AGi0PuYpuldFDjWdAH0hKd7hpesfSYmRjfnc+/CEKkYadNz7HInCpQT+ rtrF502klu8Q0JIaui2PgIOoFZ38Ui1cYrQu4p7jsA== X-Received: by 2002:a9d:509:: with SMTP id 9mr3055453otw.17.1588692013635; Tue, 05 May 2020 08:20:13 -0700 (PDT) MIME-Version: 1.0 References: <20200505142341.1096942-1-arnd@arndb.de> In-Reply-To: From: Marco Elver Date: Tue, 5 May 2020 17:19:58 +0200 Message-ID: Subject: Re: [PATCH] ubsan, kcsan: don't combine sanitizer with kcov To: Arnd Bergmann Cc: Dmitry Vyukov , Andrey Ryabinin , Kees Cook , Andrey Konovalov , "Paul E. McKenney" , Ingo Molnar , Andrew Morton , Greg Kroah-Hartman , Stephen Rothwell , Thomas Gleixner , kasan-dev , LKML , clang-built-linux 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 On Tue, 5 May 2020 at 16:59, Arnd Bergmann wrote: > > On Tue, May 5, 2020 at 4:50 PM 'Dmitry Vyukov' via Clang Built Linux > wrote: > > On Tue, May 5, 2020 at 4:36 PM Marco Elver wrote: > > > > 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] > > > > > > > > menuconfig KCSAN > > > > bool "KCSAN: dynamic data race detector" > > > > - depends on HAVE_ARCH_KCSAN && DEBUG_KERNEL && !KASAN > > > > + depends on HAVE_ARCH_KCSAN && DEBUG_KERNEL && !KASAN && !KCOV > > > > > > This also disables KCOV with GCC. Why does this not work with KCSAN? > > My mistake, this should be kept enabled for gcc. If we can get the combination > to work in clang, that's something that should also get enabled. See my suggestion below how we might dynamically determine if the combination is supported. > > > This is a huge problem for us, since syzbot requires KCOV. In fact > > > I've always been building KCSAN kernels with CONFIG_KCOV=y (with GCC > > > or Clang) and cannot reproduce the problem. > > I have some local patches that change the way we pick the warning options > for each compiler, and enable more of the warnings that are normally disabled. > > Maybe -Wunused-command-line-argument is disabled by default? > I only started seeing this problem recently. It's also possible that there > are some other options that interact with it so only Kcov+FOO leads to > KCSAN being ignored. I see. It certainly seems quite bad if one or the other option is effectively ignored. > > > Ditto, we really need KCOV for all sanitizers. I also just tried to > > > reproduce the problem but can't. > > > > > > Which version of clang is causing this? I'm currently using Clang 9. > > > My guess is that we should not fix this by disallowing KCOV, but > > > rather make Clang work with these configs. > > > > > > Dmitry, can you comment? > > > > FWIW I can reproduce both with clang: > > > > $ clang /tmp/test.c -c -fsanitize-coverage=trace-pc -fsanitize=bounds > > clang-11: warning: argument unused during compilation: > > '-fsanitize-coverage=trace-pc' [-Wunused-command-line-argument] > > > > $ clang /tmp/test.c -c -fsanitize-coverage=trace-pc -fsanitize=thread > > clang-11: warning: argument unused during compilation: > > '-fsanitize-coverage=trace-pc' [-Wunused-command-line-argument] > > > > with both my disto's 9.0.1 and fresher 11.0.0 > > (7b80cb7cf45faf462d6193cc41c2cb7ad556600d. > > > > But both work with gcc > > > > $ gcc /tmp/test.c -c -fsanitize-coverage=trace-pc -fsanitize=thread > > $ gcc /tmp/test.c -c -fsanitize-coverage=trace-pc -fsanitize=bounds > > > > Is it a known issue in clang? > > > > Can we somehow disable it only for clang and not gcc? > > > > This will immediately break KCSAN on syzbot as it enables KCSAN and KCOV: > > https://syzkaller.appspot.com/upstream?manager=ci2-upstream-kcsan-gce > > I can respin the patch with this fixup if you like: > > --- a/lib/Kconfig.kcsan > +++ b/lib/Kconfig.kcsan > @@ -5,7 +5,7 @@ config HAVE_ARCH_KCSAN > > menuconfig KCSAN > bool "KCSAN: dynamic data race detector" > - depends on HAVE_ARCH_KCSAN && DEBUG_KERNEL && !KASAN && !KCOV > + depends on HAVE_ARCH_KCSAN && DEBUG_KERNEL && !KASAN && !(KCOV > && CC_IS_CLANG) I wonder if we can just add this: depends on !(KCOV && !$(cc-option,-Werror -fsanitize=thread -fsanitize-coverage=trace-pc)) Similarly for UBSAN. That way, once Clang supports this combination, we don't need another patch to fix it. Thanks, -- Marco > select STACKTRACE > help > The Kernel Concurrency Sanitizer (KCSAN) is a dynamic > > As you both say, the combination seems to be quite important, so maybe there > is something else that can be to also enable it with clang. > > Arnd