From f8f956c7ec8c0285d7a80bed497d2f7adcbded15 Mon Sep 17 00:00:00 2001 From: Chao Yu Date: Mon, 26 Oct 2026 08:23:50 +0800 Subject: [PATCH] f2fs: fix to update superblock crc in sanity_check_area_boundary() This patch fixes the bug reported by Sashiko: We should update superblock crc along w/ raw_super->segment_count in sanity_check_area_boundary() if sb_checksum feature is enabled. Cc: stable@kernel.org Fixes: d440c52d3151 ("f2fs: support superblock checksum") Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/super.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 857cc2b29946..1071059f2cc2 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4084,6 +4084,12 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi, /* fix in-memory information all the time */ raw_super->segment_count = cpu_to_le32((main_end_blkaddr - segment0_blkaddr) >> log_blocks_per_seg); + if (__F2FS_HAS_FEATURE(raw_super, F2FS_FEATURE_SB_CHKSUM)) { + __u32 crc = f2fs_crc32(raw_super, + offsetof(struct f2fs_super_block, crc)); + + raw_super->crc = cpu_to_le32(crc); + } if (f2fs_readonly(sb) || f2fs_hw_is_readonly(sbi)) { set_sbi_flag(sbi, SBI_NEED_SB_WRITE);