Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1403515rwb; Fri, 28 Jul 2023 08:58:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFj2pWK8z9C/1WTqfFxYFdUl2Xb4B26C1+ic2egpAp3ZQ+HATtI02LqY1mWcjdkJFyJQ+N3 X-Received: by 2002:a17:902:d491:b0:1b8:5ab2:49a4 with SMTP id c17-20020a170902d49100b001b85ab249a4mr2046675plg.53.1690559881862; Fri, 28 Jul 2023 08:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690559881; cv=none; d=google.com; s=arc-20160816; b=keBVyrtBPykC8gsmaBWd+y7tGsOr9FUBMrkf7YPzsIlsCABRhC2VHDkxoHRyKzgJQm 1hbKY1nb8u/tn6PYG3qnnG0WnGif+AxaqUxOIqB4useHsbTmtCGzDLTJPQOFVGbuxscZ MVPy8OU0Hil97p5aOQ7hU3N/qoC7u8YAVl5V/39PxfqTtICbd6BWCFKu7+091PIrBsXZ JMJXn/iQhOwdzQiHWeUMa6N00aWt75yqgIkLweR6isfbu7gg6M8QfvBMbdkncVOXrgmZ LmVG5bjqz116vcvwhrULXGPwg98WJVXHrT8BUPKqznAWcc6NI2h4Q+h0r9mtXO6F8RJ6 Qdhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:organization :subject:cc:to:from:dkim-signature:dkim-signature; bh=WraNl6n1+7jI6xXHbPsuy6St/2gdjjWwknimz9pA0c4=; fh=NIwNXwX6brzxlQapCcJ1Hi9JlyjIGJYd1MeT8UEMi34=; b=TCNoLS2y0FsrEozfVWMBs/qz3kdyKyP0+t1cysjvpqKNtqGPF48o09vTbjpmCF7Spy RY2x6Mv0yenK6m0N2VrxCtVPddXqvSwMsUMk3XsiPQKVVx5hLEUWB6YFOgkGMdRmFnLa gIqnk//cCc5mA4HrTdnxa7WX7tmAYLX8Dfu5X7GWS7GsoQoLdzWxZUS6d94mtEDGTxeq HlpFqi3QXP+FBTpzzFB+3qHFYgTq08o8TCMRofsciLIgiKe18eLJeu0vQnqR1orVJI2q OOqqMOqYZuuTzrWkMkp5nF3+bn1trWIb6lAMiV+T7h+abRIa8LQWoqOsHhxe8QR2n+ws cz+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=NOjZQExp; dkim=neutral (no key) header.i=@suse.de; 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 a1-20020a170902ecc100b001b874c5f7a8si3167658plh.653.2023.07.28.08.57.45; Fri, 28 Jul 2023 08:58:01 -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=NOjZQExp; dkim=neutral (no key) header.i=@suse.de; 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 S234709AbjG1PtF (ORCPT + 99 others); Fri, 28 Jul 2023 11:49:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234149AbjG1PtE (ORCPT ); Fri, 28 Jul 2023 11:49:04 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADB9CE0; Fri, 28 Jul 2023 08:49:03 -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-out2.suse.de (Postfix) with ESMTPS id 5EB981F8A3; Fri, 28 Jul 2023 15:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1690559342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WraNl6n1+7jI6xXHbPsuy6St/2gdjjWwknimz9pA0c4=; b=NOjZQExpGN1h+BnjL4x/+zDY7xA/osu0t+Eb/ODtkzqlxS/WNF212zks42/FQL97++dGXy X7VSMRJQi5ZEJVgf2DrPMSWQ7HHP8DedqN0WL8SzC0yqB+VnwCC/VxcOlLNjKVKBlJye81 5gMZeYJknfsnejRgrb25EMm/2XSeBWE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1690559342; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WraNl6n1+7jI6xXHbPsuy6St/2gdjjWwknimz9pA0c4=; b=OytHCysNU0rLyHfQ/8nppZIFxwhUdNsbC4LiV4pWZDlBg0cs96Gh0PM+XI5/WsTYo82F7m 2oZWSNEh6AiRh8Aw== 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 28FA9133F7; Fri, 28 Jul 2023 15:49:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MeSBBG7jw2SRTQAAMHmgww (envelope-from ); Fri, 28 Jul 2023 15:49:02 +0000 From: Gabriel Krisman Bertazi To: Christian Brauner Cc: viro@zeniv.linux.org.uk, tytso@mit.edu, ebiggers@kernel.org, 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 1/7] fs: Expose name under lookup to d_revalidate hook Organization: SUSE References: <20230727172843.20542-1-krisman@suse.de> <20230727172843.20542-2-krisman@suse.de> <20230728-unrentabel-volumen-1500701f2524@brauner> Date: Fri, 28 Jul 2023 11:49:00 -0400 In-Reply-To: <20230728-unrentabel-volumen-1500701f2524@brauner> (Christian Brauner's message of "Fri, 28 Jul 2023 16:00:10 +0200") Message-ID: <87mszg11g3.fsf@suse.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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 Christian Brauner writes: >> -static inline int d_revalidate(struct dentry *dentry, unsigned int flag= s) >> +static inline int d_revalidate(struct dentry *dentry, >> + const struct qstr *name, >> + unsigned int flags) >> { >> - if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) >> + >> + if (unlikely(dentry->d_flags & DCACHE_OP_REVALIDATE)) { >> + if (dentry->d_op->d_revalidate_name) >> + return dentry->d_op->d_revalidate_name(dentry, name, flags); >> return dentry->d_op->d_revalidate(dentry, flags); > > This whole sequence got me thinking. > ... > ubuntu@imp1-vm:~$ sudo mount -t ecryptfs /mnt/test/casefold-dir /opt > ubuntu@imp1-vm:/opt$ findmnt | grep opt > =E2=94=94=E2=94=80/opt /mnt/test/casefold-dir ecryptfs rw,relatime,ecryp= tfs_sig=3D8567ee2ae5880f2d,ecryptfs_cipher=3Daes,ecryptfs_key_bytes=3D16,ec= ryptfs_unlink_sigs That's interesting. I was aware of overlayfs and wanted to eventually get it to work together with casefold, but never considered an ecryptfs com= bo. > So it doesn't even seem to care if the underlying filesytem uses a > custom dentry hash function which seems problematic (So unrelated to > this change someone should likely explain why that doesn't matter.). > > Afaict with your series this will be even more broken because ecryptfs > and overlayfs call ->d_revalidate() directly. > > So this suggests that really you want to extend ->d_revalidate() and we > should at least similar to overlayfs make ecryptfs reject being mounted > on casefolding directories and refuse lookup requests for casefolding > directories. > > Ideally we'd explicitly reject by having such fses detect casefolding > unless it's really enough to reject based on DCACHE_OP_HASH. Thanks for finding this issue. I'll follow up with merging d_revalidate and d_revalidate_name and adding a patch to explicitly reject combinations of ecryptfs/overlayfs with casefolding filesystems, and safeguard the lookup. --=20 Gabriel Krisman Bertazi