]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mtd: fix possible integer overflow in erase_xfer()
authorIvan Stepchenko <sid@itb.spb.ru>
Thu, 19 Jun 2025 14:53:13 +0000 (17:53 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:08:51 +0000 (12:08 +0200)
commit530d4db6fb89aab97a04a5e7a9052969d71c0416
tree4bf204ad6fb3ad27d6498109a03e81aa77542056
parentaff3e6eacef227f0cbc3acfba6744397c4411417
mtd: fix possible integer overflow in erase_xfer()

[ Upstream commit 9358bdb9f9f54d94ceafc650deffefd737d19fdd ]

The expression '1 << EraseUnitSize' is evaluated in int, which causes
a negative result when shifting by 31 - the upper bound of the valid
range [10, 31], enforced by scan_header(). This leads to incorrect
extension when storing the result in 'erase->len' (uint64_t), producing
a large unexpected value.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Ivan Stepchenko <sid@itb.spb.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mtd/ftl.c