lkml.org 
[lkml]   [2019]   [Jul]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
Subject[PATCH v3] f2fs: avoid out-of-range memory access
From
blk_off might over 512 due to fs corrupt and should
be checked before being used.
Use ENTRIES_IN_SUM to protect invalid memory access.

--
v2:
- fix typo
v3:
- check blk_off before being used
--
Signed-off-by: Ocean Chen <oceanchen@google.com>
---
fs/f2fs/segment.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 8dee063c833f..c3eae3239345 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -3401,6 +3401,9 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
if (seg_i->alloc_type == SSR)
blk_off = sbi->blocks_per_seg;

+ if (blk_off >= ENTRIES_IN_SUM)
+ return -EFAULT;
+
for (j = 0; j < blk_off; j++) {
struct f2fs_summary *s;
s = (struct f2fs_summary *)(kaddr + offset);
--
2.22.0.410.gd8fdbe21b5-goog
\
 
 \ /
  Last update: 2019-07-03 17:34    [W:0.038 / U:22.916 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site