lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200708012725.GE839@sol.localdomain>
Date:   Tue, 7 Jul 2020 18:27:25 -0700
From:   Eric Biggers <ebiggers@...nel.org>
To:     Daniel Rosenberg <drosen@...gle.com>
Cc:     Theodore Ts'o <tytso@....edu>, linux-ext4@...r.kernel.org,
        Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>,
        linux-f2fs-devel@...ts.sourceforge.net,
        linux-fscrypt@...r.kernel.org,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Andreas Dilger <adilger.kernel@...ger.ca>,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        Gabriel Krisman Bertazi <krisman@...labora.com>,
        kernel-team@...roid.com
Subject: Re: [PATCH v10 2/4] fs: Add standard casefolding support

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