Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp6564912ybx; Mon, 11 Nov 2019 11:02:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwgiqtsNxWHW6vAI3Wdr/aVgP0UsHR82tVh6J7W4HRPnc4O1un8LvBGva30xku8oPjnzdeR X-Received: by 2002:a17:906:13d5:: with SMTP id g21mr24123632ejc.72.1573498965046; Mon, 11 Nov 2019 11:02:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573498965; cv=none; d=google.com; s=arc-20160816; b=mbjlWZMpb831Bx68Mv7JN6oY+GSY9qXt2uzUDFuPCVwcPaq013c2V5nBi3syaASG8A 8bSbye4Zz5lhqRmVVwdQ6d6Vi3ls9tlgDBW35WjsFx/VNInIyJlb/o+j/84QBGWhEv+k eN9cU4Ok6wckaOilZTXRL/MfqAdx+YIFPidAuX+zXVaovOrwICYnPMROV8sqKV8H0Teq viZzpHQKCXpWdWcYJn4PAUSB/9eJVA4mGVoGUhhmRri0BK7Zk0DM14avLEU5fiLcDnTy 3g+PHF2wkltMi6D46QXPMjkDJ0BOvQ+EcYbBuvu8sAAWq3hSph6ImF8gbGxfibH6wBqF bdCA== 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=7X+i/K/e1sfyo/sSNSz4o3Zk6I09VNaSQEUuToduhok=; b=is3v2N7Bndi0aajpy6PXA8z7XiFujVU2jp1byjlExPuDJm76y6l6Qbnf7bjwBlBBEs mFIin4210V82M8HkWam5l1yDk7VqBGg3K7ihcfNfW2blX0rnAzTIZPYDHAlpnfMdYGR5 U9+ekKlZpdmZ3gmRUJQhvLJ1klqqPr7N5oSSlkSU3FUEwrP2WSGivTNiVcjOuJY7Ul4m R7ds8fK8m9BYK2YoLMQ/NRWW33HwvESw0RS/3IyEfpcoB6Qq9YD/WwAoRAAnObJR5lKp ZnSUvaWthyQ5y3sICmMVlTZlZRdekC+pwUSTVfj7n0o1WThCyrQ6y8U0h+b55SDgRaIq 9rFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=IfGf7e0v; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si9564661ejy.259.2019.11.11.11.02.15; Mon, 11 Nov 2019 11:02:45 -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=@linux-foundation.org header.s=google header.b=IfGf7e0v; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730424AbfKKTBL (ORCPT + 99 others); Mon, 11 Nov 2019 14:01:11 -0500 Received: from mail-lf1-f49.google.com ([209.85.167.49]:39176 "EHLO mail-lf1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729957AbfKKTBK (ORCPT ); Mon, 11 Nov 2019 14:01:10 -0500 Received: by mail-lf1-f49.google.com with SMTP id j14so2123877lfk.6 for ; Mon, 11 Nov 2019 11:01:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7X+i/K/e1sfyo/sSNSz4o3Zk6I09VNaSQEUuToduhok=; b=IfGf7e0vnSjr5D5/DFnDtseZozwEmG+KD34J8cRx2xf34AIG9uoiU23s5fCGgXqEK5 pSM5R4LyfWGXW4tT+suDhlW+bfiQEQkNQpZTYlGHKMQ/MYDHAI4BuxjcbA3OnkuY9PoG 2YgxBEu1RUtZ1BQ8hGZGSjXauXMoa4FK+6ZBk= 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=7X+i/K/e1sfyo/sSNSz4o3Zk6I09VNaSQEUuToduhok=; b=Xlash8t0tAlW7htMkLHvGuV8Hx4GUhMP/l5M7dhu5G0B6LKZPGWzYTg/s33Ups/oGW 4sKKo/nD8Q1n547Xnh3xBnlAazOBKsmJIuXbcXqTE9GpfPdrCZlCx5arR1jZNrEES/Lv NFTxy3gHY1cSRAcjrsdEvsncGTfIrW7PFhEyzNWlTCcn8BFa6kCo6g8tI+A/qka9n1DC r3n5gdTGXrl+AN2Bs8uiyPyMtqtwzTAi0+BUdTp9Wt5WhGfQFSy2olDwlv3LeiSCj84W uA9amZsBIcSPUn1NUm1Cr4/hkGLX1V7MmUfe4OsBKIzoLm3oiStp6pSXulrKm6TMXSgw u29w== X-Gm-Message-State: APjAAAXyjUlTU3qfrlqABupC7mXEFqZz9Gd3eYCx17iPRi6Uhs/j0fcu w12gcGWJhvtDTtsWKG3beWkaNF9QLNg= X-Received: by 2002:a05:6512:25d:: with SMTP id b29mr5805888lfo.171.1573498866586; Mon, 11 Nov 2019 11:01:06 -0800 (PST) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com. [209.85.208.175]) by smtp.gmail.com with ESMTPSA id d5sm1539822lfl.2.2019.11.11.11.01.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 11 Nov 2019 11:01:05 -0800 (PST) Received: by mail-lj1-f175.google.com with SMTP id e9so14945090ljp.13 for ; Mon, 11 Nov 2019 11:01:04 -0800 (PST) X-Received: by 2002:a2e:982:: with SMTP id 124mr8876387ljj.48.1573498864524; Mon, 11 Nov 2019 11:01:04 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Mon, 11 Nov 2019 11:00:48 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Eric Dumazet Cc: Alan Stern , Marco Elver , Eric Dumazet , syzbot , linux-fsdevel , Linux Kernel Mailing List , syzkaller-bugs , Al Viro , Andrea Parri , "Paul E. McKenney" , LKMM Maintainers -- Akira Yokosawa 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 Mon, Nov 11, 2019 at 10:44 AM Eric Dumazet wrote: > > An interesting case is the race in ksys_write() Not really. > if (ppos) { > pos = *ppos; // data-race That code uses "fdget_pos(). Which does mutual exclusion _if_ the file is something we care about pos for, and if it has more than one process using it. Basically the rule there is that we don't care about the data race in certain circumstances. We don't care about non-regular files, for example, because those are what POSIX gives guarantees for. (We have since moved towards FMODE_STREAM handling instead of the older FMODE_ATOMIC_POS which does this better, and it's possible we should get rid of the FMODE_ATOMIC_POS behavior in favor of FMODE_STREAM entirely) Again, that's pretty hard to tell something like KCSAN. Of course, it's then questionable whether our rules for not caring are necessarily the _right_ rules for not caring. For example, if you have threads, the "more than one process opening it" doesn't trigger. It's literally just atomicity across processes that we guarantee. That's certainly a bit questionable. But that's a higher-level decision. Linus