Re: [PATCH 1/3] libfs: reject casefolded names that fold to ".", "..", or empty

From: Al Viro

Date: Tue Nov 17 2026 - 12:59:31 EST


On Tue, Nov 17, 2026 at 09:54:32AM -0500, Theodore Tso wrote:
> On Tue, Nov 17, 2026 at 08:47:27AM -0500, David Laight wrote:
> > > Sigh... I really think these characters are *evil*. I wonder if we
> > > should simply drop those code points unconditionally when they are fed
> > > to the kernel --- not only folding to themselves, but *not* preserving
> > > them when a misguided application tries to create a file with one of
> > > these misbegotten Unicode charactesr.
> >
> > Doesn't that assume that filenames are UTF8 rather than just sequences
> > of bytes with everything except '\0' and '/' being valid.
> > Casefolding is itself so evil/impossible it shouldn't have been allowed.
>
> We would only do this if casefolding is enabled.

Which is to say, on any distro kernel. Besides, it's not just a matter of
filtering that dreck out on getname() and friends (syscall boundary won't
do at all due to the things like binfmt_misc opening files, etc.) - you'd
need to scan what you get upon ->get_link() as well.

> For better or for
> worse, it's better than what it replaced which was this terrible
> wrapfs hack that was a trivial to trigger deadlocks using fsstress ---
> which was even more evil.
>
> The other way we can deal with this is that if case folding is
> enabled, we change the VFS to call the case-folding for incoming
> filename *before* it does its special case checking for '.' and '..'
> if casefolding is enabled.

That would penalize every pathname resolution, whether that misfeature is
stepped into or not; hash_name() is fairly hot.

'.' and '..' should be recognized only as literal octet sequences 0x2e
and 0x2e 0x2e; if some misguided filesystem decides to treat something
else as equivalent to those, it bloody well ought to recognize and reject
that something else in its ->lookup() (or ->d_hash(), for that matter).