From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F742C2D0E2 for ; Thu, 24 Sep 2020 10:57:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38221239CF for ; Thu, 24 Sep 2020 10:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600945053; bh=ReNUjh2+4CXtsorEynITi+cDn6rHbuOX6gukuZuCGXI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:List-ID:From; b=KXyZY8GRpoEiHPo67wy1/KLZYJryyljCj3tmDYlSFBoSORHAlephpP+LHhwV3Aq97 70Oidhyf6WFf9m3V4fangp+rKF84/JpoBg5wf9kfiq3TILaeEaG6g8/IoBg6qfxRIq z2d8evxfpLy6DSc5O2v2R+UOe8dkceO/flVfesfI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726595AbgIXK53 (ORCPT ); Thu, 24 Sep 2020 06:57:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:36262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726483AbgIXK53 (ORCPT ); Thu, 24 Sep 2020 06:57:29 -0400 Received: from tleilax.poochiereds.net (68-20-15-154.lightspeed.rlghnc.sbcglobal.net [68.20.15.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D2A732395B; Thu, 24 Sep 2020 10:57:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600945048; bh=ReNUjh2+4CXtsorEynITi+cDn6rHbuOX6gukuZuCGXI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=a6rOZfN2v4qDIA7c079QPI66GmKpOEsCWxnxKgw2RbhqSDA1HsVDqgYgAm0I+C+t4 QNnLU9xw1Pv7zs5P67nh9IA66wgWrf1jFeumaRWvMFjUhs1FoXqRyIJGQlEtvvI++4 iL1I7aGO4aWakAy/iDW73AvJWyQbHpKWwTAjGvF8= Message-ID: Subject: Re: [PATCH] fscrypt: export fscrypt_d_revalidate() From: Jeff Layton To: Eric Biggers , linux-fscrypt@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, ceph-devel@vger.kernel.org, Daniel Rosenberg Date: Thu, 24 Sep 2020 06:57:26 -0400 In-Reply-To: <20200924054721.187797-1-ebiggers@kernel.org> References: <20200924054721.187797-1-ebiggers@kernel.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org On Wed, 2020-09-23 at 22:47 -0700, Eric Biggers wrote: > From: Eric Biggers > > Dentries that represent no-key names must have a dentry_operations that > includes fscrypt_d_revalidate(). Currently, this is handled by > fscrypt_prepare_lookup() installing fscrypt_d_ops. > > However, ceph support for encryption > (https://lore.kernel.org/r/20200914191707.380444-1-jlayton@kernel.org) > can't use fscrypt_d_ops, since ceph already has its own > dentry_operations. > > Similarly, ext4 and f2fs support for directories that are both encrypted > and casefolded > (https://lore.kernel.org/r/20200923010151.69506-1-drosen@google.com) > can't use fscrypt_d_ops either, since casefolding requires some dentry > operations too. > > To satisfy both users, we need to move the responsibility of installing > the dentry_operations to filesystems. > > In preparation for this, export fscrypt_d_revalidate() and give it a > !CONFIG_FS_ENCRYPTION stub. > > Signed-off-by: Eric Biggers > --- > > Compared to the versions of this patch from Jeff and Daniel, I've > improved the commit message and added a !CONFIG_FS_ENCRYPTION stub, > which was missing. I'm planning to apply this for 5.10 in preparation > for both the ceph patchset and the encrypt+casefold patchset. > > > fs/crypto/fname.c | 3 ++- > include/linux/fscrypt.h | 7 +++++++ > 2 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c > index c65979452844..1fbe6c24d705 100644 > --- a/fs/crypto/fname.c > +++ b/fs/crypto/fname.c > @@ -530,7 +530,7 @@ EXPORT_SYMBOL_GPL(fscrypt_fname_siphash); > * Validate dentries in encrypted directories to make sure we aren't potentially > * caching stale dentries after a key has been added. > */ > -static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) > +int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) > { > struct dentry *dir; > int err; > @@ -569,6 +569,7 @@ static int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags) > > return valid; > } > +EXPORT_SYMBOL_GPL(fscrypt_d_revalidate); > > const struct dentry_operations fscrypt_d_ops = { > .d_revalidate = fscrypt_d_revalidate, > diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h > index f1757e73162d..a8f7a43f031b 100644 > --- a/include/linux/fscrypt.h > +++ b/include/linux/fscrypt.h > @@ -197,6 +197,7 @@ int fscrypt_fname_disk_to_usr(const struct inode *inode, > bool fscrypt_match_name(const struct fscrypt_name *fname, > const u8 *de_name, u32 de_name_len); > u64 fscrypt_fname_siphash(const struct inode *dir, const struct qstr *name); > +int fscrypt_d_revalidate(struct dentry *dentry, unsigned int flags); > > /* bio.c */ > void fscrypt_decrypt_bio(struct bio *bio); > @@ -454,6 +455,12 @@ static inline u64 fscrypt_fname_siphash(const struct inode *dir, > return 0; > } > > +static inline int fscrypt_d_revalidate(struct dentry *dentry, > + unsigned int flags) > +{ > + return 1; > +} > + > /* bio.c */ > static inline void fscrypt_decrypt_bio(struct bio *bio) > { Reviewed-by: Jeff Layton