Re: [f2fs-dev] [PATCH v15 6/9] ext4: Log error when lookup of encoded dentry fails

Eric Biggers
2024-04-03T04:22:34Z

On Tue, Apr 02, 2024 at 06:48:39PM +0300, Eugen Hristev via Linux-f2fs-devel wrote:
> From: Gabriel Krisman Bertazi <krisman@collabora.com>
>
> If the volume is in strict mode, ext4_ci_compare can report a broken
> encoding name. This will not trigger on a bad lookup, which is caught
> earlier, only if the actual disk name is bad.
>
> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
> Signed-off-by: Eugen Hristev <eugen.hristev@collabora.com>
> ---
> fs/ext4/namei.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 2d0ee232fbe7..3268cf45d9db 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -1477,6 +1477,9 @@ static bool ext4_match(struct inode *parent,
> * only case where it happens is on a disk
> * corruption or ENOMEM.
> */
> + if (ret == -EINVAL)
> + EXT4_ERROR_INODE(parent,
> + "Directory contains filename that is invalid UTF-8");
> return false;

I'm seeing this error when the volume is *not* in strict mode and a file has a
name that is not valid UTF-8. That doesn't seem to be working as intended.

mkfs.ext4 -F -O casefold /dev/vdb
mount /dev/vdb /mnt
mkdir /mnt/dir
chattr +F /mnt/dir
touch /mnt/dir/$'\xff'

[ 1528.691319] EXT4-fs (vdb): Using encoding defined by superblock: utf8-12.1.0 with flags 0x0
[ 1528.707793] EXT4-fs (vdb): mounted filesystem 0be607cc-0dae-4e7f-a40f-4fe8075e8e50 r/w with ordered data mode. Quota mode: none.
[ 1528.728583] EXT4-fs error (device vdb): ext4_match:1481: inode #13: comm touch: Directory contains filename that is invalid UTF-8
[ 1528.730700] EXT4-fs error (device vdb): ext4_match:1481: inode #13: comm touch: Directory contains filename that is invalid UTF-8
[ 1528.732976] EXT4-fs error (device vdb): ext4_match:1481: inode #13: comm touch: Directory contains filename that is invalid UTF-8
[ 1528.735536] EXT4-fs error (device vdb): ext4_match:1481: inode #13: comm touch: Directory contains filename that is invalid UTF-8