]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
nilfs2: fix possible int overflows in nilfs_fiemap()
authorNikita Zhandarovich <n.zhandarovich@fintech.ru>
Fri, 24 Jan 2025 22:20:53 +0000 (07:20 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 12:49:51 +0000 (13:49 +0100)
commitf3d80f34f58445355fa27b9579a449fb186aa64e
tree85cd516ff466c7a136401f421c8f8d7d3fe787a2
parent6e143eb4ab83c24e7ad3e3d8e7daa241d9c38377
nilfs2: fix possible int overflows in nilfs_fiemap()

commit 6438ef381c183444f7f9d1de18f22661cba1e946 upstream.

Since nilfs_bmap_lookup_contig() in nilfs_fiemap() calculates its result
by being prepared to go through potentially maxblocks == INT_MAX blocks,
the value in n may experience an overflow caused by left shift of blkbits.

While it is extremely unlikely to occur, play it safe and cast right hand
expression to wider type to mitigate the issue.

Found by Linux Verification Center (linuxtesting.org) with static analysis
tool SVACE.

Link: https://lkml.kernel.org/r/20250124222133.5323-1-konishi.ryusuke@gmail.com
Fixes: 622daaff0a89 ("nilfs2: fiemap support")
Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nilfs2/inode.c