* [f2fs-dev] [PATCH] f2fs: prevent possible int overflow in dir_block_index()
@ 2024-07-24 17:05 Nikita Zhandarovich
2024-07-25 3:21 ` 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:05 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu
Cc: lvc-project, stable, linux-kernel, Nikita Zhandarovich,
linux-f2fs-devel
The result of multiplication between values derived from functions
dir_buckets() and bucket_blocks() *could* technically reach
2^30 * 2^2 = 2^32.
While unlikely to happen, it is prudent to ensure that it will not
lead to integer overflow. Thus, use mul_u32_u32() as it's more
appropriate to mitigate the issue.
Found by Linux Verification Center (linuxtesting.org) with static
analysis tool SVACE.
Fixes: 3843154598a0 ("f2fs: introduce large directory support")
Cc: stable@vger.kernel.org
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
---
fs/f2fs/dir.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index cbd7a5e96a37..14900ca8a9ff 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -166,7 +166,8 @@ static unsigned long dir_block_index(unsigned int level,
unsigned long bidx = 0;
for (i = 0; i < level; i++)
- bidx += dir_buckets(i, dir_level) * bucket_blocks(i);
+ bidx += mul_u32_u32(dir_buckets(i, dir_level),
+ bucket_blocks(i));
bidx += idx * bucket_blocks(level);
return bidx;
}
_______________________________________________
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: prevent possible int overflow in dir_block_index()
2024-07-24 17:05 [f2fs-dev] [PATCH] f2fs: prevent possible int overflow in dir_block_index() Nikita Zhandarovich
@ 2024-07-25 3:21 ` 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:21 UTC (permalink / raw)
To: Nikita Zhandarovich, Jaegeuk Kim
Cc: lvc-project, linux-kernel, stable, linux-f2fs-devel
On 2024/7/25 1:05, Nikita Zhandarovich wrote:
> The result of multiplication between values derived from functions
> dir_buckets() and bucket_blocks() *could* technically reach
> 2^30 * 2^2 = 2^32.
>
> While unlikely to happen, it is prudent to ensure that it will not
> lead to integer overflow. Thus, use mul_u32_u32() as it's more
> appropriate to mitigate the issue.
>
> Found by Linux Verification Center (linuxtesting.org) with static
> analysis tool SVACE.
>
> Fixes: 3843154598a0 ("f2fs: introduce large directory support")
> 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: prevent possible int overflow in dir_block_index()
2024-07-24 17:05 [f2fs-dev] [PATCH] f2fs: prevent possible int overflow in dir_block_index() Nikita Zhandarovich
2024-07-25 3:21 ` 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:05:44 -0700 you wrote:
> The result of multiplication between values derived from functions
> dir_buckets() and bucket_blocks() *could* technically reach
> 2^30 * 2^2 = 2^32.
>
> While unlikely to happen, it is prudent to ensure that it will not
> lead to integer overflow. Thus, use mul_u32_u32() as it's more
> appropriate to mitigate the issue.
>
> [...]
Here is the summary with links:
- [f2fs-dev] f2fs: prevent possible int overflow in dir_block_index()
https://git.kernel.org/jaegeuk/f2fs/c/47f268f33dff
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:05 [f2fs-dev] [PATCH] f2fs: prevent possible int overflow in dir_block_index() Nikita Zhandarovich
2024-07-25 3:21 ` 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).