summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Bin <yebin10@huawei.com>2022-06-22 12:02:23 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-08-25 12:45:47 +0300
commitbaa9f14ff470b301b6980db4deb58eb0efe79c3c (patch)
tree0457bce270489c74f85ad3e6488f6171b3c2e7ab
parenteb3a4f73f43f839df981dda5859e8e075067a360 (diff)
downloadlinux-baa9f14ff470b301b6980db4deb58eb0efe79c3c.tar.xz
ext4: avoid remove directory when directory is corrupted
[ Upstream commit b24e77ef1c6d4dbf42749ad4903c97539cc9755a ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/ext4/namei.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 4af441494e09..3a31b662f661 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3090,11 +3090,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;
}