mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-26 19:51:32 +00:00
resize.f2fs: fix wrong sit/nat bitmap during rebuild_checkpoint()
commit 159752dd3c
category: bugfix
issue: #I6VAS0
CVE: NA
Signed-off-by: DongSenhao <dongsenhao2@huawei.com>
---------------------------------------
As beroal <me@beroal.in.ua> reported: f2fs image can be corrupted
after below testcase:
1. truncate -s $((256*1024*1024)) img
2. mkfs.f2fs -f img
3. mount -t f2fs -o loop img /mnt
4. xfs_io -f /mnt/file -c "pwrite 0 2M" -c "fsync"
5. umount /mnt
6. resize.f2fs -s -t 262144 img
7. fsck.f2fs img
The root cause is we forgot to copy original sit/nat bitmap to
new checkpoint during rebuild_checkpoint(), fix it.
Reported-and-testd-by: beroal <me@beroal.in.ua>
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: dongsenhao <dongsenhao2@huawei.com>
This commit is contained in:
parent
143204c59f
commit
e61960e5e2
@ -526,6 +526,11 @@ static void rebuild_checkpoint(struct f2fs_sb_info *sbi,
|
||||
|
||||
memcpy(new_cp, cp, (unsigned char *)cp->sit_nat_version_bitmap -
|
||||
(unsigned char *)cp);
|
||||
if (c.safe_resize)
|
||||
memcpy((void *)new_cp + CP_BITMAP_OFFSET,
|
||||
(void *)cp + CP_BITMAP_OFFSET,
|
||||
F2FS_BLKSIZE - CP_BITMAP_OFFSET);
|
||||
|
||||
new_cp->checkpoint_ver = cpu_to_le64(cp_ver + 1);
|
||||
|
||||
crc = f2fs_checkpoint_chksum(new_cp);
|
||||
|
Loading…
Reference in New Issue
Block a user