[U-Boot-Users] [PATCH 13/13] [new uImage] Return error on image move/uncompress overwrites

Marian Balakowicz
2008-01-15T11:15:55Z

Wolfgang Denk wrote:
> In message <20080111143054.8025.33808.stgit@hekate.izotz.org> you wrote:
>> Check for overwrites during image move/uncompress, return with error
>> when the original image gets corrupted. Report clear message to the user
>> and prevent further troubles when pointer to the corrupted images is passed
>> to do_bootm_linux routine.
>
> Does this really work? With compressed images?

Yes it does, I tested it with compressed linux kernel images.

>> + image_start = (ulong)fdt_hdr;
>> + image_end = image_get_image_end(fdt_hdr);
>> +
>> + load_start = image_get_load(fdt_hdr);
>> + load_end = load_start + image_get_data_size(fdt_hdr);
>> +
>> + if ((load_start < image_end) && (load_end > image_start)) {
>> puts ("ERROR: fdt overwritten - "
>> "must RESET the board to recover.\n");
>> do_reset (cmdtp, flag, argc, argv);
>
> Me thinks that load_end gives a value which does not take into
> account that the loaded, uncompressed image will be much bigger than
> image_get_data_size() tells - or am I missing something?

That part of the patch deals with the FDT blob image. Compressed blobs
are not supported in the current code, so no decompression happens and
we can use image_get_data_size(). BTW, this particular overwrite check
is already present in the current U-boot.

Cheers,
m.