All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] mkimage: fit: Do not tail-pad fitImage with external data
@ 2020-04-24 10:19 Marek Vasut
  2020-04-24 16:02 ` Simon Glass
  2020-05-01 15:06 ` Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Marek Vasut @ 2020-04-24 10:19 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.

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 <marex@denx.de>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
 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)) {
-- 
2.25.1

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

* [RFC][PATCH] mkimage: fit: Do not tail-pad fitImage with external data
  2020-04-24 10:19 [RFC][PATCH] mkimage: fit: Do not tail-pad fitImage with external data Marek Vasut
@ 2020-04-24 16:02 ` Simon Glass
  2020-05-01 10:31   ` Marek Vasut
  2020-05-01 15:06 ` Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Simon Glass @ 2020-04-24 16:02 UTC (permalink / raw)
  To: u-boot

On Fri, 24 Apr 2020 at 04:19, Marek Vasut <marex@denx.de> wrote:
>
> 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 <marex@denx.de>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
>  tools/fit_image.c | 1 -
>  1 file changed, 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Would be good to get this in early for testing.

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

* [RFC][PATCH] mkimage: fit: Do not tail-pad fitImage with external data
  2020-04-24 16:02 ` Simon Glass
@ 2020-05-01 10:31   ` Marek Vasut
  0 siblings, 0 replies; 4+ messages in thread
From: Marek Vasut @ 2020-05-01 10:31 UTC (permalink / raw)
  To: u-boot

On 4/24/20 6:02 PM, Simon Glass wrote:
> On Fri, 24 Apr 2020 at 04:19, Marek Vasut <marex@denx.de> wrote:
>>
>> 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 <marex@denx.de>
>> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> Cc: Simon Glass <sjg@chromium.org>
>> Cc: Tom Rini <trini@konsulko.com>
>> ---
>>  tools/fit_image.c | 1 -
>>  1 file changed, 1 deletion(-)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> Would be good to get this in early for testing.

Tom ? This missed rc1 ...

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

* [RFC][PATCH] mkimage: fit: Do not tail-pad fitImage with external data
  2020-04-24 10:19 [RFC][PATCH] mkimage: fit: Do not tail-pad fitImage with external data Marek Vasut
  2020-04-24 16:02 ` Simon Glass
@ 2020-05-01 15:06 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2020-05-01 15:06 UTC (permalink / raw)
  To: u-boot

On Fri, Apr 24, 2020 at 12:19:00PM +0200, Marek Vasut wrote:

> 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 <marex@denx.de>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> ---
>  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)) {

As of:
commit ebfe611be91e0075c040588a30a9996519d30aa6
Author: Kever Yang <kever.yang@rock-chips.com>
Date:   Mon Mar 30 11:56:24 2020 +0800

    mkimage: fit_image: Add option to make fit header align

this doesn't apply and the area in question has changed.  Can you please
see if your use-case is supported correctly now?  Or v2 this, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200501/8a7a8498/attachment.sig>

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 10:19 [RFC][PATCH] mkimage: fit: Do not tail-pad fitImage with external data Marek Vasut
2020-04-24 16:02 ` Simon Glass
2020-05-01 10:31   ` Marek Vasut
2020-05-01 15:06 ` Tom Rini

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.