Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp2089957ybj; Sun, 22 Sep 2019 19:35:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRfzz568X+aXikcGbS2eQ/YmFVB6gpJXHipyYWXw6lFW9z93NVY0cAX5PA6PtJKq+edlF7 X-Received: by 2002:a17:906:57ce:: with SMTP id u14mr16593777ejr.184.1569206155641; Sun, 22 Sep 2019 19:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569206155; cv=none; d=google.com; s=arc-20160816; b=kWEB6a4JENE2c4j6KXBNJ0s6ubMJ9bx8yrj+wO0v1G7fqW8OGwYVpJb5I2TE+Ik4Ty M2OSHYEQOSBoWMysrHHqUZwzmKedE6qT4A4V852AMjdgACCuUsuFSJnyW1I8i3P29Qw5 KcLjUh6VGDlwWLPhAxNF+U+9iW5WyBGnXCnxjCiq6on5sYZXOUpC4ucPjK8PNxd5dtkl kUPnL+iYWDj+QF4sDD+0VLk+TFGDOIEL2LTFEJ3dvVTEH4ouXk+sQv7RM3WqovBfGFY1 FbWIQxmvQmNEbkHYrP74ED0bexiyGJXR11YA89IB81yzHVSaoU7PJNMgJhloj6KUDQ0P S/KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=hSNyPKLLmygnPBchyfHN97oiH6P+a0yze9eJXxgENQk=; b=ipApu5F+1X3ioDr9zLkYEj3avjQCNgnZ6fj1BFuGadg87kLrbEhamLbDPjNDOBK/AT ptS38OfV7LGob8HaEFSsq4aJGBpAkgafE47mJ0R4/cMr0Rxpo06HSoErkGxZ1MjPffv7 /HUptth3dBZDD8CZfQsbBqHDuOrANK8AAU0MvZYPFYXxe3eUdhM2YaXijk4KvvHSDzmD czminmJKb9+JAywmnPdx/MGRlG/fJdLV4loi64VpWyuhvN+JDu4zFtNpN2NMPqRfdSl/ tl9g4ZW4kfWBYxc/Dxvfb9Vfi/9y7JNynzO9YypWMbOuENb2U69RPlzmECl4s6YGnvYw L+Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bbTzVipQ; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q25si6172854edb.159.2019.09.22.19.35.32; Sun, 22 Sep 2019 19:35:55 -0700 (PDT) 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=@kernel.org header.s=default header.b=bbTzVipQ; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404739AbfITPy2 (ORCPT + 99 others); Fri, 20 Sep 2019 11:54:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404729AbfITPy1 (ORCPT ); Fri, 20 Sep 2019 11:54:27 -0400 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 444BE2086A; Fri, 20 Sep 2019 15:54:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568994867; bh=JB/KlavkKYyb6cShAWrH8NzqXSYVIlW2OW86Y+sEVJ4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bbTzVipQPKINemMAWxR+AAOssChAagB9KRceRQ8GEXxOAeb2qRyxDif3CLPBDf1KH jL28zQC3QpkSwJaIj5BP9MnJ0GCXR4y+pUaFF3ZVzHBTFaKO097I9FvQ+LHhv9/0Qp PLyFaIaqTwkHIPQ/RQjKcMXECZCek5yRZ8OsZKY0= Date: Fri, 20 Sep 2019 16:54:21 +0100 From: Will Deacon To: Marco Elver Cc: kasan-dev , LKML , Dmitry Vyukov , Andrey Konovalov , Alexander Potapenko , paulmck@linux.ibm.com, Paul Turner , Daniel Axtens , Anatol Pomazau , Andrea Parri , stern@rowland.harvard.edu, akiyks@gmail.com, npiggin@gmail.com, boqun.feng@gmail.com, dlustig@nvidia.com, j.alglave@ucl.ac.uk, luc.maranget@inria.fr Subject: Re: Kernel Concurrency Sanitizer (KCSAN) Message-ID: <20190920155420.rxiflqdrpzinncpy@willie-the-truck> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Marco, On Fri, Sep 20, 2019 at 04:18:57PM +0200, Marco Elver wrote: > We would like to share a new data-race detector for the Linux kernel: > Kernel Concurrency Sanitizer (KCSAN) -- > https://github.com/google/ktsan/wiki/KCSAN (Details: > https://github.com/google/ktsan/blob/kcsan/Documentation/dev-tools/kcsan.rst) > > To those of you who we mentioned at LPC that we're working on a > watchpoint-based KTSAN inspired by DataCollider [1], this is it (we > renamed it to KCSAN to avoid confusion with KTSAN). > [1] http://usenix.org/legacy/events/osdi10/tech/full_papers/Erickson.pdf Oh, spiffy! > In the coming weeks we're planning to: > * Set up a syzkaller instance. > * Share the dashboard so that you can see the races that are found. > * Attempt to send fixes for some races upstream (if you find that the > kcsan-with-fixes branch contains an important fix, please feel free to > point it out and we'll prioritize that). Curious: do you take into account things like alignment and/or access size when looking at READ_ONCE/WRITE_ONCE? Perhaps you could initially prune naturally aligned accesses for which __native_word() is true? > There are a few open questions: > * The big one: most of the reported races are due to unmarked > accesses; prioritization or pruning of races to focus initial efforts > to fix races might be required. Comments on how best to proceed are > welcome. We're aware that these are issues that have recently received > attention in the context of the LKMM > (https://lwn.net/Articles/793253/). This one is tricky. What I think we need to avoid is an onslaught of patches adding READ_ONCE/WRITE_ONCE without a concrete analysis of the code being modified. My worry is that Joe Developer is eager to get their first patch into the kernel, so runs this tool and starts spamming maintainers with these things to the point that they start ignoring KCSAN reports altogether because of the time they take up. I suppose one thing we could do is to require each new READ_ONCE/WRITE_ONCE to have a comment describing the racy access, a bit like we do for memory barriers. Another possibility would be to use atomic_t more widely if there is genuine concurrency involved. > * How/when to upstream KCSAN? Start by posting the patches :) Will