All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] fix dumpimage for fit images
@ 2022-01-10 17:48 Stefan Eichenberger
  2022-01-10 17:48 ` [PATCH 1/2] tools/fitimage: remove redundant format check Stefan Eichenberger
  2022-01-10 17:48 ` [PATCH 2/2] tools/fitimage: make sure dumpimage still works when "@" are detected Stefan Eichenberger
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Eichenberger @ 2022-01-10 17:48 UTC (permalink / raw)
  To: devel-sven, mr.nuke.me, sjg; +Cc: u-boot

dumpimage does not work properly when an image includes "@" because
signing would fail. However, this should be supported because it is
enabled by default (even when signing is disabled). This patch series
tries to fix this by just printing a warning instead of failing
completely.

Stefan Eichenberger (2):
  tools/fitimage: remove redundant format check
  tools/fitimage: make sure dumpimage still works when "@" are detected

 tools/fit_common.c | 12 ++++++++++--
 tools/fit_image.c  |  5 -----
 2 files changed, 10 insertions(+), 7 deletions(-)

-- 
2.32.0


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

* [PATCH 1/2] tools/fitimage: remove redundant format check
  2022-01-10 17:48 [PATCH 0/2] fix dumpimage for fit images Stefan Eichenberger
@ 2022-01-10 17:48 ` Stefan Eichenberger
  2022-01-21 15:20   ` Simon Glass
  2022-01-24 16:53   ` Tom Rini
  2022-01-10 17:48 ` [PATCH 2/2] tools/fitimage: make sure dumpimage still works when "@" are detected Stefan Eichenberger
  1 sibling, 2 replies; 7+ messages in thread
From: Stefan Eichenberger @ 2022-01-10 17:48 UTC (permalink / raw)
  To: devel-sven, mr.nuke.me, sjg; +Cc: u-boot

fit_extract_contents does a fit_check_format even thought it was already
checked during imagetool_verify_print_header.
Therefore, this check is not necessary. This commit removes the
redundancy.

Signed-off-by: Stefan Eichenberger <eichest@gmail.com>
---
 tools/fit_image.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index f4f372ba62..62e1796ce5 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -884,11 +884,6 @@ static int fit_extract_contents(void *ptr, struct image_tool_params *params)
 	/* Indent string is defined in header image.h */
 	p = IMAGE_INDENT_STRING;
 
-	if (fit_check_format(fit, IMAGE_SIZE_INVAL)) {
-		printf("Bad FIT image format\n");
-		return -1;
-	}
-
 	/* Find images parent node offset */
 	images_noffset = fdt_path_offset(fit, FIT_IMAGES_PATH);
 	if (images_noffset < 0) {
-- 
2.32.0


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

* [PATCH 2/2] tools/fitimage: make sure dumpimage still works when "@" are detected
  2022-01-10 17:48 [PATCH 0/2] fix dumpimage for fit images Stefan Eichenberger
  2022-01-10 17:48 ` [PATCH 1/2] tools/fitimage: remove redundant format check Stefan Eichenberger
@ 2022-01-10 17:48 ` Stefan Eichenberger
  2022-01-21 15:20   ` Simon Glass
  2022-01-24 16:53   ` Tom Rini
  1 sibling, 2 replies; 7+ messages in thread
From: Stefan Eichenberger @ 2022-01-10 17:48 UTC (permalink / raw)
  To: devel-sven, mr.nuke.me, sjg; +Cc: u-boot

fit_verify_header fails if it detects unit addresses "@". However, this
will break tools like dumpimage on fit images which worked with previous
versions of the tool (e.g. 2020.04 vs 2021.07). As an example the output
of:
dumpimage -l <fit image>
is:
FIT description: U-Boot fitImage for Linux Distribution
Created:         Thu Jan  1 01:00:00 1970
 Image 0 (kernel@1)
  Description:  Linux kernel
  Created:      Thu Jan  1 01:00:00 1970
  Type:         Kernel Image
  Compression:  gzip compressed
  Data Size:    6442456 Bytes = 6291.46 KiB = 6.14 MiB
  Architecture: AArch64
  OS:           Linux
  Load Address: 0x80080000
  Entry Point:  0x80080000
  Hash algo:    sha256
  Hash value:   ...
 Image 1 (fdt@freescale_fsl-s32g274a-evb.dtb)
  Description:  Flattened Device Tree blob
  Created:      Thu Jan  1 01:00:00 1970
  Type:         Flat Device Tree
  Compression:  uncompressed
  Data Size:    39661 Bytes = 38.73 KiB = 0.04 MiB
  Architecture: AArch64
  Hash algo:    sha256
  Hash value:   ...
 Default Configuration: 'conf@freescale_fsl-s32g274a-evb.dtb'
 Configuration 0 (conf@freescale_fsl-s32g274a-evb.dtb)
  Description:  1 Linux kernel, FDT blob
  Kernel:       kernel@1
  FDT:          fdt@freescale_fsl-s32g274a-evb.dtb
  Hash algo:    sha256
  Hash value:   unavailable

But with newer version it shows:
dumpimage -l <fit image>
GP Header: Size d00dfeed LoadAddr 62f0a4

This commit will output a warning that unit addresses were detected but
will not fail:
dumpimage -l <fit image>
Image contains unit addresses @, this will break signing
...

Signed-off-by: Stefan Eichenberger <eichest@gmail.com>
---
 tools/fit_common.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/fit_common.c b/tools/fit_common.c
index 52b63296f8..5c8920de54 100644
--- a/tools/fit_common.c
+++ b/tools/fit_common.c
@@ -26,10 +26,18 @@
 int fit_verify_header(unsigned char *ptr, int image_size,
 			struct image_tool_params *params)
 {
-	if (fdt_check_header(ptr) != EXIT_SUCCESS ||
-	    fit_check_format(ptr, IMAGE_SIZE_INVAL))
+	int ret;
+
+	if (fdt_check_header(ptr) != EXIT_SUCCESS)
 		return EXIT_FAILURE;
 
+	ret = fit_check_format(ptr, IMAGE_SIZE_INVAL);
+	if (ret) {
+		if (ret != -EADDRNOTAVAIL)
+			return EXIT_FAILURE;
+		fprintf(stderr, "Image contains unit addresses @, this will break signing\n");
+	}
+
 	return EXIT_SUCCESS;
 }
 
-- 
2.32.0


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

* Re: [PATCH 2/2] tools/fitimage: make sure dumpimage still works when "@" are detected
  2022-01-10 17:48 ` [PATCH 2/2] tools/fitimage: make sure dumpimage still works when "@" are detected Stefan Eichenberger
@ 2022-01-21 15:20   ` Simon Glass
  2022-01-24 16:53   ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Glass @ 2022-01-21 15:20 UTC (permalink / raw)
  To: Stefan Eichenberger; +Cc: Sven Roederer, Alexandru Gagniuc, U-Boot Mailing List

On Mon, 10 Jan 2022 at 10:48, Stefan Eichenberger <eichest@gmail.com> wrote:
>
> fit_verify_header fails if it detects unit addresses "@". However, this
> will break tools like dumpimage on fit images which worked with previous
> versions of the tool (e.g. 2020.04 vs 2021.07). As an example the output
> of:
> dumpimage -l <fit image>
> is:
> FIT description: U-Boot fitImage for Linux Distribution
> Created:         Thu Jan  1 01:00:00 1970
>  Image 0 (kernel@1)
>   Description:  Linux kernel
>   Created:      Thu Jan  1 01:00:00 1970
>   Type:         Kernel Image
>   Compression:  gzip compressed
>   Data Size:    6442456 Bytes = 6291.46 KiB = 6.14 MiB
>   Architecture: AArch64
>   OS:           Linux
>   Load Address: 0x80080000
>   Entry Point:  0x80080000
>   Hash algo:    sha256
>   Hash value:   ...
>  Image 1 (fdt@freescale_fsl-s32g274a-evb.dtb)
>   Description:  Flattened Device Tree blob
>   Created:      Thu Jan  1 01:00:00 1970
>   Type:         Flat Device Tree
>   Compression:  uncompressed
>   Data Size:    39661 Bytes = 38.73 KiB = 0.04 MiB
>   Architecture: AArch64
>   Hash algo:    sha256
>   Hash value:   ...
>  Default Configuration: 'conf@freescale_fsl-s32g274a-evb.dtb'
>  Configuration 0 (conf@freescale_fsl-s32g274a-evb.dtb)
>   Description:  1 Linux kernel, FDT blob
>   Kernel:       kernel@1
>   FDT:          fdt@freescale_fsl-s32g274a-evb.dtb
>   Hash algo:    sha256
>   Hash value:   unavailable
>
> But with newer version it shows:
> dumpimage -l <fit image>
> GP Header: Size d00dfeed LoadAddr 62f0a4
>
> This commit will output a warning that unit addresses were detected but
> will not fail:
> dumpimage -l <fit image>
> Image contains unit addresses @, this will break signing
> ...
>
> Signed-off-by: Stefan Eichenberger <eichest@gmail.com>
> ---
>  tools/fit_common.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)

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

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

* Re: [PATCH 1/2] tools/fitimage: remove redundant format check
  2022-01-10 17:48 ` [PATCH 1/2] tools/fitimage: remove redundant format check Stefan Eichenberger
@ 2022-01-21 15:20   ` Simon Glass
  2022-01-24 16:53   ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Simon Glass @ 2022-01-21 15:20 UTC (permalink / raw)
  To: Stefan Eichenberger; +Cc: Sven Roederer, Alexandru Gagniuc, U-Boot Mailing List

