Skip to contentSkip to conversation

ext4: Verify extent header in ext4_find_extent()

PATCH In review Shigeru Yoshida 2 participants 3 messages Jan 2, 2023 – Jan 3, 2023 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Verify extent header in ext4_find_extent()

syzbot reported use-after-free in ext4_find_extent() [1]. If there is a corrupted file system, this can cause invalid memory access.

This patch fixes the issue by verifying extent header.

---
 fs/ext4/extents.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/extents.c +3 -0
index 9de1c9d1a13d..79bfa583ab1d 100644
@@ -901,6 +901,9 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
 		ret = -EFSCORRUPTED;
 		goto err;
 	}
+	ret = ext4_ext_check(inode, eh, depth, 0);
+	if (ret)
+		goto err;
 
 	if (path) {
 		ext4_ext_drop_refs(path);
Signature · 1 line
2.38.1
#1 lore raw
Quoted 17 lines · Shigeru Yoshida

syzbot reported use-after-free in ext4_find_extent() [1]. If there is a corrupted file system, this can cause invalid memory access.

This patch fixes the issue by verifying extent header.

---
 fs/ext4/extents.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ext4/extents.c +0 -0
index 9de1c9d1a13d..79bfa583ab1d 100644

fs/ext4/extents.c ext4_find_extent(struct inode *inode, ext4_lblk_t block, · line 906

Quoted 6 lines
fs/ext4/extents.c +3 -0
@@ -901,6 +901,9 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
 		ret = -EFSCORRUPTED;
 		goto err;
 	}
+	ret = ext4_ext_check(inode, eh, depth, 0);
+	if (ret)
+		goto err;

This patch probably does not address the root cause of the problem. Please see the discussion on the very similar patch
https://lore.kernel.org/linux-ext4/[email protected]/T/#u

- Eric

#2 lore raw
Quoted 13 lines · Eric Biggers
Quoted 12 lines · Shigeru Yoshida

syzbot reported use-after-free in ext4_find_extent() [1]. If there is a corrupted file system, this can cause invalid memory access.

This patch fixes the issue by verifying extent header.

---
 fs/ext4/extents.c | 3 +++
 1 file changed, 3 insertions(+)
Quoted 15 lines

fs/ext4/extents.c ext4_find_extent(struct inode *inode, ext4_lblk_t block, · line 906

Quoted 11 lines
fs/ext4/extents.c +3 -0
index 9de1c9d1a13d..79bfa583ab1d 100644
@@ -901,6 +901,9 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
 		ret = -EFSCORRUPTED;
 		goto err;
 	}
+	ret = ext4_ext_check(inode, eh, depth, 0);
+	if (ret)
+		goto err;

This patch probably does not address the root cause of the problem. Please see the discussion on the very similar patch
https://lore.kernel.org/linux-ext4/[email protected]/T/#u

Thank you so much for your comment!! I missed the discussion you mentioned. I'll check that.

Regards,
Shigeru

Quoted 3 lines

- Eric