mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 3/8] pbl: Move piggy verification into pbl_barebox_uncompress()
Date: Thu, 22 Aug 2019 14:51:53 +0200	[thread overview]
Message-ID: <20190822125158.10296-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20190822125158.10296-1-s.hauer@pengutronix.de>

piggy verification is a direct prerequisite of uncompressing the
piggydata, so move the verification there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/cpu/uncompress.c | 17 +----------------
 pbl/decomp.c              | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index 9cc3b358b0..4f16af22f8 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -42,18 +42,14 @@ unsigned long free_mem_end_ptr;
 extern unsigned char input_data[];
 extern unsigned char input_data_end[];
 
-extern unsigned char sha_sum[];
-extern unsigned char sha_sum_end[];
-
 void __noreturn barebox_multi_pbl_start(unsigned long membase,
 		unsigned long memsize, void *boarddata)
 {
-	uint32_t pg_len, uncompressed_len, pbl_hash_len;
+	uint32_t pg_len, uncompressed_len;
 	void __noreturn (*barebox)(unsigned long, unsigned long, void *);
 	unsigned long endmem = membase + memsize;
 	unsigned long barebox_base;
 	void *pg_start, *pg_end;
-	void *pbl_hash_start, *pbl_hash_end;
 	unsigned long pc = get_pc();
 
 	pg_start = input_data + global_variable_offset();
@@ -96,17 +92,6 @@ void __noreturn barebox_multi_pbl_start(unsigned long membase,
 	pr_debug("uncompressing barebox binary at 0x%p (size 0x%08x) to 0x%08lx (uncompressed size: 0x%08x)\n",
 			pg_start, pg_len, barebox_base, uncompressed_len);
 
-	if (IS_ENABLED(CONFIG_PBL_VERIFY_PIGGY)) {
-		pbl_hash_start = sha_sum;
-		pbl_hash_end = sha_sum_end;
-		pbl_hash_len = pbl_hash_end - pbl_hash_start;
-		if (pbl_barebox_verify(pg_start, pg_len, pbl_hash_start,
-				       pbl_hash_len) != 0) {
-			putc_ll('!');
-			panic("hash mismatch, refusing to decompress");
-		}
-	}
-
 	pbl_barebox_uncompress((void*)barebox_base, pg_start, pg_len);
 
 	sync_caches_for_execution();
diff --git a/pbl/decomp.c b/pbl/decomp.c
index ef713a6c74..8767f9fa7e 100644
--- a/pbl/decomp.c
+++ b/pbl/decomp.c
@@ -51,8 +51,25 @@ static void noinline errorfn(char *error)
 	while (1);
 }
 
+extern unsigned char sha_sum[];
+extern unsigned char sha_sum_end[];
+
 void pbl_barebox_uncompress(void *dest, void *compressed_start, unsigned int len)
 {
+	uint32_t pbl_hash_len;
+	void *pbl_hash_start, *pbl_hash_end;
+
+	if (IS_ENABLED(CONFIG_PBL_VERIFY_PIGGY)) {
+		pbl_hash_start = sha_sum;
+		pbl_hash_end = sha_sum_end;
+		pbl_hash_len = pbl_hash_end - pbl_hash_start;
+		if (pbl_barebox_verify(compressed_start, len, pbl_hash_start,
+				       pbl_hash_len) != 0) {
+			putc_ll('!');
+			panic("hash mismatch, refusing to decompress");
+		}
+	}
+
 	decompress((void *)compressed_start,
 			len,
 			NULL, NULL,
-- 
2.20.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2019-08-22 12:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-22 12:51 [PATCH 0/8] i.MX8 EVK patches Sascha Hauer
2019-08-22 12:51 ` [PATCH 1/8] ARM: aarch64: Fixup relocation table for the second relocation Sascha Hauer
2019-08-22 13:09   ` Rouven Czerwinski
2019-08-22 12:51 ` [PATCH 2/8] ARM: aarch64: Fix get_runtime_offset after relocation Sascha Hauer
2019-08-22 13:08   ` Rouven Czerwinski
2019-08-22 20:14   ` Andrey Smirnov
2019-08-23  8:11     ` Sascha Hauer
2019-08-22 12:51 ` Sascha Hauer [this message]
2019-08-22 13:07   ` [PATCH 3/8] pbl: Move piggy verification into pbl_barebox_uncompress() Rouven Czerwinski
2019-08-22 12:51 ` [PATCH 4/8] ARM: i.MX: imx8-ddrc: Remove debug code Sascha Hauer
2019-08-22 13:04   ` Rouven Czerwinski
2019-08-22 12:51 ` [PATCH 5/8] ARM: nxp-imx8mq-evk: Remove duplicate call to imx8mq_cpu_lowlevel_init() Sascha Hauer
2019-08-22 13:03   ` Rouven Czerwinski
2019-08-22 12:51 ` [PATCH 6/8] ARM: nxp-imx8mq-evk: Replace trampoline Sascha Hauer
2019-08-22 13:03   ` Rouven Czerwinski
2019-08-22 12:51 ` [PATCH 7/8] ARM: i.MX8: Fix piggydata loading Sascha Hauer
2019-08-22 13:02   ` Rouven Czerwinski
2019-08-22 12:51 ` [PATCH 8/8] ARM: nxp-imx8mq-evk: Update comments Sascha Hauer
2019-08-22 12:59   ` Rouven Czerwinski
2019-08-22 13:19 ` [PATCH 0/8] i.MX8 EVK patches Rouven Czerwinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190822125158.10296-4-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox