[PATCH 0/3] fs: reject casefolded names that fold to ".", "..", or empty

From: Sarthak Kukreti

Date: Fri Nov 13 2026 - 03:09:44 EST


Unicode normalization in fs/unicode strips Default_Ignorable_Code_Point
characters (such as U+202E RIGHT-TO-LEFT OVERRIDE and U+200B ZERO WIDTH
SPACE) in both UTF8_NFDI and UTF8_NFDICF. In casefolded directories,
filenames consisting of 0 to 2 ASCII dots plus ignorable code points
(e.g. "\u202e", ".\u202e", "..\u202e") pass VFS path walk as normal
multi-byte components, but fold to "", ".", or ".." in utf8_casefold():

1. Looking up ".\u202e" folds to "." and matches the on-disk "." entry
(de->inode == dir->i_ino) in generic_ci_match(), triggering
EXT4_ERROR_INODE ("linked to parent dir") in ext4_lookup().
2. Looking up "..\u202e" folds to ".." and matches the on-disk ".."
entry, returning -ELOOP via d_splice_alias() (or triggering
EXT4_ERROR_INODE on the root directory).
3. Filenames consisting solely of ignorable characters fold to "" (0
bytes), causing distinct ignorable-only filenames to hash and compare
equal and creating entries that e2fsck flags as corruption.

This series rejects casefolding and case-insensitive matching of names
that fold to "", ".", or ".." across libfs (d_hash, d_compare,
generic_ci_match, and generic_ci_validate_strict_name), ext4
(ext4_fname_setup_ci_filename and ext4fs_dirhash), and f2fs
(f2fs_init_casefolded_name), while preserving exact byte-equality
matching for genuine "." and ".." lookups (such as NFS ext4_get_parent)
and opaque byte fallback for invalid UTF-8 sequences in non-strict mode.

Dmitry Torokhov (1):
f2fs: reject casefolded names that fold to ".", "..", or empty

Sarthak Kukreti (2):
libfs: reject casefolded names that fold to ".", "..", or empty
ext4: reject casefolded names that fold to ".", "..", or empty

fs/ext4/hash-test.c | 12 ++++++++++++
fs/ext4/hash.c | 2 +-
fs/ext4/namei.c | 11 +++++++++--
fs/f2fs/dir.c | 6 +++++-
fs/libfs.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
include/linux/fs.h | 29 +++++++++++++----------------
6 files changed, 91 insertions(+), 21 deletions(-)

--
2.56.0.611.g1030f0b940-goog