[PATCH v4 05/10] libfs: Check for casefold dirs on simple_lookup()

André Almeida posted 10 patches 2 months, 2 weeks ago
There is a newer version of this series
[PATCH v4 05/10] libfs: Check for casefold dirs on simple_lookup()
Posted by André Almeida 2 months, 2 weeks ago
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@igalia.com>
---
 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