Skip to contentSkip to conversation

f2fs: avoid out-of-range memory access

PATCH In review Ocean Chen 2 participants 2 messages Jul 8, 2019 F2FS file system

lore
Share & tools
lore

Ocean Chen

author
#0 lore raw

PATCH v4 1/1 f2fs: avoid out-of-range memory access

blkoff_off might over 512 due to fs corrupt or security vulnerability. That should be checked before being using.

Use ENTRIES_IN_SUM to protect invalid value in cur_data_blkoff.

---
 fs/f2fs/segment.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/f2fs/segment.c +5 -0
index 8dee063c833f..ac824f6632b6 100644
@@ -3393,6 +3393,11 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
 		seg_i = CURSEG_I(sbi, i);
 		segno = le32_to_cpu(ckpt->cur_data_segno[i]);
 		blk_off = le16_to_cpu(ckpt->cur_data_blkoff[i]);
+		if (blk_off > ENTRIES_IN_SUM) {
+			f2fs_bug_on(sbi, 1);
+			f2fs_put_page(page, 1);
+			return -EFAULT;
+		}
 		seg_i->next_segno = segno;
 		reset_curseg(sbi, i, 0);
 		seg_i->alloc_type = ckpt->alloc_type[i];
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog