diff mbox series

[1/1] bootm: update image OS image size when decompressing

Message ID 20200830093412.23494-1-xypron.glpk@gmx.de
State Accepted
Commit 21d3946840fd62dc09e93986743915bcbac100b7
Delegated to: Tom Rini
Headers show
Series [1/1] bootm: update image OS image size when decompressing | expand

Commit Message

Heinrich Schuchardt Aug. 30, 2020, 9:34 a.m. UTC
In bootm_load_os() the OS image is decompressed. In later stages of the
boot process we need the decompressed size of the image.

Update images->os.image_len after decompression.

Passing the correct size is necessary if we want to check loaded EFI
binararies for file truncation by comparing the loaded size to the header
field SizeOfImage.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 common/bootm.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.28.0

Comments

Simon Glass Aug. 31, 2020, 1:41 p.m. UTC | #1
On Sun, 30 Aug 2020 at 03:34, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> In bootm_load_os() the OS image is decompressed. In later stages of the
> boot process we need the decompressed size of the image.
>
> Update images->os.image_len after decompression.
>
> Passing the correct size is necessary if we want to check loaded EFI
> binararies for file truncation by comparing the loaded size to the header
> field SizeOfImage.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  common/bootm.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Sept. 14, 2020, 7:40 p.m. UTC | #2
On Sun, Aug 30, 2020 at 11:34:12AM +0200, Heinrich Schuchardt wrote:

> In bootm_load_os() the OS image is decompressed. In later stages of the
> boot process we need the decompressed size of the image.
> 
> Update images->os.image_len after decompression.
> 
> Passing the correct size is necessary if we want to check loaded EFI
> binararies for file truncation by comparing the loaded size to the header
> field SizeOfImage.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/bootm.c b/common/bootm.c
index 247b600d9c..b3377490b3 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -390,6 +390,8 @@  static int bootm_load_os(bootm_headers_t *images, int boot_progress)
 		bootstage_error(BOOTSTAGE_ID_DECOMP_IMAGE);
 		return err;
 	}
+	/* We need the decompressed image size in the next steps */
+	images->os.image_len = load_end - load;

 	flush_cache(flush_start, ALIGN(load_end, ARCH_DMA_MINALIGN) - flush_start);