Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7092660rwp; Tue, 18 Jul 2023 09:55:54 -0700 (PDT) X-Google-Smtp-Source: APBJJlFDe+EU/22Dt1mkG3tynqnIUYvH0/Wnq7DQcRxDs6kl1c1Z64eAUjfK8p6jLd/2VbFtocP8 X-Received: by 2002:a17:907:7815:b0:966:17b2:5b0b with SMTP id la21-20020a170907781500b0096617b25b0bmr351391ejc.49.1689699354633; Tue, 18 Jul 2023 09:55:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689699354; cv=none; d=google.com; s=arc-20160816; b=IGxBFymActo3lNh1U0YSRkcYFY2nwfqSG782uk8hKQ3a5o8hVgIDp2qZtfMY+OOgNM kYcxDcwhca/HCPCeYuFmZir99Qa6FQ1lzfIwBcjzIzRaxqbbV/rjTHwRYbyVVz3gth4X FFUuA0D833uKtfsR533MDzhxTv+u3xGurG7IENk3XGExrAIIbxcqCiFqnTix4Zykkbvm YHFTRI+tLaUaK0HxYLoIbtdMMS7mEoeZ43cQMv0sF+KA8Me6yIfWdHyx5t+R3EizUNyC EhkNGcuEshen/KfwarqfRWPRIjz4OQEhcpZI+9zJWo3xapfXdTGfoqpAoq3xE30unh1P eUyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature:dkim-signature; bh=0gG/SrZGF5/s3yIgwzjFlba62tVC4bEASQFHFHTinDw=; fh=2NjOw3P6YBqQSy8wPAr/CiSUD+Z+VH5vDPDLj5eE6S4=; b=PhYB5p+bUSJLh9GqzRlGRx+g6mEbWxeazzFNITvoPg52qo1fgy0hzVCQz6QiK4C5bC nHEoqABYyRp1iAwOY4aGrLXUck0th35fLlBU35QHDi8uGBqz+/tJSUe2yf0E5344nAjv 12JcgKtY2L1t4MNolc+zETKtzg8lFDrTNKMaASgFDuvjW24X2RPfF5Pm4CHkISRH+E96 t+QO995SiiEal3CYxvqMu1z19SRpBpEF8M3bt1WC0h+0L6+SWmv/ntA+AhvnFDbKixLH oucO0e6z9dFS87uRodypL5tx09Nsce36rc+1nl05PzVx6hibqhaKhqEXl5ajB/vvwUBL Wpxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=sCqIZIae; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ka10-20020a170907990a00b0099342fc2a87si1392599ejc.692.2023.07.18.09.55.26; Tue, 18 Jul 2023 09:55:54 -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=@suse.de header.s=susede2_rsa header.b=sCqIZIae; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231614AbjGRQrc (ORCPT + 99 others); Tue, 18 Jul 2023 12:47:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230428AbjGRQr3 (ORCPT ); Tue, 18 Jul 2023 12:47:29 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58BC710D2; Tue, 18 Jul 2023 09:47:28 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 02C3D21835; Tue, 18 Jul 2023 16:47:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689698847; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0gG/SrZGF5/s3yIgwzjFlba62tVC4bEASQFHFHTinDw=; b=sCqIZIaeY+lZmLjsOPsAbQI7GvoRp+QnzyxAweo04VRhB02G7zlyPODdtnMibPbRArJBXD EmKHbQr2G1Hg/mlor+k1OhYUl6g3r4QossnKRSkX+YcTTQxPScxqx/r35yGnTw3fNEyVf5 ghYS+pV/sSq88EFejZe58ccHS7UeR7E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689698847; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0gG/SrZGF5/s3yIgwzjFlba62tVC4bEASQFHFHTinDw=; b=5Agcg3CzsovgtmLs9P2htHWvOOKunhSV4WopA6/9BhjEF+Ts1aNnzWoRaa1U1bHqG+xwJc Fil0WRvm5Z4c3BAA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C0405134B0; Tue, 18 Jul 2023 16:47:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id llAuKR7CtmTiUwAAMHmgww (envelope-from ); Tue, 18 Jul 2023 16:47:26 +0000 From: Gabriel Krisman Bertazi To: Eric Biggers Cc: brauner@kernel.org, tytso@mit.edu, linux-f2fs-devel@lists.sourceforge.net, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, jaegeuk@kernel.org, linux-ext4@vger.kernel.org Subject: Re: [f2fs-dev] [PATCH v2 3/7] libfs: Validate negative dentries in case-insensitive directories References: <20230422000310.1802-1-krisman@suse.de> <20230422000310.1802-4-krisman@suse.de> <20230714050028.GC913@sol.localdomain> Date: Tue, 18 Jul 2023 12:47:25 -0400 In-Reply-To: <20230714050028.GC913@sol.localdomain> (Eric Biggers's message of "Thu, 13 Jul 2023 22:00:28 -0700") Message-ID: <87pm4p5fqa.fsf@suse.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Eric Biggers writes: > I notice that the existing vfat_revalidate_ci() in fs/fat/namei_vfat.c behaves > differently in the 'flags == 0' case: > > > /* > * This may be nfsd (or something), anyway, we can't see the > * intent of this. So, since this can be for creation, drop it. > */ > if (!flags) > return 0; > > I don't know whether that's really needed, but have you thought about this? Hi Eric, I didn't look much into it before because, as you know, the vfat case-insensitive implementation is completely different than the ext4/f2fs code. But I think you are on to something. The original intent of this check was to safeguard against the case where d_revalidate would be called without nameidata from the filesystem helpers. The filesystems don't give the purpose of the lookup (nd->flags) so there is no way to tell if the dentry is being used for creation, and therefore we can't rely on the negative dentry for ci. The path is like this: lookup_one_len(...) __lookup_hash(..., nd = NULL) cached_lookup(...) do_revalidate(parent, name, nd) dentry->d_op->d_revalidate(parent, nd); Then !nd was dropped to pass flags directly around 2012, which overloaded the flags meaning. Which means, d_revalidate can still be called for creation without (LOOKUP_CREATE|...). For instance, in nfsd_create. I wasn't considering this. This sucks, because we don't have enough information to avoid the name check in this case, so we'd also need memcmp there. Except it won't be safe. because callers won't necessarily hold the parent lock in the path below. lookup_one_unlocked() lookup_dcache() d_revalidate() // called unlocked Thus, I'll have to add a similar: if (!flags) return 0; Ahead of the is_creation check. It will solve it. But i think the issue is in VFS. the lookup_one_* functions should have proper lookup flags, such that d_revalidate can tell the purpose of the lookup. -- Gabriel Krisman Bertazi