Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2769718ybx; Fri, 8 Nov 2019 09:05:22 -0800 (PST) X-Google-Smtp-Source: APXvYqz5KUT+LqlpQmO15GDf6eYNvJc0DTOjfugT3LMxYyVhqeaQV5UE2nKwlM63aOQEg0vVwz7k X-Received: by 2002:a17:906:670c:: with SMTP id a12mr9682454ejp.273.1573232722542; Fri, 08 Nov 2019 09:05:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573232722; cv=none; d=google.com; s=arc-20160816; b=c6zANo9bpBHh87Mp6f3vUwHwxMFGuvfvrXISVitLGSa3YGivv6/EBz/wrqEaIVR4Wc ecPGUWdgeENTOeFA3iSsc6A5xAwJFQ7pjmedBPXXeKni45tFH5GXypSd6cRI7lMTbsIb 0kYeB4LtTteUh7y7MjuF5xa3tj/J0Hb9OrxBQfQpzOYMIY5OcuLVtTDaP5bj4zQvtijV 0/viUmvLngNy5I1zfN6UZwSKNc7sNT3dig7GZtXXL4+6VK1M3Y6kzdFKjNXrzLd5BAqz 17iLpSeXu6Z7VHmJY4p1FgqZh3FRaYDuNI7oJYY0RoggLgyGnwToHgsBfjJTt4AKegW8 2h7Q== 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=areMWrVEmfkCGN5C3vFUMp6ntvtTANx8pMI7+P+pQwk=; b=bxjO2x7FnSjbnD9tS4nuEuv7tn/rJbuf1+38IdAAztpdKoLLwp0wEXP2NzqKNNpH8r DJTNODAZxI8FI5eMfXofDDdATMzLOJNFwnhgFfT7TlAF9SZ+hDBnISjcDovROyk4GhWP uJ4eGNNvTNC3FF+5MGd7oC7xXg/OP57Rcy3OpuEF+UoaYYieYrlqJsy32+9Wgub3eyFZ tiecdLB5r7iyLJjyrgsTSg7oY12c4THUTW59aLfzq3vC6LQsnT+BTAtSINKsnVjVOTM6 9kVXXCyuyTxp02EBOgIrtwprCq7uDc8BCIx/Kmn8JAyc6U5r7upm8EsX1DNe0eZMNZeM aiaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=fTQAG1nv; 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 o22si4094996ejr.397.2019.11.08.09.04.59; Fri, 08 Nov 2019 09:05:22 -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=fTQAG1nv; 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 S1726095AbfKHRBy (ORCPT + 99 others); Fri, 8 Nov 2019 12:01:54 -0500 Received: from mail-lj1-f182.google.com ([209.85.208.182]:44552 "EHLO mail-lj1-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730745AbfKHRBx (ORCPT ); Fri, 8 Nov 2019 12:01:53 -0500 Received: by mail-lj1-f182.google.com with SMTP id g3so6938251ljl.11 for ; Fri, 08 Nov 2019 09:01:51 -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=areMWrVEmfkCGN5C3vFUMp6ntvtTANx8pMI7+P+pQwk=; b=fTQAG1nv+Xfvawkzfroy56UyjdshaUI6tDZmA2U31BY2vRabBOWqqcIrGwEiaPTMLM UpxslrqN19Q5RkBzYwKrg+R9FYC+kmfTcy86WRoQeVweyUd8I+BSDcL1kR2UVpc9heaR 8C9Z7s7NSuSZCqLYqqjNuS4lSdyWdr7omtzoY= 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=areMWrVEmfkCGN5C3vFUMp6ntvtTANx8pMI7+P+pQwk=; b=jxO0UcFecw31XBZjSU06rCHPduQRGoHsNlCusBnvDmvTLKpsMu9FctI4Ay9t4m53wk tEP8xaqVcqlNPmByCUoYHdoWck1cn/wpignXlHWZR60cg/4YsxUgYLLxYHLZa5/epk9v PBvd0whXbq1ZlcMsFpRfHe0RFzoXvY4eny2yiAWQQM3PvapaQl6emvG4QiKTGSm2Zk3S RxBnQXazspKeymIIVZQ78O831bJNpxYEHG3RLXLPe7p2bNxHBzSNax5F4/1y6YX+jpr6 UdYobjF0KAAD40/yow5tNq2cNfg2DNZN3AVfxW3EYggZ5rNzBc8UXiTjSotV6Z4ycZ1y D49g== X-Gm-Message-State: APjAAAUmp2PjkYRTjdzH6rUZ2U1kd3kJm0MoimyP1SBCoGTI/xFcMYlk 6sbA7/nFfg+WJy3WexrfUxlScEUksE0= X-Received: by 2002:a2e:a175:: with SMTP id u21mr7430836ljl.198.1573232510173; Fri, 08 Nov 2019 09:01:50 -0800 (PST) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id o5sm3161909lfn.78.2019.11.08.09.01.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Nov 2019 09:01:49 -0800 (PST) Received: by mail-lj1-f180.google.com with SMTP id r7so6982166ljg.2 for ; Fri, 08 Nov 2019 09:01:48 -0800 (PST) X-Received: by 2002:a2e:8809:: with SMTP id x9mr7562934ljh.82.1573232508697; Fri, 08 Nov 2019 09:01:48 -0800 (PST) MIME-Version: 1.0 References: <000000000000c422a80596d595ee@google.com> <6bddae34-93df-6820-0390-ac18dcbf0927@gmail.com> In-Reply-To: <6bddae34-93df-6820-0390-ac18dcbf0927@gmail.com> From: Linus Torvalds Date: Fri, 8 Nov 2019 09:01:31 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: KCSAN: data-race in __alloc_file / __alloc_file To: Eric Dumazet Cc: syzbot , elver@google.com, linux-fsdevel , Linux Kernel Mailing List , syzkaller-bugs , Al Viro , Eric Dumazet 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 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. Linus