mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sarthak Kukreti <sarthakkukreti@google.com>
To: "Theodore Ts'o" <tytso@mit.edu>, Jaegeuk Kim <jaegeuk@kernel.org>,
	Chao Yu <chao@kernel.org>,  Al Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>
Cc: Gabriel Krisman Bertazi <krisman@suse.de>,
	Eric Biggers <ebiggers@kernel.org>,
	 Dmitry Torokhov <dtor@google.com>,
	linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
	 linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org,
	 Sarthak Kukreti <sarthakkukreti@google.com>
Subject: [PATCH v2 0/3] fs: reject casefolded names that fold to ".", "..", or empty
Date: Thu, 19 Nov 2026 13:49:41 -0800	[thread overview]
Message-ID: <20261119214944.1480596-1-sarthakkukreti@google.com> (raw)

Unicode normalization in fs/unicode strips Default_Ignorable_Code_Point
characters 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). On ext4, the first such file is created on disk and
   subsequent ignorable-only names collide with it (-EEXIST); on f2fs,
   f2fs_init_casefolded_name() treats len == 0 as a fallback to raw
   bytewise hashing/matching, writing multiple ignorable-only files to
   disk that fsck.f2fs flags with hash mismatches.

This series rejects casefolding and case-insensitive matching of names
that fold to "", ".", or ".." across libfs (generic_ci_d_hash,
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.

Changes in v2:
- Drop redundant generic_ci_d_compare() changes from patch 1.
- Add Fixes: tags for initial ext4 and f2fs casefolding support to patch 1.
- Clarify ext4 vs f2fs behavior for ignorable-only filenames.

Link: https://lore.kernel.org/r/20261113065332.929085-1-sarthakkukreti@google.com # v1

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 | 14 ++++++++++++++
 fs/ext4/hash.c      |  2 +-
 fs/ext4/namei.c     |  9 +++++++--
 fs/f2fs/dir.c       |  6 +++++-
 fs/libfs.c          | 32 +++++++++++++++++++++++++++++---
 include/linux/fs.h  | 31 ++++++++++++++++++-------------
 6 files changed, 74 insertions(+), 20 deletions(-)

-- 
2.56.1.703.gf848ed807c-goog


             reply	other threads:[~2026-11-19 21:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 21:49 Sarthak Kukreti [this message]
2026-11-19 21:49 ` [PATCH v2 1/3] libfs: " Sarthak Kukreti
2026-11-19 21:49 ` [PATCH v2 2/3] ext4: " Sarthak Kukreti
2026-11-19 21:49 ` [PATCH v2 3/3] f2fs: " Sarthak Kukreti

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=20261119214944.1480596-1-sarthakkukreti@google.com \
    --to=sarthakkukreti@google.com \
    --cc=brauner@kernel.org \
    --cc=chao@kernel.org \
    --cc=dtor@google.com \
    --cc=ebiggers@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=krisman@suse.de \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®