diff --git a/fsck/mount.c b/fsck/mount.c index 1d0df88..0e0c3f9 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -1248,7 +1248,7 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi) int ret; cp_payload = get_sb(cp_payload); - if (cp_payload > F2FS_BLK_ALIGN(MAX_SIT_BITMAP_SIZE)) + if (cp_payload > F2FS_BLK_ALIGN(MAX_CP_PAYLOAD)) return -EINVAL; cp_blks = 1 + cp_payload; diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 333ae07..f890634 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1168,6 +1168,10 @@ static_assert(sizeof(struct f2fs_nat_block) == 4095, ""); #define MAX_SIT_BITMAP_SIZE (SEG_ALIGN(SIZE_ALIGN(F2FS_MAX_SEGMENT, \ SIT_ENTRY_PER_BLOCK)) * \ c.blks_per_seg / 8) +#define MAX_CP_PAYLOAD (SEG_ALIGN(SIZE_ALIGN(UINT32_MAX, NAT_ENTRY_PER_BLOCK)) * \ + DEFAULT_NAT_ENTRY_RATIO / 100 * \ + c.blks_per_seg / 8 + \ + MAX_SIT_BITMAP_SIZE - MAX_BITMAP_SIZE_IN_CKPT) /* * Note that f2fs_sit_entry->vblocks has the following bit-field information.