Skip to contentSkip to conversation

f2fs: avoid out-of-range memory access

PATCH Superseded Ocean Chen 1 participant 1 message Jul 2, 2019 F2FS file system

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Ocean Chen

author
#0 lore raw

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

blk_off might over 512 due to fs corrupt. Use ENTRIES_IN_SUM to protect invalid memory access.

---
 fs/f2fs/segment.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/segment.c +2 -0
index 8dee063c833f..b83c23ebae1f 100644
@@ -3403,6 +3403,8 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
 
 		for (j = 0; j < blk_off; j++) {
 			struct f2fs_summary *s;
+			if (blk_off >= ENTRIES_IN_SUM)
+				return -EFAULT;
 			s = (struct f2fs_summary *)(kaddr + offset);
 			seg_i->sum_blk->entries[j] = *s;
 			offset += SUMMARY_SIZE;
Signature · 1 line
2.22.0.410.gd8fdbe21b5-goog