]> asedeno.scripts.mit.edu Git - linux.git/commit
mtd: bcm47xxpart: improve handling TRX partition size
authorRafał Miłecki <rafal@milecki.pl>
Thu, 12 Apr 2018 05:24:52 +0000 (07:24 +0200)
committerBoris Brezillon <boris.brezillon@bootlin.com>
Sat, 12 May 2018 07:42:38 +0000 (09:42 +0200)
commit237ea0d4762cc14d0fc80e80d61f0f08e1050c7f
treea75c119297bc01792bfe9ecee94bc2c9be4e560f
parent5ac67ce36cfe38b4c104a42ce52c5c8d526f1c95
mtd: bcm47xxpart: improve handling TRX partition size

When bcm47xxpart finds a TRX partition (container) it's supposed to jump
to the end of it and keep looking for more partitions. TRX and its
subpartitions are handled by a separate parser.

The problem with old code was relying on the length specified in a TRX
header. That isn't reliable as TRX is commonly modified to have checksum
cover only non-changing subpartitions. Otherwise modifying e.g. a rootfs
would result in CRC32 mismatch and bootloader refusing to boot a
firmware.

Fix it by trying better to figure out a real TRX size. We can securely
assume that TRX has to cover all subpartitions and the last one is at
least of a block size in size. Then compare it with a length field.

This makes code more optimal & reliable thanks to skipping data that
shouldn't be parsed.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
drivers/mtd/bcm47xxpart.c