diff options
author | Ye Bin <yebin10@huawei.com> | 2022-06-22 17:02:23 +0800 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2022-08-02 23:56:17 -0400 |
commit | b24e77ef1c6d4dbf42749ad4903c97539cc9755a (patch) | |
tree | e460fc768af3a33bd2f13825295f6bc51efeaff9 /fs/ext4 | |
parent | c64a92992e6c1799f743999e1f1538fea0156aa4 (diff) | |
download | linux-stable-b24e77ef1c6d4dbf42749ad4903c97539cc9755a.tar.gz linux-stable-b24e77ef1c6d4dbf42749ad4903c97539cc9755a.tar.bz2 linux-stable-b24e77ef1c6d4dbf42749ad4903c97539cc9755a.zip |
ext4: avoid remove directory when directory is corrupted
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>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/namei.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index db4ba99d1ceb..1c6725ecca1a 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -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; } |