Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2797577ybx; Fri, 8 Nov 2019 09:26:36 -0800 (PST) X-Google-Smtp-Source: APXvYqy8LhGlQcqE4VlwJ+Nb3vet3ClEaY0lKH0uUyVJ9XLFsiY/6W5h8R90aNhS/0gJe0e7CE7o X-Received: by 2002:a50:9908:: with SMTP id k8mr11369371edb.75.1573233996310; Fri, 08 Nov 2019 09:26:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573233996; cv=none; d=google.com; s=arc-20160816; b=whSMjfFVCyou+0edDPX+DgeJNkuVICyEwfefuI8XnHrZII8zst4PCeT31ZkyvEi/It CnmMPu5ypgX9DsdFaT9z1YA06ZZHFJ60NuIrL/gpazz9olkuTnGl0QHhSTIwlobDg50z x7e2sfQc8U9dcRqCEOMqdH/gXBwbYvpXbPx9t7sngQjHMvqt7qIY48D3MSPwFm+KwzJO WjAlAbeAgbrSPAu1ykn4Ujyo4K4a+lHSgH5XYFCzWo9ZFroDqj6y02ASSif2qiOW+MDa 4u39F2aRt03fU5CoPwwvv7Q4M6J7LVA/tT+Q/aDrCOVX3g4qTzQda1bdYDO50U1jLk+r dGzQ== 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=kCFuBzX0ssMEDdf5FEm7iYvhAqHfXgR1VUvfj9lOe/w=; b=u3MelZbdE92shXlwGAnlRqYMt2DQdh3U1RjaIL5+iXBvqC8KvIzN74/i2rBsaBi1Zq odFxc/ozlBBKqYJW60+d9uE0E8g/LSakBAAia2dIyyy4pg67hDa5/t8llkADIdT9q6pu GkNCsOQHu/XaMKfLIE+j/IVpr+88zWK9CatUSM/aHi7iXlpuBFxcMYGfW1T3bfqyC+Lf if2YPfdVHGUjC9l2vFhzRb282YdBw3YO6aYww4ZJiB++ZArzKM3HVuYEdfWDJOFJPuJt H3YHREXitRgWz3hYebkIdz7hLK1eYyMh/epVzpOI20EGh7iNjz5BA3jntbjli5OtgBJ6 1YrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="CEfiZj/b"; 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 v16si5000634edc.142.2019.11.08.09.26.13; Fri, 08 Nov 2019 09:26:36 -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="CEfiZj/b"; 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 S1728410AbfKHRWy (ORCPT + 99 others); Fri, 8 Nov 2019 12:22:54 -0500 Received: from mail-il1-f175.google.com ([209.85.166.175]:34929 "EHLO mail-il1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfKHRWy (ORCPT ); Fri, 8 Nov 2019 12:22:54 -0500 Received: by mail-il1-f175.google.com with SMTP id z12so5812828ilp.2 for ; Fri, 08 Nov 2019 09:22:53 -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=kCFuBzX0ssMEDdf5FEm7iYvhAqHfXgR1VUvfj9lOe/w=; b=CEfiZj/bsHwWAjk9E2+anUgIMAxbVSUOX+XJF2bZ0OcF0BZenHgQ0u67RQKxsSJVvO cg6auRE4K1Dd46AV9IDjw+fBDqbhIOvgtZ+xWLJSCCu7ESdlYcccDwf50l/5fKpJ98SU qu2KR81c1yXgqEMCFodWqnFqZnWA1GSDihhSmrcE97ct41ooi829D6bwXP4yixBHxOPR 82Q1s9H/qJ44YK+ZDn1u9LMEaIEj2yNDLFqsg5PTSK9is2D2nmxrN7ZlqJUqvN89jCDH Z6dtGmWJoisrj5v4yiRnDtrVjKHAtkPbjKMzgkdxrde76DY/9Tx2bxjqD4hsArlMj+q+ 6A3Q== 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=kCFuBzX0ssMEDdf5FEm7iYvhAqHfXgR1VUvfj9lOe/w=; b=AkPvyJfdoyrzeZF0a//SM5/n2DDGIwFUFD+fEewbSV/cP6cQIuREX1Hrf6w24zNt+g tmFneTHsq7+kXlekFUVPrs+v3CFpft60PIQO1QJGa891TVBAsi6AzC5vQ/Ko2P87uQzw syml8P/WQQMSsugXjRkwPeS7PnNgxn23FF7izDTjh9tONi+6lw1AcNTj0Blx1OSdCfF2 iktSS2DoAH9Tvb02tPFFiGwxDm4C9vHu/vtzAejh79QIQ2pR16TLD0j7AaeHkVRYOfM+ 2qFcUWx7hdJsnbexLgzqtNtuST91m05tAjD4z2bwcUsxR1s2L7ToJCcjPiAo8ox4Dmol bFUA== X-Gm-Message-State: APjAAAWqSLFVI+PagyUVd0eLbQqCwzNnRzN6JTD3OZzV/HdCDdbCAnPs kd1JuMxuBpRTRMrVr7oIp/5mtl1du9vjtYPPOfyqtw== X-Received: by 2002:a92:7e0d:: with SMTP id z13mr14651612ilc.168.1573233772737; Fri, 08 Nov 2019 09:22:52 -0800 (PST) MIME-Version: 1.0 References: <000000000000c422a80596d595ee@google.com> <6bddae34-93df-6820-0390-ac18dcbf0927@gmail.com> In-Reply-To: From: Eric Dumazet Date: Fri, 8 Nov 2019 09:22:41 -0800 Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Linus Torvalds Cc: Eric Dumazet , syzbot , Marco Elver , linux-fsdevel , Linux Kernel Mailing List , syzkaller-bugs , Al Viro 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, Nov 8, 2019 at 9:01 AM Linus Torvalds wrote: > > On Fri, Nov 8, 2019 at 5:28 AM Eric Dumazet wrote: > > > > Linus, what do you think of the following fix ? > > I think it's incredibly ugly. > > I realize that avoiding the cacheline dirtying might be worth it, but > I'd like to see some indication that it actually matters and helps > from a performance angle. We've already dirtied memory fairly close, > even if it might not share a cacheline (that structure is randomized, > we've touched - or will touch - 'cred->usage') too. > > Honestly, I don't think get_cred() is even in a hotpath. Most cred use > just use the current cred that doesn't need the 'get'. So the > optimization looks somewhat questionable - for all we know it just > makes things worse. > > I also don't like using a "WRITE_ONCE()" without a reason for it. In > this case, the only "reason" is that KCSAN special-cases that thing. > I'd much rather have some other way to mark it. > > So it just looks hacky to me. > > I like that people are looking at KCSAN, but I get a very strong > feeling that right now the workarounds for KCSAN false-positives are > incredibly ugly, and not always appropriate. > > There is absolutely zero need for a WRITE_ONCE() in this case. The > code would work fine if the compiler did the zero write fifty times, > and re-ordered it wildly. We have a flag that starts out set, and we > clear it. There's really no "write-once" about it. > Ok, so what do you suggest next ? Declare KCSAN useless because too many false positives ?