Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1789119ybj; Sun, 22 Sep 2019 11:59:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqw40B0JjNwD4w/J6Gt9BY3t3HtknD5QZE0lGwRtTZPyy5W5yPHqS5sTpKFPKanPx8itB6v8 X-Received: by 2002:a17:906:e28f:: with SMTP id gg15mr21329633ejb.182.1569178765069; Sun, 22 Sep 2019 11:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569178765; cv=none; d=google.com; s=arc-20160816; b=sOlXwVvWYc1eWqGv5f+7YYK+mEsAmTwnkix83PlokgJyjZxI2M6fWhCDaYtCiEiqLR ZsR6MDKQ8E6FSM75Cmj8CHUFX9fSn6NjFyFCGhrkxQ5vvpe6qdTHmrT1kba7NxP7eZ0J O/92T4F1aRa0X7io/ymxWbyeYVx1c9w7WS09N9bOHDxfaDE0w7Nczy0yh7e4aQBuQjWQ zu+cLYDDTqA5YbQ8PXYbGfRvAZjKXslaSevOb4O+Ts2u6hBfRikoPKrRCrcJuguVDi8q BH2hHGi93C8/AGi4cKZBB9IgRDLElBxOmlwH0LeRoDLc20gt6cAdZWk5sQU1xBzqBnnE rZjg== 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=EvpPydj1iU8UnRZJqqbCnDu9C5EKJs0suXbTn88VB04=; b=IJ2wdq0XINAw5QuZt4TexfSQAilqFCsfUN8t2cfOk2PvilpHiO1+S3nPsJXH4SLP0Y KXPqRrXYJGpbWlZqbxDoSQcc8EL4ZPRu/pVMr1VfT+k63ju/9IlyI0hA6KQ+k6frMofV uMBErrAoT1TcQhFt3KulUIHVrZnC66UjwptEHWDMH4/lF4aiGEUbcSqxwiEb6DBNhN19 xtAaW7/lMC9a0ldJFHaew2R/C6nBHVLgw4lHAkukWCs1yq4y9k4KrPZVJaN3s5YG3t50 swURm6h5p2+665dKcaB5uyr5s0RxS7oXT9+aRZ0jg6V9ZxVt+2WPF+ckOvPCcVkCW++I D0Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GcxR+Hvz; 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 f29si4106687ejj.110.2019.09.22.11.59.01; Sun, 22 Sep 2019 11:59:25 -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=@google.com header.s=20161025 header.b=GcxR+Hvz; 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 S2393757AbfITRvI (ORCPT + 99 others); Fri, 20 Sep 2019 13:51:08 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:41271 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389956AbfITRvI (ORCPT ); Fri, 20 Sep 2019 13:51:08 -0400 Received: by mail-ot1-f66.google.com with SMTP id g13so6890784otp.8 for ; Fri, 20 Sep 2019 10:51:07 -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=EvpPydj1iU8UnRZJqqbCnDu9C5EKJs0suXbTn88VB04=; b=GcxR+HvzkXI2nIDk0UXBhXZvmf/lAf6OwYRzeQlPhZdE5Qt1dME4AqiNQrA7sG9hI7 0RvOgydID51KqqfXlPuQYPG7ZTCZC16F1Me3VzcyjmWM/wYVSr5W7b/UMOGiFHO+u4lr wl6whGez4/CFR6k7/2A+PNjyQXd61BffSYrvF2c8XXYYmBoHJx9EDPxlb7LN9/7+ljCV oFZURexaaFWGupJRBXjddkIXK9weNdDpMiiC8GzczkyW6sLjtPsYLTNLu9y7+yn4SsJb V061jLr8t6PbPzh2pxwyISRTt+EScUS3u/z2rHiplQM/SvCGkX4wvGzmKdOqXoKMvmWs NRiQ== 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=EvpPydj1iU8UnRZJqqbCnDu9C5EKJs0suXbTn88VB04=; b=I3BpwM5ppZk8ExQzYXIam8gGhNUkGv8ZdRarSsjbLiF+peR4awk4ck0yTOdCH/ZyCH YvDmWt09DL/ZqYRE4bAT15zOzp0l/EzsUWWdoEKQLnf/CsKspSas4Yoo+9tKHwsBbULH h2hfrfxvU/z97FP6ntQW/+jJTS9K1DBYDD3/k9Yzpzb1bT5veeA0xVgx+NNj5eIGHZJA KHxrSjNGk38eoqvJqXG7QSRkr77mBjOyqzaMoMvQ7ZR8Xa/7QWFimlC5pCXXB9WYZhPL DvATETAGmK015ZNnQQ7exVMwFb5743pQKCj7YgC2S3FA/KO79MUh6sCswLHBzN3dIHOE mg+g== X-Gm-Message-State: APjAAAUVuvUNQnevZI/xF/T5ZLswXrzJmeQz1/WR21MpUNzRMdqpxbaV UUs9ZiDPR26mPSbrO1ym9js9Wx8nbRWxg+m6eQMpoGHybjbgdg== X-Received: by 2002:a9d:68d7:: with SMTP id i23mr5023651oto.23.1569001867060; Fri, 20 Sep 2019 10:51:07 -0700 (PDT) MIME-Version: 1.0 References: <20190920155420.rxiflqdrpzinncpy@willie-the-truck> In-Reply-To: <20190920155420.rxiflqdrpzinncpy@willie-the-truck> From: Marco Elver Date: Fri, 20 Sep 2019 19:50:55 +0200 Message-ID: Subject: Re: Kernel Concurrency Sanitizer (KCSAN) To: Will Deacon 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 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, 20 Sep 2019 at 17:54, Will Deacon wrote: > > 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? Nothing special (other than the normal check if accesses overlap) done with size in READ_ONCE/WRITE_ONCE. When you say prune naturally aligned && __native_word() accesses, I assume you mean _plain_ naturally aligned && __native_word(), right? I think this is a slippery slope, because if we start pretending that such plain accesses should be treated as atomics, then we will also miss e.g. races where the accesses should actually have been protected by a mutex. > > 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. Our plan here is to use some of the options in Kconfig.kcsan to limit reported volume of races initially, at least for syzbot instances. But of course, this will not make the real issue go away, and eventually we'll have to deal with all reported races somehow. Thanks, -- Marco