• Rafał Miłecki's avatar
    mtd: bcm47xxpart: improve handling TRX partition size · 237ea0d4
    Rafał Miłecki authored
    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: default avatarRafał Miłecki <rafal@milecki.pl>
    Signed-off-by: default avatarBoris Brezillon <boris.brezillon@bootlin.com>
    237ea0d4
bcm47xxpart.c 8.58 KB