Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Daniel Rosenberg <drosen@google.com>
Cc: Theodore Ts'o <tytso@mit.edu>,
linux-ext4@vger.kernel.org, Jaegeuk Kim <jaegeuk@kernel.org>,
Chao Yu <chao@kernel.org>,
linux-f2fs-devel@lists.sourceforge.net,
linux-fscrypt@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Andreas Dilger <adilger.kernel@dilger.ca>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Gabriel Krisman Bertazi <krisman@collabora.com>,
kernel-team@android.com
Subject: Re: [PATCH v10 2/4] fs: Add standard casefolding support
Date: Tue, 7 Jul 2020 18:27:25 -0700 [thread overview]
Message-ID: <20200708012725.GE839@sol.localdomain> (raw)
In-Reply-To: <20200707113123.3429337-3-drosen@google.com>
On Tue, Jul 07, 2020 at 04:31:21AM -0700, Daniel Rosenberg wrote:
> +/*
> + * Determine if the name of a dentry should be casefolded. It does not make
> + * sense to casefold the no-key token of an encrypted filename.
> + *
> + * Return: if names will need casefolding
> + */
> +static bool needs_casefold(const struct inode *dir, const struct dentry *dentry)
> +{
> + return IS_CASEFOLDED(dir) && dir->i_sb->s_encoding &&
> + !(dentry->d_flags & DCACHE_ENCRYPTED_NAME);
> +}
> +
[...]
> +/**
> + * generic_ci_d_hash - generic d_hash implementation for casefolding filesystems
> + * @dentry: dentry whose name we are hashing
> + * @str: qstr of name whose hash we should fill in
> + *
> + * Return: 0 if hash was successful, or -ERRNO
> + */
> +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str)
> +{
> + const struct inode *inode = READ_ONCE(dentry->d_inode);
> + struct super_block *sb = dentry->d_sb;
> + const struct unicode_map *um = sb->s_encoding;
> + int ret = 0;
> +
> + if (!inode || !needs_casefold(inode, dentry))
> + return 0;
> +
> + ret = utf8_casefold_hash(um, dentry, str);
> + if (ret < 0)
> + goto err;
> +
> + return 0;
> +err:
> + if (sb_has_strict_encoding(sb))
> + ret = -EINVAL;
> + else
> + ret = 0;
> + return ret;
> +}
> +EXPORT_SYMBOL(generic_ci_d_hash);
I thought this was discussed before, but the 'dentry' passed to ->d_hash() is
the parent dentry, not the one being hashed.
Therefore checking DCACHE_ENCRYPTED_NAME on 'dentry' is wrong here. Instead we
need to use !fscrypt_has_encryption_key() here. (IOW, while checking
DCACHE_ENCRYPTED_NAME is better *when possible*, it's not possible here.)
Note that the whole point of ->d_hash() is to hash the filename so that the VFS
can find the dentry. If the VFS already had the dentry, there would be no need
for ->d_hash().
Also, did you consider my suggestion to not handle encrypt+casefold in this
patch? I'd like to get this series in as a refactoring for 5.9. The encryption
handling (which is new) might better belong in a later patch series.
- Eric
next prev parent reply other threads:[~2020-07-08 1:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-07 11:31 [PATCH v10 0/4] Prepare for upcoming Casefolding/Encryption patches Daniel Rosenberg
2020-07-07 11:31 ` [PATCH v10 1/4] unicode: Add utf8_casefold_hash Daniel Rosenberg
2020-07-07 17:50 ` Gabriel Krisman Bertazi
2020-07-08 1:36 ` Eric Biggers
2020-07-07 11:31 ` [PATCH v10 2/4] fs: Add standard casefolding support Daniel Rosenberg
2020-07-08 1:27 ` Eric Biggers [this message]
2020-07-07 11:31 ` [PATCH v10 3/4] f2fs: Use generic " Daniel Rosenberg
2020-07-08 1:41 ` Eric Biggers
2020-07-07 11:31 ` [PATCH v10 4/4] ext4: " Daniel Rosenberg
2020-07-08 1:44 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200708012725.GE839@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=adilger.kernel@dilger.ca \
--cc=chao@kernel.org \
--cc=drosen@google.com \
--cc=jaegeuk@kernel.org \
--cc=kernel-team@android.com \
--cc=krisman@collabora.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
--subject='Re: [PATCH v10 2/4] fs: Add standard casefolding support' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).