summaryrefslogtreecommitdiff
path: root/fs/f2fs/checkpoint.c
diff options
context:
space:
mode:
authorKinglong Mee <kinglongmee@gmail.com>2017-03-15 16:12:50 +0300
committerJaegeuk Kim <jaegeuk@kernel.org>2017-03-22 05:34:34 +0300
commitc6f89dfd528041de2e71788495579a18c0363869 (patch)
tree1705c386e00b73c1a1c6325eeb8eec0c86b1fe50 /fs/f2fs/checkpoint.c
parentd03ba4cc3fa639916a86b61c5a3d817cb6aa91a0 (diff)
downloadlinux-c6f89dfd528041de2e71788495579a18c0363869.tar.xz
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 <kinglongmee@gmail.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/checkpoint.c')
-rw-r--r--fs/f2fs/checkpoint.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 22348c7df67d..7dd7dd5914c5 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -678,7 +678,7 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
*cp_block = (struct f2fs_checkpoint *)page_address(*cp_page);
crc_offset = le32_to_cpu((*cp_block)->checksum_offset);
- if (crc_offset >= blk_size) {
+ if (crc_offset > (blk_size - sizeof(__le32))) {
f2fs_msg(sbi->sb, KERN_WARNING,
"invalid crc_offset: %zu", crc_offset);
return -EINVAL;