From patchwork Fri Apr 24 10:19:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 238406 List-Id: U-Boot discussion From: marex at denx.de (Marek Vasut) Date: Fri, 24 Apr 2020 12:19:00 +0200 Subject: [RFC][PATCH] mkimage: fit: Do not tail-pad fitImage with external data Message-ID: <20200424101900.156281-1-marex@denx.de> There is no reason to tail-pad fitImage with external data to 4-bytes, while fitImage without external data does not have any such padding and is often unaligned. DT spec also does not mandate any such padding. Moreover, the tail-pad fills the last few bytes with uninitialized data, which could lead to a potential information leak. Test: echo -n x > /tmp/data ; ./tools/mkimage -f auto -d /tmp/data /tmp/fitImage ; hexdump -vC /tmp/fitImage echo -n x > /tmp/data ; ./tools/mkimage -E -f auto -d /tmp/data /tmp/fitImage ; hexdump -vC /tmp/fitImage Signed-off-by: Marek Vasut Cc: Heinrich Schuchardt Cc: Simon Glass Cc: Tom Rini Reviewed-by: Simon Glass --- tools/fit_image.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/fit_image.c b/tools/fit_image.c index dd61a816c9..2fc4c3630d 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -488,7 +488,6 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname) debug("Size reduced from %x to %x\n", fit_size, fdt_totalsize(fdt)); debug("External data size %x\n", buf_ptr); new_size = fdt_totalsize(fdt); - new_size = (new_size + 3) & ~3; munmap(fdt, sbuf.st_size); if (ftruncate(fd, new_size)) {