From patchwork Wed Jun 1 20:44:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 1638146 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=ARysa8n0; dkim-atps=neutral Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4LD1T937Flz9sFk for ; Thu, 2 Jun 2022 06:48:45 +1000 (AEST) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4LD1T70JKPz4xCy for ; Thu, 2 Jun 2022 06:48:43 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4LD1T70Bm2z4xD8; Thu, 2 Jun 2022 06:48:43 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2620:137:e000::1:20; helo=out1.vger.email; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.a=rsa-sha256 header.s=mail header.b=ARysa8n0; dkim-atps=neutral Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4LD1T707TXz4xCy for ; Thu, 2 Jun 2022 06:48:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230214AbiFAUsl (ORCPT ); Wed, 1 Jun 2022 16:48:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230190AbiFAUrp (ORCPT ); Wed, 1 Jun 2022 16:47:45 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE2EB27D0C6; Wed, 1 Jun 2022 13:45:00 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 1D0291F438EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654116296; bh=BBhM4E24E3FzLZ2ImuINI815DcsgQV3gbQsLsPXZbL0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ARysa8n0T/spCEKppZpd7ncpab+aSeFM2iIGRnjodegjdm0pXm2ewpECE+U8l1kN2 fOq2mYSWr/sqCpxQrh2R0VIeBaWps7RE4rea2Qn6O48t3AZvtmaa1hjQ0l3LxFLvk6 59aX+JBnRK8RALv0X11lJQqIeTBjkWWRjgTczIb1D2jBn3New5scJBkLMtXgXF2rw+ g2tIFy4GbBKTRhg3ON16h9/2O3A7pB8BIfmSN24prOpKDKvm2HiZBY9em8FMO6RlLH 4By2c+o4wsvi19z2UIdyeKBY0wxexp+QgDBvyMfA3zvpeG0mxSj5AZqEU3iRK5mnuy XOzjMV1cKdjEg== From: Gabriel Krisman Bertazi To: viro@zeniv.linux.org.uk, tytso@mit.edu, jaegeuk@kernel.org Cc: ebiggers@kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH RFC 4/7] libfs: Support revalidation of encrypted case-insensitive dentries Date: Wed, 1 Jun 2022 16:44:34 -0400 Message-Id: <20220601204437.676872-5-krisman@collabora.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220601204437.676872-1-krisman@collabora.com> References: <20220601204437.676872-1-krisman@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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 Preserve the existing behavior for encrypted directories, by rejecting negative dentries of encrypted+casefolded directories. This allows generic_ci_d_revalidate to be used by filesystems with both features enabled, as long as the directory is either casefolded or encrypted, but not both at the same time. Signed-off-by: Gabriel Krisman Bertazi --- fs/libfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 618a85c08aa7..fe22738291e4 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1461,6 +1461,9 @@ static inline int generic_ci_d_revalidate(struct dentry *dentry, const struct inode *dir = READ_ONCE(parent->d_inode); if (dir && needs_casefold(dir)) { + if (IS_ENCRYPTED(dir)) + return 0; + if (!d_is_casefold_lookup(dentry)) return 0; @@ -1470,7 +1473,8 @@ static inline int generic_ci_d_revalidate(struct dentry *dentry, return 0; } } - return 1; + + return fscrypt_d_revalidate(dentry, flags); } static const struct dentry_operations generic_ci_dentry_ops = { @@ -1490,7 +1494,7 @@ static const struct dentry_operations generic_encrypted_dentry_ops = { static const struct dentry_operations generic_encrypted_ci_dentry_ops = { .d_hash = generic_ci_d_hash, .d_compare = generic_ci_d_compare, - .d_revalidate = fscrypt_d_revalidate, + .d_revalidate_name = generic_ci_d_revalidate, }; #endif