[PATCH v4 05/10] libfs: Check for casefold dirs on simple_lookup()
From: André Almeida
Date: Wed Sep 11 2024 - 11:00:40 EST
On simple_lookup(), do not create dentries for casefold directories.
Currently, VFS does not support case-insensitive negative dentries and
can create inconsistencies in the filesystem. Prevent such dentries to
being created in the first place.
Signed-off-by: André Almeida <andrealmeid@xxxxxxxxxx>
---
fs/libfs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/libfs.c b/fs/libfs.c
index 99fb36b48708..838524314b1b 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -77,6 +77,10 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned
return ERR_PTR(-ENAMETOOLONG);
if (!dentry->d_sb->s_d_op)
d_set_d_op(dentry, &simple_dentry_operations);
+
+ if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir))
+ return NULL;
+
d_add(dentry, NULL);
return NULL;
}
--
2.46.0