From: Sarthak Kukreti <sarthakkukreti@google.com>
To: "Theodore Ts'o" <tytso@mit.edu>, Jaegeuk Kim <jaegeuk@kernel.org>,
Chao Yu <chao@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>
Cc: Gabriel Krisman Bertazi <krisman@collabora.co.uk>,
Eric Biggers <ebiggers@google.com>,
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 3/3] f2fs: reject casefolded names that fold to ".", "..", or empty
Date: Thu, 12 Nov 2026 22:53:32 -0800 [thread overview]
Message-ID: <20261113065332.929085-4-sarthakkukreti@google.com> (raw)
In-Reply-To: <20261113065332.929085-1-sarthakkukreti@google.com>
From: Dmitry Torokhov <dtor@google.com>
Filenames consisting only of ignorable Unicode characters fold to empty
strings, and names with leading dots and ignorable characters can fold
to "." or "..". Allowing such names in casefolded directories can corrupt
directory structure or cause confusion with special entries.
Reject any non-dot names that fold to empty, ".", or ".." during
casefolded name setup, while still allowing invalid UTF-8 sequences to
be handled as opaque byte sequences when strict mode is not enabled.
Fixes: 2c2eb7a300cd ("f2fs: Support case-insensitive file name lookups")
Signed-off-by: Dmitry Torokhov <dtor@google.com>
Signed-off-by: Sarthak Kukreti <sarthakkukreti@google.com>
---
fs/f2fs/dir.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index fd0e2cd31a81..a20723edb724 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -77,13 +77,17 @@ int f2fs_init_casefolded_name(const struct inode *dir,
len = utf8_casefold(sb->s_encoding, fname->usr_fname,
buf, F2FS_NAME_LEN);
- if (len <= 0) {
+ if (len < 0) {
kmem_cache_free(f2fs_cf_name_slab, buf);
if (sb_has_strict_encoding(sb))
return -EINVAL;
/* fall back to treating name as opaque byte sequence */
return 0;
}
+ if (len == 0 || name_is_dot_dotdot(buf, len)) {
+ kmem_cache_free(f2fs_cf_name_slab, buf);
+ return -EINVAL;
+ }
fname->cf_name.name = buf;
fname->cf_name.len = len;
}
--
2.56.0.611.g1030f0b940-goog
prev parent reply other threads:[~2026-11-13 6:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 6:53 [PATCH 0/3] fs: " Sarthak Kukreti
2026-11-13 6:53 ` [PATCH 1/3] libfs: " Sarthak Kukreti
2026-11-16 19:34 ` Gabriel Krisman Bertazi
2026-11-16 20:05 ` Eric Biggers
2026-11-13 6:53 ` [PATCH 2/3] ext4: " Sarthak Kukreti
2026-11-13 6:53 ` Sarthak Kukreti [this message]
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=20261113065332.929085-4-sarthakkukreti@google.com \
--to=sarthakkukreti@google.com \
--cc=brauner@kernel.org \
--cc=chao@kernel.org \
--cc=dtor@google.com \
--cc=ebiggers@google.com \
--cc=jaegeuk@kernel.org \
--cc=krisman@collabora.co.uk \
--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®