* [f2fs-dev] [PATCH] f2fs: avoid potential int overflow in sanity_check_area_boundary()
@ 2024-07-24 17:51 Nikita Zhandarovich
2024-07-25 3:26 ` Chao Yu
2024-08-05 23:30 ` patchwork-bot+f2fs
0 siblings, 2 replies; 3+ messages in thread
From: Nikita Zhandarovich @ 2024-07-24 17:51 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu
Cc: lvc-project, stable, linux-kernel, Nikita Zhandarovich,
linux-f2fs-devel
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: fd694733d523 ("f2fs: cover large section in sanity check of super")
Cc: stable@vger.kernel.org
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
---
fs/f2fs/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 3959fd137cc9..4d8f38ca6fcd 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -3356,9 +3356,9 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi,
u32 segment_count = le32_to_cpu(raw_super->segment_count);
u32 log_blocks_per_seg = le32_to_cpu(raw_super->log_blocks_per_seg);
u64 main_end_blkaddr = main_blkaddr +
- (segment_count_main << log_blocks_per_seg);
+ ((u64)segment_count_main << log_blocks_per_seg);
u64 seg_end_blkaddr = segment0_blkaddr +
- (segment_count << log_blocks_per_seg);
+ ((u64)segment_count << log_blocks_per_seg);
if (segment0_blkaddr != cp_blkaddr) {
f2fs_info(sbi, "Mismatch start address, segment0(%u) cp_blkaddr(%u)",
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: avoid potential int overflow in sanity_check_area_boundary()
2024-07-24 17:51 [f2fs-dev] [PATCH] f2fs: avoid potential int overflow in sanity_check_area_boundary() Nikita Zhandarovich
@ 2024-07-25 3:26 ` Chao Yu
2024-08-05 23:30 ` patchwork-bot+f2fs
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2024-07-25 3:26 UTC (permalink / raw)
To: Nikita Zhandarovich, Jaegeuk Kim
Cc: lvc-project, linux-kernel, stable, linux-f2fs-devel
On 2024/7/25 1:51, Nikita Zhandarovich wrote:
> 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: fd694733d523 ("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>
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [f2fs-dev] [PATCH] f2fs: avoid potential int overflow in sanity_check_area_boundary()
2024-07-24 17:51 [f2fs-dev] [PATCH] f2fs: avoid potential int overflow in sanity_check_area_boundary() Nikita Zhandarovich
2024-07-25 3:26 ` Chao Yu
@ 2024-08-05 23:30 ` patchwork-bot+f2fs
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs @ 2024-08-05 23:30 UTC (permalink / raw)
To: Nikita Zhandarovich
Cc: lvc-project, linux-kernel, stable, linux-f2fs-devel, jaegeuk
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Wed, 24 Jul 2024 10:51:58 -0700 you wrote:
> 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).
>
> [...]
Here is the summary with links:
- [f2fs-dev] f2fs: avoid potential int overflow in sanity_check_area_boundary()
https://git.kernel.org/jaegeuk/f2fs/c/50438dbc483c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-05 23:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-24 17:51 [f2fs-dev] [PATCH] f2fs: avoid potential int overflow in sanity_check_area_boundary() Nikita Zhandarovich
2024-07-25 3:26 ` Chao Yu
2024-08-05 23:30 ` patchwork-bot+f2fs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).