* [PATCH 1/1] f2fs-tools: sanity check segno and blk_off when building curseg array
@ 2017-04-27 22:03 Jin Qian
2017-04-27 22:41 ` Jaegeuk Kim
0 siblings, 1 reply; 2+ messages in thread
From: Jin Qian @ 2017-04-27 22:03 UTC (permalink / raw)
To: linux-f2fs-devel; +Cc: jaegeuk
segno and blk_off were read from input image without sanity check. This
could lead to buffer overflow when accessing internal arrays like SIT
sentries and seg_entry cur_valid_map.
Signed-off-by: Jin Qian <jinqian@google.com>
---
fsck/mount.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fsck/mount.c b/fsck/mount.c
index ffaa0ed..749c417 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1040,6 +1040,9 @@ static void build_curseg(struct f2fs_sb_info *sbi)
blk_off = get_cp(cur_node_blkoff[i - CURSEG_HOT_NODE]);
segno = get_cp(cur_node_segno[i - CURSEG_HOT_NODE]);
}
+ ASSERT(segno < TOTAL_SEGS(sbi));
+ ASSERT((blk_off >> 3) < SIT_VBLOCK_MAP_SIZE);
+
array[i].segno = segno;
array[i].zone = GET_ZONENO_FROM_SEGNO(sbi, segno);
array[i].next_segno = NULL_SEGNO;
--
2.13.0.rc0.306.g87b477812d-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] f2fs-tools: sanity check segno and blk_off when building curseg array
2017-04-27 22:03 [PATCH 1/1] f2fs-tools: sanity check segno and blk_off when building curseg array Jin Qian
@ 2017-04-27 22:41 ` Jaegeuk Kim
0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2017-04-27 22:41 UTC (permalink / raw)
To: Jin Qian; +Cc: linux-f2fs-devel
Hi Jin,
On 04/27, Jin Qian wrote:
> segno and blk_off were read from input image without sanity check. This
> could lead to buffer overflow when accessing internal arrays like SIT
> sentries and seg_entry cur_valid_map.
>
> Signed-off-by: Jin Qian <jinqian@google.com>
> ---
> fsck/mount.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fsck/mount.c b/fsck/mount.c
> index ffaa0ed..749c417 100644
> --- a/fsck/mount.c
> +++ b/fsck/mount.c
> @@ -1040,6 +1040,9 @@ static void build_curseg(struct f2fs_sb_info *sbi)
> blk_off = get_cp(cur_node_blkoff[i - CURSEG_HOT_NODE]);
> segno = get_cp(cur_node_segno[i - CURSEG_HOT_NODE]);
> }
> + ASSERT(segno < TOTAL_SEGS(sbi));
> + ASSERT((blk_off >> 3) < SIT_VBLOCK_MAP_SIZE);
ASSERT(blk_off < DEFAULT_BLOCKS_PER_SEGMENT);
Otherwise, blk_off can be cut by shift operation.
Thanks,
> +
> array[i].segno = segno;
> array[i].zone = GET_ZONENO_FROM_SEGNO(sbi, segno);
> array[i].next_segno = NULL_SEGNO;
> --
> 2.13.0.rc0.306.g87b477812d-goog
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-04-27 22:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-27 22:03 [PATCH 1/1] f2fs-tools: sanity check segno and blk_off when building curseg array Jin Qian
2017-04-27 22:41 ` Jaegeuk Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).