]> git.ipfire.org Git - thirdparty/kernel/linux.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)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Thu, 19 Jun 2025 17:14:46 +0000 (19:14 +0200)
commit9358bdb9f9f54d94ceafc650deffefd737d19fdd
treeca6c3a8cb2de86dff56b442ac8c6529bdac919d3
parentd22d5f47ecb2c4e140c0ee52204f4dd8fd0e85eb
mtd: fix possible integer overflow in erase_xfer()

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>
drivers/mtd/ftl.c