Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3344014ybg; Fri, 25 Oct 2019 02:45:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxHg+xbVpTQvf4LVYATJZde5nx5/UC1Yz6PjLejMncbE18Sj4BL+u3OpQr1VKQ71Rfk325q X-Received: by 2002:a17:906:fcce:: with SMTP id qx14mr2583543ejb.186.1571996711955; Fri, 25 Oct 2019 02:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571996711; cv=none; d=google.com; s=arc-20160816; b=MuGOoajAiriTi0tR+auNloyeza8DtmjowuPmxOrvFkvUGdzMoBd3PFnnQ8+jyGUIiC J6gx+UUj4Gt2e8scxGZdK+VNOxQ7g/4Dr01fcFZl5++qYBp9lobyQODn8DxQSCvhaR2G 6xVDqNf9PIc0Jq0ZehsR8OE4AtW1I0YiYJ+fC3d//ghIKDgIxrxltxUeADy2vWGzH8uF ldfwWRT4bfe2sqpxgDLpm9j6uWEA4hfrX2kDdKKUKWXqq+V1ozAcjUsq1hTJ74g03R48 RlecXDyunBwFngKMIqLLn3AS51yPMj5VS2QM1KYZT9GPUhbaStd1pwZU/wOLdj+na02r moaA== 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=Wp7j55fCu8VBbV3w6xxbpPhvOdRSu/ha8VU4hcpzHdY=; b=IiJoK7oPIRMgrrxJFNh7Gi57jQGQs4issTQDpbk0Gg9K+1AS+a2wumFhBLWVDwzuPL /TXUJvPwAyrtwMkucGPJXK7AQgvtGqNBdnosuXO1Aho5R32zzbVQwemyCNYDk/RpMqnQ k2GKurOKj4eDAXzShC1dP2jNmuHa2Dsp25jktaoomEhTjflQ9M28WtbnN2SiKSIMe8Nb /U5SWxqW79XU8QKu0NZzDCive16DGTi22HEN+zP6hMRg8ZKeW+QkY1dPbUJOfnNv8kWk gDkz8jFm3VoD6xvRL9pYP70yCBdgxfqVVJxB+xCO1ZDl77oKqbhn5+cHTTpqgM7WSVgr +sFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=GSxZTUgn; 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 r8si881841eju.426.2019.10.25.02.44.47; Fri, 25 Oct 2019 02:45:11 -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=GSxZTUgn; 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 S2392808AbfJXLCS (ORCPT + 99 others); Thu, 24 Oct 2019 07:02:18 -0400 Received: from mail-ot1-f68.google.com ([209.85.210.68]:35074 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391693AbfJXLCR (ORCPT ); Thu, 24 Oct 2019 07:02:17 -0400 Received: by mail-ot1-f68.google.com with SMTP id z6so20279183otb.2 for ; Thu, 24 Oct 2019 04:02:16 -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=Wp7j55fCu8VBbV3w6xxbpPhvOdRSu/ha8VU4hcpzHdY=; b=GSxZTUgn5T2HRAlKrADzvv53PhUqCr6HGwWIfZ+q0bFeBI/8il22Kv3vpugrhHlUKc JSd3yXOh4TDUfIqO8JPYXGilp4Vg98FIe9l+pL6F5FO2iW7zWgkU28rHfnrJDKC/RUhT 9y7xvvCroceLV28G/DNxI6s3sI/MSBb0LxVcLxj5vL25ilXRyhqWJ+AnuTdwWYD+wKpX O5vqsk+9Nvl/sUnYEZWYKKkmZRx3M69w2mSa0T0GYjtT0TBikdjdIHl9bdIy1avJXFGR mVT16n7Jv0qZPjTSiWzuZVrSqaZmV1oEhg+iVLOxp3SXxbxsxWpuo8R2VJIKx8+2qGRR M+7Q== 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=Wp7j55fCu8VBbV3w6xxbpPhvOdRSu/ha8VU4hcpzHdY=; b=oBGePFsu+zeocMJfvIAxB4AYF6efNSJgMzVxqBuqaNWQnAiUfBqHgBf79D2N9TwyMZ OoEcOwpaH58VKdaxU49dEXMJvaBu+d32Evs9IleW6d0GSNDRN/t6OLyw4Y1v72oI241V uBKtMbtZpR2OotpjuBiu2wvNldA2bnAhj5hkX3ERVoblMrKnUkhd5C8dvq4UFGc/nrpg ogyzxzYvjtGhzmT47tsSA5A4ilXg1DCY79HJj2xLM+Rbq6ciDZMVhhx/1s205Auu189J q/31RzN0vFj4vzFMlkOmRZFGdd0hxPPbjo/pPscqwHHd8+5QG9lHLiIL25a7z2w5Xf0L MTTQ== X-Gm-Message-State: APjAAAXiOHNhtFLamc7emM+rAgi88CMLKkTRKJothTVqUan5HI9ODhjZ CWLwZdixVPOpHrieTV7ZPAd0uDErFjAdyQbhd/iWxg== X-Received: by 2002:a9d:82e:: with SMTP id 43mr8537524oty.23.1571914935893; Thu, 24 Oct 2019 04:02:15 -0700 (PDT) MIME-Version: 1.0 References: <20191017141305.146193-1-elver@google.com> <20191017141305.146193-2-elver@google.com> <20191022154858.GA13700@redhat.com> <20191023162432.GC14327@redhat.com> In-Reply-To: <20191023162432.GC14327@redhat.com> From: Marco Elver Date: Thu, 24 Oct 2019 13:02:03 +0200 Message-ID: Subject: Re: [PATCH v2 1/8] kcsan: Add Kernel Concurrency Sanitizer infrastructure To: Oleg Nesterov Cc: LKMM Maintainers -- Akira Yokosawa , Alan Stern , Alexander Potapenko , Andrea Parri , Andrey Konovalov , Andy Lutomirski , Ard Biesheuvel , Arnd Bergmann , Boqun Feng , Borislav Petkov , Daniel Axtens , Daniel Lustig , Dave Hansen , David Howells , Dmitry Vyukov , "H. Peter Anvin" , Ingo Molnar , Jade Alglave , Joel Fernandes , Jonathan Corbet , Josh Poimboeuf , Luc Maranget , Mark Rutland , Nicholas Piggin , "Paul E. McKenney" , Peter Zijlstra , Thomas Gleixner , Will Deacon , kasan-dev , linux-arch , "open list:DOCUMENTATION" , linux-efi@vger.kernel.org, Linux Kbuild mailing list , LKML , Linux Memory Management List , "the arch/x86 maintainers" 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 Wed, 23 Oct 2019 at 18:24, Oleg Nesterov wrote: > > On 10/22, Marco Elver wrote: > > > > On Tue, 22 Oct 2019 at 17:49, Oleg Nesterov wrote: > > > > > > Just for example. Suppose that task->state = TASK_UNINTERRUPTIBLE, this task > > > does __set_current_state(TASK_RUNNING), another CPU does wake_up_process(task) > > > which does the same UNINTERRUPTIBLE -> RUNNING transition. > > > > > > Looks like, this is the "data race" according to kcsan? > > > > Yes, they are "data races". They are probably not "race conditions" though. > > > > This is a fair distinction to make, and we never claimed to find "race > > conditions" only > > I see, thanks, just wanted to be sure... > > > KCSAN's goal is to find *data races* according to the LKMM. Some data > > races are race conditions (usually the more interesting bugs) -- but > > not *all* data races are race conditions. Those are what are usually > > referred to as "benign", but they can still become bugs on the wrong > > arch/compiler combination. Hence, the need to annotate these accesses > > with READ_ONCE, WRITE_ONCE or use atomic_t: > > Well, if I see READ_ONCE() in the code I want to understand why it was > used. Is it really needed for correctness or we want to shut up kcsan? > Say, why should wait_event(wq, *ptr) use READ_ONCE()? Nevermind, please > forget. > > Btw, why __kcsan_check_watchpoint() does user_access_save() before > try_consume_watchpoint() ? Instrumentation is added in UACCESS regions. Since we do not access user-memory, we do user_access_save to ensure everything is safe (otherwise objtool complains that we do calls to non-whitelisted functions). I will try to optimize this a bit, but we can't avoid it. > Oleg. >