fsck.f2fs: sanity check of crc_offset from raw checkpoint
PATCH 1/1 fsck.f2fs: sanity check of crc_offset from raw checkpoint
The crc_offset towards or beyond the end of block is wrong, sanity check it.
Signed-off-by Kinglong Mee <[email protected]>
--- fsck/mount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fsck/mount.c +2 -2
@@ -545,7 +545,7 @@ void *validate_checkpoint(struct f2fs_sb_info *sbi, block_t cp_addr, cp = (struct f2fs_checkpoint *)cp_page_1; crc_offset =get_cp (checksum_offset); -if (crc_offset >= blk_size) +if (crc_offset > (blk_size -sizeof (__le32))) goto invalid_cp1; crc =le32_to_cpu (*(__le32 *)((unsigned char *)cp + crc_offset));
@@ -563,7 +563,7 @@ void *validate_checkpoint(struct f2fs_sb_info *sbi, block_t cp_addr, cp = (struct f2fs_checkpoint *)cp_page_2; crc_offset =get_cp (checksum_offset); -if (crc_offset >= blk_size) +if (crc_offset > (blk_size -sizeof (__le32))) goto invalid_cp2; crc =le32_to_cpu (*(__le32 *)((unsigned char *)cp + crc_offset));
Signature · 6 lines
2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot