Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9029236ybl; Fri, 17 Jan 2020 05:16:40 -0800 (PST) X-Google-Smtp-Source: APXvYqxsXoaMaaZiRuQ5QUsM2ueGKL3mLUJSSwyLe0sbW2Py4ibIVYoT0ge0ZKgTCQQwVIxEyybU X-Received: by 2002:a05:6808:8f5:: with SMTP id d21mr3396289oic.58.1579267000828; Fri, 17 Jan 2020 05:16:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579267000; cv=none; d=google.com; s=arc-20160816; b=h0sP3FA7Bg0wAvE0L95yBIDw517aempQQwcKQZ2po6B94ueDMS2qJanzf0SedHfh+a U2NxD14x4iei994uVHmIOyg9n5iyaXzHCM2SwBlRuY/0zwrVGQvxwDlB1GklDNjFu7DP GtKlrEQjMKsIuQ/M1wPACjXSjoaBA9hCPQ/7kbyiwiBiYScGbcUF1zdVwZK6qFMYd95+ LEXpxOuOyujOzUAfuQ0u5HeWv8AItN9iVj+7A/DO6p21CTjWNb6oAA2c2E0w3MHpnJle ZPOmKpwG0PgiJH9xBvrsk2VMbkvt9RfZrZjhjoienT1CLF4ZICiOej8GTQqeSkg2otDw L9yQ== 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=B8YqwuFYQqcgYYrogodMJhZN7j+MHKf9rIlBL0O/Le8=; b=gI9IxnEXk+pe3kus8XL0kRMGANFdZl6NV9DdOlI9peEcRq84+Feb1umrxIWayb1xlG GgNWHPwW72OPwn7mA1MLuxIPUAW/dUvSbJlf8LhHXwq3oI8uFKQkNw2fS4Iy3GbPUHbX 9rP5l4IazaSFgTBENPwP7nfUaEGMzAB4O2TlAEH83mj0C/SwvNwQq0dOFgD8e67zuWcE XzxtneO3BAZx3F3H26aFKZ41kSZqnoCNZTdndt/j944AgulgcuWz8ZBt7W1DLAtsyrqr n8J3iUlm/XfPcb7NggVx22agdH+PeLdw95kuwnQsho4CGV4bW9SLsbVZp/TW8WMR4JKi RG5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=phe1Ud2o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u62si13608065oig.29.2020.01.17.05.16.27; Fri, 17 Jan 2020 05:16:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=phe1Ud2o; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726513AbgAQNPB (ORCPT + 99 others); Fri, 17 Jan 2020 08:15:01 -0500 Received: from mail-ot1-f42.google.com ([209.85.210.42]:39839 "EHLO mail-ot1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbgAQNPA (ORCPT ); Fri, 17 Jan 2020 08:15:00 -0500 Received: by mail-ot1-f42.google.com with SMTP id 77so22480420oty.6 for ; Fri, 17 Jan 2020 05:15:00 -0800 (PST) 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=B8YqwuFYQqcgYYrogodMJhZN7j+MHKf9rIlBL0O/Le8=; b=phe1Ud2oxwDPz6N0qGWXhYFzGha1cekzFvcn3g626qlUYghuyTbxgeFkLbD/M/5L2u FDYTHp9qH37eL4oqnFRBAXta5mf/ffxwB4CRYjCptTn0qENxhEnuJ6sd/k/c5WjQtL3l CZK7j9ZJcq40q1mQa/jNGhIl8VicJfvINi+VTqNF9qMX85UYRNemMrGHv6Y80fNbk6dg S9PPuTsUhR6lSiS6eVa+Gbu3kWZBLzmYXabHgR1/Uj8EbZ/xevu89+zvdF3lhTPSyKkD PaFZsgRegpuHk3NdVQ+8Daz+cDXqVbLvfaHQH+1GTrWlCrdFvn5XQvguxBKRfdkeZq/s GNkQ== 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=B8YqwuFYQqcgYYrogodMJhZN7j+MHKf9rIlBL0O/Le8=; b=Vc5ylP6Kf7+IzSJvIY8bNi8ALiOTgYZDlYSQkrENXjEknjMCqaU3g9kcmHiLkeynTG 5ct/K2IOI2d8J86njod5Sw2WNOiRwbya3dHB9jXOHjx1Fd1l4cetadAHEVsufDoCxms+ PP/cpvQlYacsdAmDOtyR2q6UyoFn5W2ghT4Xv4fDPrnEe7iYHKzhMXRxdwdjjq25b/Xk LJOKt51hmLHpp5/WKOldttO/zWYjccJVDzIFVnwOvg5SVwRcPkV7zzhLVTY5Hjcw+7VX qL79hKhACUmN5oKd7/Su5RQzIrk3bPNTWok2ISa2B3dp33O0LnYi8qQE/Z2IhtBZRkG1 2NPQ== X-Gm-Message-State: APjAAAXZDcQKm3n0BB3/L3ayrTfHKMitq5kLQLbn5HIoOl0FzjIPF17n KlAXcVVSQY1fz92uoIMNPgHg2nP+LRY8iCijsqppxA== X-Received: by 2002:a9d:588c:: with SMTP id x12mr5863094otg.2.1579266899985; Fri, 17 Jan 2020 05:14:59 -0800 (PST) MIME-Version: 1.0 References: <20200115165749.145649-1-elver@google.com> In-Reply-To: From: Marco Elver Date: Fri, 17 Jan 2020 14:14:48 +0100 Message-ID: Subject: Re: [PATCH -rcu] asm-generic, kcsan: Add KCSAN instrumentation for bitops To: Arnd Bergmann Cc: "Paul E. McKenney" , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , kasan-dev , "linux-kernel@vger.kernel.org" , Michael Ellerman , christophe leroy , Daniel Axtens , linux-arch 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 Fri, 17 Jan 2020 at 13:25, Arnd Bergmann wrote: > > On Wed, Jan 15, 2020 at 9:50 PM Marco Elver wrote: > > On Wed, 15 Jan 2020 at 20:55, Arnd Bergmann wrote: > > > On Wed, Jan 15, 2020 at 8:51 PM Marco Elver wrote: > > > > On Wed, 15 Jan 2020 at 20:27, Arnd Bergmann wrote: > > > Are there any that really just want kasan_check_write() but not one > > > of the kcsan checks? > > > > If I understood correctly, this suggestion would amount to introducing > > a new header, e.g. 'ksan-checks.h', that provides unified generic > > checks. For completeness, we will also need to consider reads. Since > > KCSAN provides 4 check variants ({read,write} x {plain,atomic}), we > > will need 4 generic check variants. > > Yes, that was the idea. > > > I certainly do not feel comfortable blindly introducing kcsan_checks > > in all places where we have kasan_checks, but it may be worthwhile > > adding this infrastructure and starting with atomic-instrumented and > > bitops-instrumented wrappers. The other locations you list above would > > need to be evaluated on a case-by-case basis to check if we want to > > report data races for those accesses. > > I think the main question to answer is whether it is more likely to go > wrong because we are missing checks when one caller accidentally > only has one but not the other, or whether they go wrong because > we accidentally check both when we should only be checking one. > > My guess would be that the first one is more likely to happen, but > the second one is more likely to cause problems when it happens. Right, I guess both have trade-offs. > > As a minor data point, {READ,WRITE}_ONCE in compiler.h currently only > > has kcsan_checks and not kasan_checks. > > Right. This is because we want an explicit "atomic" check for kcsan > but we want to have the function inlined for kasan, right? Yes, correct. > > My personal preference would be to keep the various checks explicit, > > clearly opting into either KCSAN and/or KASAN. Since I do not think > > it's obvious if we want both for the existing and potentially new > > locations (in future), the potential for error by blindly using a > > generic 'ksan_check' appears worse than potentially adding a dozen > > lines or so. > > > > Let me know if you'd like to proceed with 'ksan-checks.h'. > > Could you have a look at the files I listed and see if there are any > other examples that probably a different set of checks between the > two, besides the READ_ONCE() example? All the user-copy related code should probably have kcsan_checks as well. > If you can't find any, I would prefer having the simpler interface > with just one set of annotations. That's fair enough. I'll prepare a v2 series that first introduces the new header, and then applies it to the locations that seem obvious candidates for having both checks. Thanks, -- Marco