mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Stefan Kerkmann <s.kerkmann@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 BAREBOX <barebox@lists.infradead.org>
Cc: Stefan Kerkmann <s.kerkmann@pengutronix.de>
Subject: [PATCH] hab: writing the same srk hash is not an error
Date: Wed, 09 Jul 2025 09:42:43 +0200	[thread overview]
Message-ID: <20250709-fix-hab-equal-hash-writes-v1-1-6a59bb4b5ff1@pengutronix.de> (raw)

Before this commit writing the same srk hash twice failed with an error.
This is inconsistent with other invocations of the hab tool e.g.: `hab
-l -p` doesn't fail if the lockdown bit is already set.

So let's align the behavior by only throwing an error if we attempt to
write a srk hash that is different from the one that is already burned.

Signed-off-by: Stefan Kerkmann <s.kerkmann@pengutronix.de>
---
 drivers/hab/hab.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/hab/hab.c b/drivers/hab/hab.c
index 4e9f96c98b619d12d069986aa688b92d48f3442c..1c747e8a3e52fdfc0240b5794fbffe9a2a562bb2 100644
--- a/drivers/hab/hab.c
+++ b/drivers/hab/hab.c
@@ -470,12 +470,13 @@ int imx_hab_write_srk_hash(const void *buf, unsigned flags)
 	}
 
 	if (imx_hab_srk_hash_valid(cursrk)) {
-		char *str = "Current SRK hash is valid";
-
 		if (flags & IMX_SRK_HASH_FORCE) {
-			pr_warn("%s, ignoring\n", str);
+			pr_warn("Current SRK hash is valid, ignoring\n");
+		} else if (memcmp(cursrk, buf, SRK_HASH_SIZE) == 0) {
+			pr_info("Current SRK hash is equal, nothing to do\n");
+			return 0;
 		} else {
-			pr_err("%s, refusing to burn again\n", str);
+			pr_err("Current SRK hash is different, refusing to burn again\n");
 			return -EEXIST;
 		}
 	}

---
base-commit: f49c873d7ec78a2df7bd3c7a86f5372fb1666517
change-id: 20250709-fix-hab-equal-hash-writes-87c28792acf4

Best regards,
-- 
Stefan Kerkmann <s.kerkmann@pengutronix.de>




                 reply	other threads:[~2025-07-09  9:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250709-fix-hab-equal-hash-writes-v1-1-6a59bb4b5ff1@pengutronix.de \
    --to=s.kerkmann@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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