[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210328144356.12866-4-andrealmeid@collabora.com>
Date: Sun, 28 Mar 2021 11:43:56 -0300
From: André Almeida <andrealmeid@...labora.com>
To: Alexander Viro <viro@...iv.linux.org.uk>,
Theodore Ts'o <tytso@....edu>,
Andreas Dilger <adilger.kernel@...ger.ca>,
Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>
Cc: krisman@...labora.com, kernel@...labora.com,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-ext4@...r.kernel.org, linux-f2fs-devel@...ts.sourceforge.net,
Daniel Rosenberg <drosen@...gle.com>,
Chao Yu <yuchao0@...wei.com>,
André Almeida <andrealmeid@...labora.com>
Subject: [PATCH 3/3] f2fs: Prevent dangling dentries on casefold directories
Before making a folder a case-insensitive one, this folder could have
been used before and created some negative dentries (given that the
folder needs to be empty before making it case-insensitive, all detries
there are negative ones). During a new file creation, if a d_hash()
collision happens and the name matches a negative dentry, the new file
might have a name different than the specified by user.
To prevent this from happening, remove all negative dentries in a
directory before making it a case-folded one.
Fixes: 2c2eb7a300cd ("f2fs: Support case-insensitive file name lookups")
Signed-off-by: André Almeida <andrealmeid@...labora.com>
---
fs/f2fs/file.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index d26ff2ae3f5e..616b7eb43795 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1826,6 +1826,10 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask)
return -EOPNOTSUPP;
if (!f2fs_empty_dir(inode))
return -ENOTEMPTY;
+
+ if (!(masked_flags & F2FS_CASEFOLD_FL) &&
+ (iflags & F2FS_CASEFOLD_FL))
+ d_clear_dir_neg_dentries(inode);
}
if (iflags & (F2FS_COMPR_FL | F2FS_NOCOMP_FL)) {
--
2.31.0
Powered by blists - more mailing lists