fsck.f2fS: is_valid_summary(): check whether offset is out of bounds

commit 63d5004573
category: bugfix
issue: #I6VAS0
CVE: NA

Signed-off-by: DongSenhao <dongsenhao2@huawei.com>
---------------------------------------

This adds a check to the is_valid_summary function to prevent a segfault
if the calculated offset is out of bounds. Such an offset can for example
occur as the result of corruption of the underlying hardware.

I encountered this segfault on my own phone's sd card, so this is not
just a theoretical concern.

Signed-off-by: Arpad Müller <arpad.mueller@uni-bonn.de>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: dongsenhao <dongsenhao2@huawei.com>
This commit is contained in:
Arpad Müller 2021-09-01 06:55:54 +02:00 committed by dongsenhao
parent 5ff868458b
commit cc815563fc

View File

@ -250,8 +250,12 @@ static int is_valid_summary(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
if (node_blk->footer.nid == node_blk->footer.ino) {
int ofs = get_extra_isize(node_blk);
if (ofs + ofs_in_node >= DEF_ADDRS_PER_INODE)
goto out;
target_blk_addr = node_blk->i.i_addr[ofs + ofs_in_node];
} else {
if (ofs_in_node >= DEF_ADDRS_PER_BLOCK)
goto out;
target_blk_addr = node_blk->dn.addr[ofs_in_node];
}