All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] mkimage: fit: Do not tail-pad fitImage with external data
@ 2020-05-01 15:40 Marek Vasut
  2020-05-03  2:26 ` Simon Glass
  2020-05-04 11:27 ` Tom Rini
  0 siblings, 2 replies; 40+ messages in thread
From: Marek Vasut @ 2020-05-01 15:40 UTC (permalink / raw)
  To: u-boot

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.

$ echo -n xy > /tmp/data ; \
	./tools/mkimage -E -f auto -d /tmp/data /tmp/fitImage ; \
	hexdump -vC /tmp/fitImage | tail -n 3

before:
00000260  61 2d 6f 66 66 73 65 74  00 64 61 74 61 2d 73 69  |a-offset.data-si|
00000270  7a 65 00 00 78 79 64 64                           |ze..xydd|
                   ^^       ^^ ^^
after:
00000260  61 2d 6f 66 66 73 65 74  00 64 61 74 61 2d 73 69  |a-offset.data-si|
00000270  7a 65 00 78 79                                    |ze.xy|

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
V2: Rebase on u-boot/master, update commit message
---
 tools/fit_image.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 4aeabbcfe9..b859e7c0c0 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -434,7 +434,7 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
 	int image_number;
 	int align_size;
 
-	align_size = params->bl_len ? params->bl_len : 4;
+	align_size = params->bl_len ? params->bl_len : 1;
 	fd = mmap_fdt(params->cmdname, fname, 0, &fdt, &sbuf, false, false);
 	if (fd < 0)
 		return -EIO;
@@ -492,7 +492,6 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
 	fdt_pack(fdt);
 
 	new_size = fdt_totalsize(fdt);
-	new_size = ALIGN(new_size, align_size);
 	fdt_set_totalsize(fdt, new_size);
 	debug("Size reduced from %x to %x\n", fit_size, fdt_totalsize(fdt));
 	debug("External data size %x\n", buf_ptr);
-- 
2.25.1

^ permalink raw reply related	[flat|nested] 40+ messages in thread

end of thread, other threads:[~2020-05-26 15:53 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-01 15:40 [PATCH V2] mkimage: fit: Do not tail-pad fitImage with external data Marek Vasut
2020-05-03  2:26 ` Simon Glass
2020-05-04 11:27 ` Tom Rini
2020-05-05 13:22   ` Alex Kiernan
2020-05-05 13:28     ` Marek Vasut
2020-05-05 16:37       ` Alex Kiernan
2020-05-05 16:39         ` Marek Vasut
2020-05-05 17:50           ` Tom Rini
2020-05-05 17:53             ` Marek Vasut
2020-05-05 17:55               ` Tom Rini
2020-05-05 17:59                 ` Marek Vasut
2020-05-05 18:06                   ` Tom Rini
2020-05-05 18:18                     ` Marek Vasut
2020-05-05 18:41             ` Simon Glass
2020-05-05 21:17               ` Michael Walle
2020-05-06 10:15                 ` Michael Walle
2020-05-06 12:30                 ` Alex Kiernan
2020-05-06 13:48                 ` Tom Rini
2020-05-06 14:17                   ` Marek Vasut
2020-05-06 14:27                     ` Tom Rini
2020-05-06 14:33                       ` Marek Vasut
2020-05-06 14:37                         ` Tom Rini
2020-05-06 14:41                           ` Marek Vasut
2020-05-06 15:43                             ` Alex Kiernan
2020-05-06 15:52                               ` Marek Vasut
2020-05-06 16:04                                 ` Tom Rini
2020-05-06 16:17                                   ` Marek Vasut
2020-05-06 16:33                                     ` Tom Rini
2020-05-06 16:35                                       ` Marek Vasut
2020-05-06 17:02                                         ` Tom Rini
2020-05-06 18:11                                           ` Marek Vasut
2020-05-07 20:46                                           ` Samuel Holland
2020-05-08  1:37                                             ` Marek Vasut
2020-05-08 18:47                                               ` Tom Rini
2020-05-08 19:00                                                 ` Marek Vasut
2020-05-08 19:21                                                   ` Tom Rini
2020-05-10 19:24                                                     ` Marek Vasut
2020-05-11 19:36                                                       ` Tom Rini
2020-05-26 15:53                                                         ` Marek Vasut
2020-05-06 12:43               ` Alex Kiernan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.