On Mon, 10 Jan 2022 at 10:48, Stefan Eichenberger <eichest@gmail.com> wrote:
>
> fit_extract_contents does a fit_check_format even thought it was already
> checked during imagetool_verify_print_header.
> Therefore, this check is not necessary. This commit removes the
> redundancy.
>
> Signed-off-by: Stefan Eichenberger <eichest@gmail.com>
> ---
>  tools/fit_image.c | 5 -----
>  1 file changed, 5 deletions(-)
>

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

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

* Re: [PATCH 1/2] tools/fitimage: remove redundant format check
  2022-01-10 17:48 ` [PATCH 1/2] tools/fitimage: remove redundant format check Stefan Eichenberger
  2022-01-21 15:20   ` Simon Glass
@ 2022-01-24 16:53   ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2022-01-24 16:53 UTC (permalink / raw)
  To: Stefan Eichenberger; +Cc: devel-sven, mr.nuke.me, sjg, u-boot

[-- Attachment #1: Type: text/plain, Size: 437 bytes --]

On Mon, Jan 10, 2022 at 06:48:31PM +0100, Stefan Eichenberger wrote:

> fit_extract_contents does a fit_check_format even thought it was already
> checked during imagetool_verify_print_header.
> Therefore, this check is not necessary. This commit removes the
> redundancy.
> 
> Signed-off-by: Stefan Eichenberger <eichest@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

* Re: [PATCH 2/2] tools/fitimage: make sure dumpimage still works when "@" are detected
  2022-01-10 17:48 ` [PATCH 2/2] tools/fitimage: make sure dumpimage still works when "@" are detected Stefan Eichenberger
  2022-01-21 15:20   ` Simon Glass
@ 2022-01-24 16:53   ` Tom Rini
  1 sibling, 0 replies; 7+ messages in thread
From: Tom Rini @ 2022-01-24 16:53 UTC (permalink / raw)
  To: Stefan Eichenberger; +Cc: devel-sven, mr.nuke.me, sjg, u-boot

[-- Attachment #1: Type: text/plain, Size: 1935 bytes --]

On Mon, Jan 10, 2022 at 06:48:32PM +0100, Stefan Eichenberger wrote:

> fit_verify_header fails if it detects unit addresses "@". However, this
> will break tools like dumpimage on fit images which worked with previous
> versions of the tool (e.g. 2020.04 vs 2021.07). As an example the output
> of:
> dumpimage -l <fit image>
> is:
> FIT description: U-Boot fitImage for Linux Distribution
> Created:         Thu Jan  1 01:00:00 1970
>  Image 0 (kernel@1)
>   Description:  Linux kernel
>   Created:      Thu Jan  1 01:00:00 1970
>   Type:         Kernel Image
>   Compression:  gzip compressed
>   Data Size:    6442456 Bytes = 6291.46 KiB = 6.14 MiB
>   Architecture: AArch64
>   OS:           Linux
>   Load Address: 0x80080000
>   Entry Point:  0x80080000
>   Hash algo:    sha256
>   Hash value:   ...
>  Image 1 (fdt@freescale_fsl-s32g274a-evb.dtb)
>   Description:  Flattened Device Tree blob
>   Created:      Thu Jan  1 01:00:00 1970
>   Type:         Flat Device Tree
>   Compression:  uncompressed
>   Data Size:    39661 Bytes = 38.73 KiB = 0.04 MiB
>   Architecture: AArch64
>   Hash algo:    sha256
>   Hash value:   ...
>  Default Configuration: 'conf@freescale_fsl-s32g274a-evb.dtb'
>  Configuration 0 (conf@freescale_fsl-s32g274a-evb.dtb)
>   Description:  1 Linux kernel, FDT blob
>   Kernel:       kernel@1
>   FDT:          fdt@freescale_fsl-s32g274a-evb.dtb
>   Hash algo:    sha256
>   Hash value:   unavailable
> 
> But with newer version it shows:
> dumpimage -l <fit image>
> GP Header: Size d00dfeed LoadAddr 62f0a4
> 
> This commit will output a warning that unit addresses were detected but
> will not fail:
> dumpimage -l <fit image>
> Image contains unit addresses @, this will break signing
> ...
> 
> Signed-off-by: Stefan Eichenberger <eichest@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

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

end of thread, other threads:[~2022-01-24 16:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10 17:48 [PATCH 0/2] fix dumpimage for fit images Stefan Eichenberger
2022-01-10 17:48 ` [PATCH 1/2] tools/fitimage: remove redundant format check Stefan Eichenberger
2022-01-21 15:20   ` Simon Glass
2022-01-24 16:53   ` Tom Rini
2022-01-10 17:48 ` [PATCH 2/2] tools/fitimage: make sure dumpimage still works when "@" are detected Stefan Eichenberger
2022-01-21 15:20   ` Simon Glass
2022-01-24 16:53   ` 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.