Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: bcm47xxpart: avoid overflowing when registering trx

Our code parsing "trx" header registers few partitions at once (in one
loop iteration). Add extra check in that place.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Rafał Miłecki and committed by
Brian Norris
108ebcd8 00b79860

+5
+5
drivers/mtd/bcm47xxpart.c
··· 147 147 148 148 /* TRX */ 149 149 if (buf[0x000 / 4] == TRX_MAGIC) { 150 + if (BCM47XXPART_MAX_PARTS - curr_part < 4) { 151 + pr_warn("Not enough partitions left to register trx, scanning stopped!\n"); 152 + break; 153 + } 154 + 150 155 trx = (struct trx_header *)buf; 151 156 152 157 trx_part = curr_part;