Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5722956rwl; Thu, 29 Dec 2022 01:42:46 -0800 (PST) X-Google-Smtp-Source: AMrXdXuCITKTtAvwnb3Iy6sPPnnRr0GPfChC2QEy0AHD9pOTwTt8y/+HDLZ1UhC5HgHsKWJsbFcO X-Received: by 2002:a17:906:524b:b0:7c1:5098:907f with SMTP id y11-20020a170906524b00b007c15098907fmr23076040ejm.61.1672306966599; Thu, 29 Dec 2022 01:42:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672306966; cv=none; d=google.com; s=arc-20160816; b=j4t5ubKUFMwKUHOqpFV1oCBi0+KcrGU0XiXCeTVy2HB/nMDgpTOovyVsZcTLMIWyjM e+gmpjvG0hzYjZv5ndg9bz6j/2TGlivfl19su9ykWmhzc/TlT4vLjRADYHMAP2NwlTA5 QFNRbXGKamzOAXRjTMDKmkvSfEBj78s3CIVIuvthhIBiY9EHIYE3uQN8iXP9p5YyId2R 4c9fTgQrO9dAxejFepDoz3mvoRkCO7e60PvVEw1pRacdr/zjusSoBam+k6EBv2whU/53 wTQVRyGTCtcYGq6k73tkRSjrL+o5/XHPlSfWr8X3f7B88IemlpmtgaD23G3lyDXOtr+k hGhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=L0EoTG3qDJubgjvELC5diq0fKOZgb4tkHLVSHGjypzo=; b=vApvlYc7YMm+6UMh0uSXDGSEDda2Q2HTKpcpjsw6mmttJ1S/MvsGnq0pedqL7yaWCi R+tbR6HxWeb/ED4vJj46DtdcnOEx5uYvWmJ6v7bXcex7x0cvGSD2Lg49kcPWQFRtryaX FQ8GrtMRn/i90HY8GgANKmlxP3zJtSxGWQ+E8d6bQp22hc5WxCWXm0NI8u+4zXHbqQLY d1rmIBieVEmMzvykGxjjeGLIk9OmKx9uqJOdjIEYyAFJBbhujsyseOQmwXxodyGhitFT eGeMDKlN6+drPzs81d/6QDYOH7h23tZvwhYkpG3mZRPSyFHzWDunrLYydHgsMde0voaz J19w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=rlOYwqUN; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=PxswnNSv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw16-20020a170906479000b006feb76dbd51si16471894ejc.289.2022.12.29.01.42.32; Thu, 29 Dec 2022 01:42:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=rlOYwqUN; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=PxswnNSv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230382AbiL2JVH (ORCPT + 62 others); Thu, 29 Dec 2022 04:21:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbiL2JVF (ORCPT ); Thu, 29 Dec 2022 04:21:05 -0500 Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 859C6DEC9; Thu, 29 Dec 2022 01:21:03 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.nyi.internal (Postfix) with ESMTP id 168385C024D; Thu, 29 Dec 2022 04:21:01 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Thu, 29 Dec 2022 04:21:01 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm1; t=1672305661; x=1672392061; bh=L0EoTG3qDJ ubgjvELC5diq0fKOZgb4tkHLVSHGjypzo=; b=rlOYwqUNgdnXQ8AWOWDlf12lwY y3j9rkPML69pZMjIJvMHjx7zjNSVhQe1bOpgdrgpT20LV9z2bSUy8DZUZhDydFKD tqOp6doVG8dKpxNO20dNSIIJ3DKpC4xWP0rmPIBcLduCqnlC3pWpCMl/7b9guUzV 8yYxWqQ6XpfJBa8OXlR8ASnl5QvAoacxuj06tc16fKj00UCwVrEL30N3tXQN/6uz IvhzHNk/n+TmUxdBwqStFOlwAEhQLP+JuczEWCuuP/aV/K4bwTABAspkPPWSnEOZ GYoi1PF9w3jeVnHJIdGJWndUgK3R/QDlK/ObyoNrqiKxGPWHlpAhziLUYTkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1672305661; x=1672392061; bh=L0EoTG3qDJubgjvELC5diq0fKOZg b4tkHLVSHGjypzo=; b=PxswnNSvJtQ4X8wU9PkLBFhmfR094T+Ats/VFIzsTQSz S9QibOSuJUTpt/o5G7sMZw5zguZ1+Gp9X7gTMbbewxzH34s9jvXd7Nrk+tjxbyHP 2fKLjI5D2AqtpbgzGigfEJjeAilVHN09IfwYWZ8lNAdv+OxIR06Z2SgoKkR03yUs KTnVDMu8yKDnpxLH4JTg0OkAukhIUIojVhGoJ0e/FosY7lCI+9oFv3K1xG1UDmQY IXNfEwRZlRffM4VvkaqbDSHlDECpuoB3rzddYBlBa0gbT7iIKbtA0TVBqaA4Krnw muZggS4Dwm4GcWT/rj4YcOlrHOuBdLw/nW8bJhpqJw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrieeggddtfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdetrhhn ugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrghtth gvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedtkeet ffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrrh hnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 56787B60089; Thu, 29 Dec 2022 04:21:00 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1185-g841157300a-fm-20221208.002-g84115730 Mime-Version: 1.0 Message-Id: In-Reply-To: <7815c8da-7d5f-c2c5-9dfd-7a77ac37c7f7@themaw.net> References: <166606025456.13363.3829702374064563472.stgit@donald.themaw.net> <166606036215.13363.1288735296954908554.stgit@donald.themaw.net> <20221221133428.GE69385@mutt> <7815c8da-7d5f-c2c5-9dfd-7a77ac37c7f7@themaw.net> Date: Thu, 29 Dec 2022 10:20:40 +0100 From: "Arnd Bergmann" To: "Ian Kent" , "Anders Roxell" , "Tejun Heo" Cc: "Greg Kroah-Hartman" , "Minchan Kim" , "Eric Sandeen" , "Alexander Viro" , "Rick Lindsley" , "David Howells" , "Miklos Szeredi" , "Carlos Maiolino" , linux-fsdevel , "Kernel Mailing List" , elver@google.com Subject: Re: [PATCH 1/2] kernfs: dont take i_lock on inode attr read Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 23, 2022, at 00:11, Ian Kent wrote: > On 21/12/22 21:34, Anders Roxell wrote: >> On 2022-10-31 12:30, Tejun Heo wrote: >>> On Tue, Oct 18, 2022 at 10:32:42AM +0800, Ian Kent wrote: >>>> The kernfs write lock is held when the kernfs node inode attributes >>>> are updated. Therefore, when either kernfs_iop_getattr() or >>>> kernfs_iop_permission() are called the kernfs node inode attributes >>>> won't change. >>>> >>>> Consequently concurrent kernfs_refresh_inode() calls always copy the >>>> same values from the kernfs node. >>>> >>>> So there's no need to take the inode i_lock to get consistent values >>>> for generic_fillattr() and generic_permission(), the kernfs read lock >>>> is sufficient. >>>> >>>> Signed-off-by: Ian Kent >>> Acked-by: Tejun Heo >> Hi, >> >> Building an allmodconfig arm64 kernel on yesterdays next-20221220 and >> booting that in qemu I see the following "BUG: KCSAN: data-race in >> set_nlink / set_nlink". > > > I'll check if I missed any places where set_link() could be > called where the link count could be different. > > > If there aren't any the question will then be can writing the > same value to this location in multiple concurrent threads > corrupt it? I think the race that is getting reported for set_nlink() is about this bit getting called simulatenously on multiple CPUs with only the read lock held for the inode: /* Yes, some filesystems do change nlink from zero to one */ if (inode->i_nlink == 0) atomic_long_dec(&inode->i_sb->s_remove_count); inode->__i_nlink = nlink; Since i_nlink and __i_nlink refer to the same memory location, the 'inode->i_nlink == 0' check can be true for all of them before the nonzero nlink value gets set, and this results in s_remove_count being decremented more than once. Arnd