Skip to content

Commit

Permalink
mtd: partitions: redboot: Added conversion of operands to a larger type
Browse files Browse the repository at this point in the history
The value of an arithmetic expression directory * master->erasesize is
subject to overflow due to a failure to cast operands to a larger data
type before perfroming arithmetic

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

Signed-off-by: Denis Arefev <arefev@swemel.ru>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20240315093758.20790-1-arefev@swemel.ru
  • Loading branch information
Denis Arefev authored and miquelraynal committed Mar 25, 2024
1 parent 26729db commit 1162bc2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/parsers/redboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int parse_redboot_partitions(struct mtd_info *master,
offset -= master->erasesize;
}
} else {
offset = directory * master->erasesize;
offset = (unsigned long) directory * master->erasesize;
while (mtd_block_isbad(master, offset)) {
offset += master->erasesize;
if (offset == master->size)
Expand Down

0 comments on commit 1162bc2

Please sign in to comment.