]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ext4: avoid remove directory when directory is corrupted
authorYe Bin <yebin10@huawei.com>
Wed, 22 Jun 2022 09:02:23 +0000 (17:02 +0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 3 Aug 2022 03:56:17 +0000 (23:56 -0400)
Now if check directoy entry is corrupted, ext4_empty_dir may return true
then directory will be removed when file system mounted with "errors=continue".
In order not to make things worse just return false when directory is corrupted.

Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20220622090223.682234-1-yebin10@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
fs/ext4/namei.c

index db4ba99d1cebeb72a6e45622cfc8f2e024f53a2b..1c6725ecca1ad1dbdb68e7494c827ec9d156296e 100644 (file)
@@ -3067,11 +3067,8 @@ bool ext4_empty_dir(struct inode *inode)
                de = (struct ext4_dir_entry_2 *) (bh->b_data +
                                        (offset & (sb->s_blocksize - 1)));
                if (ext4_check_dir_entry(inode, NULL, de, bh,
-                                        bh->b_data, bh->b_size, offset)) {
-                       offset = (offset | (sb->s_blocksize - 1)) + 1;
-                       continue;
-               }
-               if (le32_to_cpu(de->inode)) {
+                                        bh->b_data, bh->b_size, offset) ||
+                   le32_to_cpu(de->inode)) {
                        brelse(bh);
                        return false;
                }