Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3102182rwo; Thu, 3 Aug 2023 22:25:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEmB0x0t91M8xra3gH4fEGoKfnxxYaVaODHhYXAdFllpj2gl6OAzfTPsyMeZWze+/5eS8YJ X-Received: by 2002:aca:2b18:0:b0:3a4:1983:69e6 with SMTP id i24-20020aca2b18000000b003a4198369e6mr691159oik.45.1691126750939; Thu, 03 Aug 2023 22:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691126750; cv=none; d=google.com; s=arc-20160816; b=zF/p2B656QR34Q9tRan5QXyED0H7GTZ68ufDZdBFk765h317lVAAK1CVkRaiK0tqaA M/ZuDmcGCdTTOl/S3ADPj86FitY6qGMB7KBxfjmxVdoNfQ37PYSaS1bUfQaLkGZrHArU qduQv4jGKlvjgv7Xqm/adwbEGkPLFedKIGGiFJXb+vFcCV7yaByn+o2yeswM260YwRbe EE/9S9nO2Md3IHFF6JOGPNSU0hrom3sBscjTcl+nYnBJM2rFORgeuRe49msLwYLQ7lMx ZBV302pHn8GQ8CTkclf6JT5RJTRDMmiqcyst1Emk+UzEDTd+IO/JXw1QSHIORUbNXDwA 7UXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QoZhwhwxP+ujyhKVgT7oNV0UqypRIfalkfzbu158U/g=; fh=nL118WpnY3LGXPi0GP5e49DxM7+TEZhr95g9EGwQjuY=; b=a4Xga4h4p5/iwPZmQejWC8mDi/Ni9zD8JKbAP0zKg3xSJm+PkLZ1OtzbunEtjOYVyj 2Bz2jn2M2yR9B0SvpIus3OmXknVQlUbrJNhHMQm8FjLvLIjXFUDVHGowgcciv4b2iDUt ebqaSG7hngBUo9ZylnKbUbOhXDxXbWGp7MstSOD1pT6OuiOIKC1jksZqWxA8TQ5g8uHL me6XIFYOdnEV4YWSrezuxNLWIuw+qYKC3QZKeacW51XC5DegnFcj3s9CCP+Ux8UaiQkr HPY7D15zfXjroM/PxiB64uZR8hDgjNAU/WDCUr65f9aVzQDHtLY6EXoD0DBca64I6prC 6nGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Q5REp5QC; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id md10-20020a17090b23ca00b00263e4949dbbsi1298794pjb.29.2023.08.03.22.25.31; Thu, 03 Aug 2023 22:25:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@kernel.org header.s=k20201202 header.b=Q5REp5QC; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232080AbjHDEmG (ORCPT + 99 others); Fri, 4 Aug 2023 00:42:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229631AbjHDEmD (ORCPT ); Fri, 4 Aug 2023 00:42:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E89BF180; Thu, 3 Aug 2023 21:41:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7B7D461F29; Fri, 4 Aug 2023 04:41:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A2CAC433C7; Fri, 4 Aug 2023 04:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691124118; bh=483xcLasT3cOTrxUXGXtibomqh1U7dTQNKUfCSr0aBI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Q5REp5QCvmmZ5NkRVkpLVzwl0MiA0bI+SR/XdKPOcj8jqYI9WZirVeVplh/2b8i1Q roMrmCG242fT9QQP/B2bahS2aNCanlpWUGftxZuIbblqajP7uYnt3CooErFske5t4g R+QR6PwE4Ep8t+ytmnWsxvrLeLG1icA6PKo9AjEUwZ7LH1oZ3oFAY/4nXil3iX4+vA L4LoulTP72IR06STRpxXRzAZLIvnHt4E6Bo1COwKnQtJCZ5EDh/GyiRXsvVHnXfgbH 5DVV3KdP4hb0TvqM8L/+Dl1U8wbW3hbkY0Df0x54CEFX47+EdJC3edb41g3+Up+alm 3viLGtON5P+0Q== Date: Thu, 3 Aug 2023 21:41:56 -0700 From: Eric Biggers To: Gabriel Krisman Bertazi Cc: viro@zeniv.linux.org.uk, brauner@kernel.org, tytso@mit.edu, jaegeuk@kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi Subject: Re: [PATCH v4 3/7] libfs: Validate negative dentries in case-insensitive directories Message-ID: <20230804044156.GB1954@sol.localdomain> References: <20230727172843.20542-1-krisman@suse.de> <20230727172843.20542-4-krisman@suse.de> <20230729042048.GB4171@sol.localdomain> <875y5w10ye.fsf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <875y5w10ye.fsf@suse.de> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org On Thu, Aug 03, 2023 at 01:37:45PM -0400, Gabriel Krisman Bertazi wrote: > Eric Biggers writes: > > > On Thu, Jul 27, 2023 at 01:28:39PM -0400, Gabriel Krisman Bertazi wrote: > >> - In __lookup_slow, either the parent inode is read locked by the > >> caller (lookup_slow), or it is called with no flags (lookup_one*). > >> The read lock suffices to prevent ->d_name modifications, with the > >> exception of one case: __d_unalias, will call __d_move to fix a > >> directory accessible from multiple dentries, which effectively swaps > >> ->d_name while holding only the shared read lock. This happens > >> through this flow: > >> > >> lookup_slow() //LOOKUP_CREATE > >> d_lookup() > >> ->d_lookup() > >> d_splice_alias() > >> __d_unalias() > >> __d_move() > >> > >> Nevertheless, this case is not a problem because negative dentries > >> are not allowed to be moved with __d_move. > > > > Isn't it possible for a negative dentry to become a positive one concurrently? > > Do you mean d_splice_alias racing with a dentry instantiation and > __d_move being called on a negative dentry that is turning positive? > > It is not possible for __d_move to be called with a negative dentry for > d_splice_alias, since the inode->i_lock is locked during __d_find_alias, > so it can't race with __d_instantiate or d_add. Then, __d_find_alias > can't find negative dentries in the first place, so we either have a > positive dentry, in which case __d_move is fine with regard to > d_revalidate_name, or we don't have any aliases and don't call > __d_move. > > Can you clarify what problem you see here? > I agree that negative dentries can't be moved --- I pointed this out earlier (https://lore.kernel.org/linux-fsdevel/20230720060657.GB2607@sol.localdomain). The question is whether if ->d_revalidate sees a negative dentry, when can it assume that it remains a negative dentry for the remainder of ->d_revalidate. I'm not sure there is a problem, I just don't understand your explanation. - Eric