mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 04:42:04 -04:00
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: 1da177e4c3 ("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>
This commit is contained in:
parent
b890f3d8d1
commit
a0d2de5561
1 changed files with 1 additions and 1 deletions
|
|
@ -344,7 +344,7 @@ static int erase_xfer(partition_t *part,
|
|||
return -ENOMEM;
|
||||
|
||||
erase->addr = xfer->Offset;
|
||||
erase->len = 1 << part->header.EraseUnitSize;
|
||||
erase->len = 1ULL << part->header.EraseUnitSize;
|
||||
|
||||
ret = mtd_erase(part->mbd.mtd, erase);
|
||||
if (!ret) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue