Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 03db683

Browse files
Nikita Zhandarovichgregkh
Nikita Zhandarovich
authored andcommittedOct 4, 2024
f2fs: avoid potential int overflow in sanity_check_area_boundary()
commit 50438db upstream. While calculating the end addresses of main area and segment 0, u32 may be not enough to hold the result without the danger of int overflow. Just in case, play it safe and cast one of the operands to a wider type (u64). Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE. Fixes: fd69473 ("f2fs: cover large section in sanity check of super") Cc: stable@vger.kernel.org Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1752644 commit 03db683

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎fs/f2fs/super.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3356,9 +3356,9 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi,
33563356
u32 segment_count = le32_to_cpu(raw_super->segment_count);
33573357
u32 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
33583358
u64 main_end_blkaddr = main_blkaddr +
3359-
(segment_count_main << log_blocks_per_seg);
3359+
((u64)segment_count_main << log_blocks_per_seg);
33603360
u64 seg_end_blkaddr = segment0_blkaddr +
3361-
(segment_count << log_blocks_per_seg);
3361+
((u64)segment_count << log_blocks_per_seg);
33623362

33633363
if (segment0_blkaddr != cp_blkaddr) {
33643364
f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)",

0 commit comments

Comments
 (0)
This repository has been archived.