Skip to contentSkip to conversation

image: Control FIT signature verification at runtime

PATCH In review Andrew Jeffery 5 participants 15 messages Jan 31, 2022 – Feb 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 image: Control FIT signature verification at runtime

Some platform designs include support for disabling secure-boot via a jumper on the board. Sometimes this control can be separate from the mechanism enabling the root-of-trust for the platform. Add support for this latter scenario by allowing boards to implement board_fit_image_require_verfied(), which is then invoked in the usual FIT verification paths.

---
Hi,

This patch is extracted from and motivated by a series adding run-time control of FIT signature verification to u-boot in OpenBMC:

https://lore.kernel.org/openbmc/[email protected]/

Unfortunately the OpenBMC u-boot tree is quite a way behind on tracking upstream and contains a bunch of out-of-tree work as well. As such I'm looking to upstream the couple of changes that make sense against master.

Please take a look!

Andrew

 boot/Kconfig     |  8 ++++++++
 boot/image-fit.c | 21 +++++++++++++++++----
 include/image.h  |  9 +++++++++
 3 files changed, 34 insertions(+), 4 deletions(-)
boot/Kconfig +8 -0
index c8d5906cd304..ec413151fd5a 100644
@@ -78,6 +78,14 @@ config FIT_SIGNATURE
 	  format support in this case, enable it using
 	  CONFIG_LEGACY_IMAGE_FORMAT.
 
+if FIT_SIGNATURE
+config FIT_RUNTIME_SIGNATURE
+	bool "Control verification of FIT uImages at runtime"
+	help
+	  This option allows board support to disable verification of
+	  signatures at runtime, for example through the state of a GPIO.
+endif # FIT_SIGNATURE
+
 config FIT_SIGNATURE_MAX_SIZE
 	hex "Max size of signed FIT structures"
 	depends on FIT_SIGNATURE
boot/image-fit.c +17 -4
index f01cafe4e277..919dbfa4ee1d 100644
@@ -1308,6 +1308,14 @@ static int fit_image_check_hash(const void *fit, int noffset, const void *data,
 	return 0;
 }
 
+#ifndef __weak
+#define __weak
+#endif
+__weak int board_fit_image_require_verified(void)
+{
+	return 1;
+}
+
 int fit_image_verify_with_data(const void *fit, int image_noffset,
 			       const void *key_blob, const void *data,
 			       size_t size)
@@ -1319,6 +1327,7 @@ int fit_image_verify_with_data(const void *fit, int image_noffset,
 
 	/* Verify all required signatures */
 	if (FIT_IMAGE_ENABLE_VERIFY &&
+	    fit_image_require_verified() &&
 	    fit_image_verify_required_sigs(fit, image_noffset, data, size,
 					   key_blob, &verify_all)) {
 		err_msg = "Unable to verify required signature";
@@ -1340,9 +1349,11 @@ int fit_image_verify_with_data(const void *fit, int image_noffset,
 						 &err_msg))
 				goto error;
 			puts("+ ");
-		} else if (FIT_IMAGE_ENABLE_VERIFY && verify_all &&
-				!strncmp(name, FIT_SIG_NODENAME,
-					strlen(FIT_SIG_NODENAME))) {
+		} else if (FIT_IMAGE_ENABLE_VERIFY &&
+			   fit_image_require_verified() &&
+			   verify_all &&
+			   !strncmp(name, FIT_SIG_NODENAME,
+				    strlen(FIT_SIG_NODENAME))) {
 			ret = fit_image_check_sig(fit, noffset, data, size,
 						  gd_fdt_blob(), -1, &err_msg);
 
@@ -2061,7 +2072,9 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 		if (image_type == IH_TYPE_KERNEL)
 			images->fit_uname_cfg = fit_base_uname_config;
 
-		if (FIT_IMAGE_ENABLE_VERIFY && images->verify) {
+		if (FIT_IMAGE_ENABLE_VERIFY &&
+		    fit_image_require_verified() &&
+		    images->verify) {
 			puts("   Verifying Hash Integrity ... ");
 			if (fit_config_verify(fit, cfg_noffset)) {
 				puts("Bad Data Hash\n");
include/image.h +9 -0
index 97e5f2eb24d6..98900c2e839b 100644
@@ -1173,6 +1173,15 @@ int calculate_hash(const void *data, int data_len, const char *algo,
 # define FIT_IMAGE_ENABLE_VERIFY	CONFIG_IS_ENABLED(FIT_SIGNATURE)
 #endif
 
+/*
+ * Further, allow run-time control of verification, e.g. via a jumper
+ */
+#if defined(CONFIG_FIT_RUNTIME_SIGNATURE)
+# define fit_image_require_verified()	board_fit_image_require_verified()
+#else
+# define fit_image_require_verified()	FIT_IMAGE_ENABLE_VERIFY
+#endif
+
 #ifdef USE_HOSTCC
 void *image_get_host_blob(void);
 void image_set_host_blob(void *host_blob);
Signature · 1 line
2.32.0
#1 lore raw

Hi Andrew,

I am curious about the usage scenario.
Is the runtime control required for production release?
As this control acts like a backdoor to bypass the chain-of-trust.
If it is for debugging/development purposes, should we encourage the use of unsigned images under RD environments? Beyond this, I have no concern as the patch provides more flexibility.

Quoted 37 lines

From: Andrew Jeffery <[email protected]>
Sent: Monday, January 31, 2022 11:42 AM

Some platform designs include support for disabling secure-boot via a jumper on the board. Sometimes this control can be separate from the mechanism enabling the root-of-trust for the platform. Add support for this latter scenario by allowing boards to implement board_fit_image_require_verfied(), which is then invoked in the usual FIT verification paths.

---
Hi,

This patch is extracted from and motivated by a series adding run-time control of FIT signature verification to u-boot in OpenBMC:

https://lore.kernel.org/openbmc/[email protected]/

Unfortunately the OpenBMC u-boot tree is quite a way behind on tracking upstream and contains a bunch of out-of-tree work as well. As such I'm looking to upstream the couple of changes that make sense against master.

Please take a look!

Andrew

 boot/Kconfig     |  8 ++++++++
 boot/image-fit.c | 21 +++++++++++++++++----  include/image.h  |  9
+++++++++
 3 files changed, 34 insertions(+), 4 deletions(-)
boot/Kconfig index c8d5906cd304..ec413151fd5a renamed from boot/Kconfig +0 -0

100644

boot/Kconfig +0 -0
@@ -78,6 +78,14 @@ config FIT_SIGNATURE
 	  format support in this case, enable it using

boot/Kconfig config FIT_SIGNATURE · line 88

Quoted 10 lines
boot/Kconfig +8 -0
 	  CONFIG_LEGACY_IMAGE_FORMAT.
 
+if FIT_SIGNATURE
+config FIT_RUNTIME_SIGNATURE
+	bool "Control verification of FIT uImages at runtime"
+	help
+	  This option allows board support to disable verification of
+	  signatures at runtime, for example through the state of a GPIO.
+endif # FIT_SIGNATURE
+

Using "depends on" might be preferred for Kconfig dependency.

Regards,
Chiawei

#2 lore raw
Quoted 4 lines · ChiaWei Wang

Hi Andrew,

I am curious about the usage scenario.
Is the runtime control required for production release?

Yes.

Quoted 1 line

As this control acts like a backdoor to bypass the chain-of-trust.

Right, just as strap pin controlling the SB ROM in the 2600 allows bypass.

It's just another one of these affecting a different boot stage.

Quoted 43 lines

If it is for debugging/development purposes, should we encourage the use of unsigned images under RD environments?
Beyond this, I have no concern as the patch provides more flexibility.

Quoted 39 lines

From: Andrew Jeffery <[email protected]>
Sent: Monday, January 31, 2022 11:42 AM

Some platform designs include support for disabling secure-boot via a jumper on the board. Sometimes this control can be separate from the mechanism enabling the root-of-trust for the platform. Add support for this latter scenario by allowing boards to implement board_fit_image_require_verfied(), which is then invoked in the usual FIT verification paths.

---
Hi,

This patch is extracted from and motivated by a series adding run-time control of FIT signature verification to u-boot in OpenBMC:

https://lore.kernel.org/openbmc/[email protected]/

Unfortunately the OpenBMC u-boot tree is quite a way behind on tracking upstream and contains a bunch of out-of-tree work as well. As such I'm looking to upstream the couple of changes that make sense against master.

Please take a look!

Andrew

 boot/Kconfig     |  8 ++++++++
 boot/image-fit.c | 21 +++++++++++++++++----  include/image.h  |  9
+++++++++
 3 files changed, 34 insertions(+), 4 deletions(-)
boot/Kconfig index c8d5906cd304..ec413151fd5a renamed from boot/Kconfig +0 -0

100644

boot/Kconfig +0 -0
@@ -78,6 +78,14 @@ config FIT_SIGNATURE
 	  format support in this case, enable it using
 	  CONFIG_LEGACY_IMAGE_FORMAT.
 
Quoted 10 lines

boot/Kconfig config FIT_SIGNATURE · line 88

Quoted 8 lines
boot/Kconfig +8 -0
+if FIT_SIGNATURE
+config FIT_RUNTIME_SIGNATURE
+	bool "Control verification of FIT uImages at runtime"
+	help
+	  This option allows board support to disable verification of
+	  signatures at runtime, for example through the state of a GPIO.
+endif # FIT_SIGNATURE
+

Using "depends on" might be preferred for Kconfig dependency.

Yes, that's probably better.

Thanks for taking a look.

Andrew

#3 lore raw
Quoted 3 lines · Andrew Jeffery

Right, just as strap pin controlling the SB ROM in the 2600 allows bypass.

It's just another one of these affecting a different boot stage.

Why would someone leave such external exploit open in production?
Fusing OTPCFG0[6]=1 would ignore external strap and OTPCFG0[1]=1 would enable secure boot with no way to bypass.

Regards,
Dhananjay

#4 lore raw
In reply to Andrew Jeffery
Quoted 14 lines · Andrew Jeffery

Some platform designs include support for disabling secure-boot via a jumper on the board. Sometimes this control can be separate from the mechanism enabling the root-of-trust for the platform. Add support for this latter scenario by allowing boards to implement board_fit_image_require_verfied(), which is then invoked in the usual FIT verification paths.

---
Hi,

This patch is extracted from and motivated by a series adding run-time control of FIT signature verification to u-boot in OpenBMC:

Quoted 6 lines

https://lore.kernel.org/openbmc/[email protected]/

Unfortunately the OpenBMC u-boot tree is quite a way behind on tracking upstream and contains a bunch of out-of-tree work as well. As such I'm looking to upstream the couple of changes that make sense against master.

I don't understand the practical use of a mechanism to disable security if secure boot was enabled in the first place. Sure it can be technically done, but why is this not a bad idea?

Quoted 14 lines

Please take a look!

Andrew

  boot/Kconfig     |  8 ++++++++
  boot/image-fit.c | 21 +++++++++++++++++----
  include/image.h  |  9 +++++++++
  3 files changed, 34 insertions(+), 4 deletions(-)
boot/Kconfig +0 -0
index c8d5906cd304..ec413151fd5a 100644

boot/Kconfig config FIT_SIGNATURE · line 86

Quoted 9 lines
boot/Kconfig +6 -0
@@ -78,6 +78,14 @@ config FIT_SIGNATURE
  	  format support in this case, enable it using
  	  CONFIG_LEGACY_IMAGE_FORMAT.
 
+if FIT_SIGNATURE
+config FIT_RUNTIME_SIGNATURE
+	bool "Control verification of FIT uImages at runtime"
+	help
+	  This option allows board support to disable verification of
+	  signatures at runtime, for example through the state of a GPIO.

The commit message does a much nicer job explaining this option, even though it is this kconfig help text that almost all users will ever see.

Quoted 10 lines
boot/Kconfig +2 -0
+endif # FIT_SIGNATURE
+
  config FIT_SIGNATURE_MAX_SIZE
  	hex "Max size of signed FIT structures"
  	depends on FIT_SIGNATURE
boot/image-fit.c +0 -0
index f01cafe4e277..919dbfa4ee1d 100644

boot/image-fit.c static int fit_image_check_hash(const void *fit, int noffset, const void *data, · line 1313

Quoted 6 lines
boot/image-fit.c +3 -0
@@ -1308,6 +1308,14 @@ static int fit_image_check_hash(const void *fit, int noffset, const void *data,
  	return 0;
  }
 
+#ifndef __weak
+#define __weak
+#endif

What?

boot/image-fit.c static int fit_image_check_hash(const void *fit, int noffset, const void *data, · line 1318

Quoted 5 lines
boot/image-fit.c +5 -0
+__weak int board_fit_image_require_verified(void)
+{
+	return 1;
+}
+

I caution against having any platform security related functionality as a weak function. Did I get the right function, or something else with the same name was compiled that returns 0 and silently disables security in my platform?

I think a weak function in this context is a source of confusion and future bugs. You could instead require the symbol to be defined if and only if the appropriate kconfig is selected. Symbol not defined -> compiler error. Symbol defined twice -> compiler error. Solves the issues in the preceding paragraph.

[snip]

Quoted 7 lines
include/image.h +0 -0
index 97e5f2eb24d6..98900c2e839b 100644
@@ -1173,6 +1173,15 @@ int calculate_hash(const void *data, int data_len, const char *algo,
  # define FIT_IMAGE_ENABLE_VERIFY	CONFIG_IS_ENABLED(FIT_SIGNATURE)
  #endif

include/image.h int calculate_hash(const void *data, int data_len, const char *algo, · line 1184

Quoted 10 lines
include/image.h +9 -0
 
+/*
+ * Further, allow run-time control of verification, e.g. via a jumper
+ */
+#if defined(CONFIG_FIT_RUNTIME_SIGNATURE)
+# define fit_image_require_verified()	board_fit_image_require_verified()
+#else
+# define fit_image_require_verified()	FIT_IMAGE_ENABLE_VERIFY
+#endif
+

image.h is also used for host code. When only changing target code behavior, there should be a very good reason to modify common code. I'm not convinced that threshold has been met.

My second concern here is subjective: I don't like functions defined as macros, further depending on config selections. It makes many code parsers and IDEs poop their pantaloons. It makes u-boot harder to work with as a result. I suggest finding a way to turn this into a static inline.

Alex

#5 lore raw

Hi Alex, thanks for taking a look at the patch.

Quoted 17 lines · Alex G.
Quoted 16 lines · Andrew Jeffery

Some platform designs include support for disabling secure-boot via a jumper on the board. Sometimes this control can be separate from the mechanism enabling the root-of-trust for the platform. Add support for this latter scenario by allowing boards to implement board_fit_image_require_verfied(), which is then invoked in the usual FIT verification paths.

---
Hi,

This patch is extracted from and motivated by a series adding run-time control of FIT signature verification to u-boot in OpenBMC:

https://lore.kernel.org/openbmc/[email protected]/

Quoted 8 lines
Quoted 4 lines

Unfortunately the OpenBMC u-boot tree is quite a way behind on tracking upstream and contains a bunch of out-of-tree work as well. As such I'm looking to upstream the couple of changes that make sense against master.

I don't understand the practical use of a mechanism to disable security if secure boot was enabled in the first place. Sure it can be technically done, but why is this not a bad idea?

Right, I think this question is an indication that I could write a more informative commit message, so if we converge on something acceptable I'll update it. Let me provide some more context:

As mentioned above this is motivated by use with BMCs, specifically on the ASPEED AST2600, in some specific platform contexts.

Platforms can be designed with two styles of firmware management in mind:

1. The typical approach - No owner control: Manufacturer supplied firmware with secure-boot always enabled

2. The atypical approach - Full owner control: Owner-controlled firmware with secure-boot optionally enabled

For quite a few contributing to OpenBMC, the manufacturer and the owner are the same, and so the typical approach is a good match. It probably is the use case Dhananjay was considering[1]. It also caters to the traditionally closed-source firmware ecosystem where manufacturer control is retained.

[1] https://lore.kernel.org/openbmc/[email protected]/

The second approach requires open-source firmware stacks combined with platforms designed to enable owner control. There are some ecosystems that allow this (e.g. OpenPOWER). On the host side for those systems it's possible to secure-boot them using firmware and kernels signed entirely and only by user-controlled keys. We're looking to enable this for the BMC side too, as much as we can.

For completeness (i.e. stating this to make the argument self-contained, not implying that you're unaware of it), for secure-boot to be meaningful at a given point in the boot process we need all previous elements of the boot process to have been verified. That is, it's not enough to verify u-boot if the u-boot SPL is not verified.

Where such systems use the AST2600, limitations of the AST2600 secure-boot design come into play:

3. All secure-boot configuration is held in OTP memory integrated into the SoC

4. The OTP memory must be write-protected to prevent attackers installing arbitrary keys without physical presence

5. The OTP is write-protected by configuration held in the OTP.

The consequence with respect to 2. is that the system manufacturer either must:

6. Program and write-protect the OTP during production, or

7. Ship the system with the OTP in a vulnerable state.

We figure the latter isn't desirable which means dealing with limitations of the former.

If the OTP is programmed (with the required public keys) and write-protected by the manufacturer, then when configured as a secure-boot root-of-trust, the AST2600 must only boot an SPL image signed by the manufacturer. From here there are two options for owner control:

8. The manufacturer signs arbitrary SPLs upon request. This requires trust from both parties and potentially a lot of auditing focus from the manufacturer.

9. The manufacturer publishes the source for the signed u-boot SPL binary in a fashion that allows reproducible builds for verification by inspection. Firmware signed by owner-controlled keys can only be applied beyond this boot stage.

Despite the compromise, the latter approach seems to be the most reasonable in the circumstances.

Again for completeness, broadly, security can be divided into two categories:

10. Software security
11. Physical security

Controlling secure-boot in a way that requires physical presence rules out the ability to influence the boot process via (remote) software attacks. This is beneficial. The approach at the platform level does not yet solve for physical security, however given this is motivated by use on BMCs, physical security concerns could be viewed as taken care of in the sense that the systems are likely installed in a datacenter or some other controlled environment.

With that in mind:

To escape the manufacturer's key-chain for owner-controlled signatures the concept is the manufacturer-signed SPL (or u-boot payload) will load keys from an external, write-protected EEPROM. These keys are used to verify the next element of the boot process, providing user control.

To configure owner-controlled keys the EEPROM write-protect must be disabled. This may, for example, be done via a physical jumper. If left with write-protection disabled the matching public key for the signature on the payload can arbitrarily be installed into the EEPROM which makes secure-boot verification moot. The patch avoids the run-around in this last behaviour by providing a platform hook to read the state of what is effectively the EEPROM write-protect pin.

Quoted 18 lines
Quoted 18 lines

Please take a look!

Andrew

  boot/Kconfig     |  8 ++++++++
  boot/image-fit.c | 21 +++++++++++++++++----
  include/image.h  |  9 +++++++++
  3 files changed, 34 insertions(+), 4 deletions(-)
boot/Kconfig +0 -0
index c8d5906cd304..ec413151fd5a 100644
@@ -78,6 +78,14 @@ config FIT_SIGNATURE
  	  format support in this case, enable it using
  	  CONFIG_LEGACY_IMAGE_FORMAT.
 
Quoted 9 lines

boot/Kconfig config FIT_SIGNATURE · line 86

Quoted 6 lines
boot/Kconfig +6 -0
+if FIT_SIGNATURE
+config FIT_RUNTIME_SIGNATURE
+	bool "Control verification of FIT uImages at runtime"
+	help
+	  This option allows board support to disable verification of
+	  signatures at runtime, for example through the state of a GPIO.

The commit message does a much nicer job explaining this option, even though it is this kconfig help text that almost all users will ever see.

I'll fix this once we finish up on the discussion above.

Quoted 14 lines
Quoted 14 lines
boot/Kconfig +2 -0
+endif # FIT_SIGNATURE
+
  config FIT_SIGNATURE_MAX_SIZE
  	hex "Max size of signed FIT structures"
  	depends on FIT_SIGNATURE
boot/image-fit.c +0 -0
index f01cafe4e277..919dbfa4ee1d 100644
@@ -1308,6 +1308,14 @@ static int fit_image_check_hash(const void *fit, int noffset, const void *data,
  	return 0;
  }
 
Quoted 5 lines

boot/image-fit.c static int fit_image_check_hash(const void *fit, int noffset, const void *data, · line 1313

Quoted 3 lines
boot/image-fit.c +3 -0
+#ifndef __weak
+#define __weak
+#endif

What?

boot/image-fit.c is built by the tools as well as into the u-boot{,-spl} images, but __weak is only defined when __KERNEL__ is defined, which is not how the tools are compiled.

This is a bit of hack but if I resolve your concern about using weak symbols below then this goes away.

Quoted 12 lines

boot/image-fit.c static int fit_image_check_hash(const void *fit, int noffset, const void *data, · line 1318

Quoted 6 lines
boot/image-fit.c +5 -0
+__weak int board_fit_image_require_verified(void)
+{
+	return 1;
+}
+

I caution against having any platform security related functionality as a weak function. Did I get the right function, or something else with the same name was compiled that returns 0 and silently disables security in my platform?

Quoted 5 lines

I think a weak function in this context is a source of confusion and future bugs. You could instead require the symbol to be defined if and only if the appropriate kconfig is selected. Symbol not defined -> compiler error. Symbol defined twice -> compiler error. Solves the issues in the preceding paragraph.

Okay.

Quoted 11 lines

[snip]

Quoted 8 lines
include/image.h +0 -0
index 97e5f2eb24d6..98900c2e839b 100644
@@ -1173,6 +1173,15 @@ int calculate_hash(const void *data, int data_len, const char *algo,
  # define FIT_IMAGE_ENABLE_VERIFY	CONFIG_IS_ENABLED(FIT_SIGNATURE)
  #endif
 
Quoted 13 lines

include/image.h int calculate_hash(const void *data, int data_len, const char *algo, · line 1184

Quoted 9 lines
include/image.h +9 -0
+/*
+ * Further, allow run-time control of verification, e.g. via a jumper
+ */
+#if defined(CONFIG_FIT_RUNTIME_SIGNATURE)
+# define fit_image_require_verified()	board_fit_image_require_verified()
+#else
+# define fit_image_require_verified()	FIT_IMAGE_ENABLE_VERIFY
+#endif
+

image.h is also used for host code. When only changing target code behavior, there should be a very good reason to modify common code. I'm not convinced that threshold has been met.

I guess I could move it into boot/image-fit.c as that's the only user, but given its role that too doesn't really address your concern :)

Joel had related comments on the patch on the OpenBMC list[2]

[2] https://lore.kernel.org/openbmc/CACPK8XcY=afrQ9bE2A3q1tC8Hhxmx3oVM7k_C_fVoYGbLJ4OUg@mail.gmail.com/

How do you propose I add target-specific behaviour? Or is the patch just a non-starter? As mentioned above, moving the behaviour to boot/image-fit.c doesn't address this concern.

Quoted 5 lines

My second concern here is subjective: I don't like functions defined as macros, further depending on config selections. It makes many code parsers and IDEs poop their pantaloons. It makes u-boot harder to work with as a result. I suggest finding a way to turn this into a static inline.

That's fine, I'm not wedded to the approach so happy to clean it up.

I was trying to make sure the change had no impact on code generation with CONFIG_FIT_RUNTIME_SIGNATURE=n without relying too much on the optimiser to clean things up. I'll reassess what I've done to see if we can get a decent outcome both ways.

Andrew

#6 lore raw
Quoted 82 lines · Andrew Jeffery

Right, I think this question is an indication that I could write a more informative commit message, so if we converge on something acceptable I'll update it. Let me provide some more context:

As mentioned above this is motivated by use with BMCs, specifically on the ASPEED AST2600, in some specific platform contexts.

Platforms can be designed with two styles of firmware management in mind:

1. The typical approach - No owner control: Manufacturer supplied firmware with secure-boot always enabled

2. The atypical approach - Full owner control: Owner-controlled firmware with secure-boot optionally enabled

For quite a few contributing to OpenBMC, the manufacturer and the owner are the same, and so the typical approach is a good match. It probably is the use case Dhananjay was considering[1]. It also caters to the traditionally closed-source firmware ecosystem where manufacturer control is retained.

[1]https://lore.kernel.org/openbmc/[email protected]/

The second approach requires open-source firmware stacks combined with platforms designed to enable owner control. There are some ecosystems that allow this (e.g. OpenPOWER). On the host side for those systems it's possible to secure-boot them using firmware and kernels signed entirely and only by user-controlled keys. We're looking to enable this for the BMC side too, as much as we can.

For completeness (i.e. stating this to make the argument self-contained, not implying that you're unaware of it), for secure-boot to be meaningful at a given point in the boot process we need all previous elements of the boot process to have been verified. That is, it's not enough to verify u-boot if the u-boot SPL is not verified.

Where such systems use the AST2600, limitations of the AST2600 secure-boot design come into play:

3. All secure-boot configuration is held in OTP memory integrated into the SoC

4. The OTP memory must be write-protected to prevent attackers installing arbitrary keys without physical presence

5. The OTP is write-protected by configuration held in the OTP.

The consequence with respect to 2. is that the system manufacturer either must:

6. Program and write-protect the OTP during production, or

7. Ship the system with the OTP in a vulnerable state.

We figure the latter isn't desirable which means dealing with limitations of the former.

If the OTP is programmed (with the required public keys) and write-protected by the manufacturer, then when configured as a secure-boot root-of-trust, the AST2600 must only boot an SPL image signed by the manufacturer. From here there are two options for owner control:

8. The manufacturer signs arbitrary SPLs upon request. This requires trust from both parties and potentially a lot of auditing focus from the manufacturer.

9. The manufacturer publishes the source for the signed u-boot SPL binary in a fashion that allows reproducible builds for verification by inspection. Firmware signed by owner-controlled keys can only be applied beyond this boot stage.

Despite the compromise, the latter approach seems to be the most reasonable in the circumstances.

Again for completeness, broadly, security can be divided into two categories:

10. Software security
11. Physical security

Quoted 7 lines

Controlling secure-boot in a way that requires physical presence rules out the ability to influence the boot process via (remote) software attacks. This is beneficial. The approach at the platform level does not yet solve for physical security, however given this is motivated by use on BMCs, physical security concerns could be viewed as taken care of in the sense that the systems are likely installed in a datacenter or some other controlled environment.

We can decouple HW RoT and runtime control on enforcing secure boot (requiring one or keys) on FIT image. Conflating two raises lot of questions.

There's not much case for disabling HW RoT, which implies the bootloader (U-Boot or more) has to be trusted after board is manufactured (OTPstraps, especially OTPCFG0[6], are programmed).

There's indeed a case for disabling secure boot on OS FIT image -
If bootloader is trusted, it's possible to remotely push the policy to
disable runtime FIT image secure boot. Such policy push must use secure transport (someway authenticated) and storage (simplest U-Boot env). This is helpful in cases like booting diagnostic images if board has to
be RMA'ed and diagnostic images won't be signed by production keys.

There's a key-requirement policy already implemented [1].

[1] https://lore.kernel.org/u-boot/[email protected]/

Board code can patch "required-policy" = none at runtime based appropriate logic.

Regards,
Dhananjay

Quoted 15 lines

With that in mind:

To escape the manufacturer's key-chain for owner-controlled signatures the concept is the manufacturer-signed SPL (or u-boot payload) will load keys from an external, write-protected EEPROM. These keys are used to verify the next element of the boot process, providing user control.

To configure owner-controlled keys the EEPROM write-protect must be disabled. This may, for example, be done via a physical jumper. If left with write-protection disabled the matching public key for the signature on the payload can arbitrarily be installed into the EEPROM which makes secure-boot verification moot. The patch avoids the run-around in this last behaviour by providing a platform hook to read the state of what is effectively the EEPROM write-protect pin.

#7 lore raw
Quoted 91 lines · Dhananjay Phadke
Quoted 82 lines · Andrew Jeffery

Right, I think this question is an indication that I could write a more informative commit message, so if we converge on something acceptable I'll update it. Let me provide some more context:

As mentioned above this is motivated by use with BMCs, specifically on the ASPEED AST2600, in some specific platform contexts.

Platforms can be designed with two styles of firmware management in mind:

1. The typical approach - No owner control: Manufacturer supplied firmware with secure-boot always enabled

2. The atypical approach - Full owner control: Owner-controlled firmware with secure-boot optionally enabled

For quite a few contributing to OpenBMC, the manufacturer and the owner are the same, and so the typical approach is a good match. It probably is the use case Dhananjay was considering[1]. It also caters to the traditionally closed-source firmware ecosystem where manufacturer control is retained.

[1]https://lore.kernel.org/openbmc/[email protected]/

The second approach requires open-source firmware stacks combined with platforms designed to enable owner control. There are some ecosystems that allow this (e.g. OpenPOWER). On the host side for those systems it's possible to secure-boot them using firmware and kernels signed entirely and only by user-controlled keys. We're looking to enable this for the BMC side too, as much as we can.

For completeness (i.e. stating this to make the argument self-contained, not implying that you're unaware of it), for secure-boot to be meaningful at a given point in the boot process we need all previous elements of the boot process to have been verified. That is, it's not enough to verify u-boot if the u-boot SPL is not verified.

Where such systems use the AST2600, limitations of the AST2600 secure-boot design come into play:

3. All secure-boot configuration is held in OTP memory integrated into the SoC

4. The OTP memory must be write-protected to prevent attackers installing arbitrary keys without physical presence

5. The OTP is write-protected by configuration held in the OTP.

The consequence with respect to 2. is that the system manufacturer either must:

6. Program and write-protect the OTP during production, or

7. Ship the system with the OTP in a vulnerable state.

We figure the latter isn't desirable which means dealing with limitations of the former.

If the OTP is programmed (with the required public keys) and write-protected by the manufacturer, then when configured as a secure-boot root-of-trust, the AST2600 must only boot an SPL image signed by the manufacturer. From here there are two options for owner control:

8. The manufacturer signs arbitrary SPLs upon request. This requires trust from both parties and potentially a lot of auditing focus from the manufacturer.

9. The manufacturer publishes the source for the signed u-boot SPL binary in a fashion that allows reproducible builds for verification by inspection. Firmware signed by owner-controlled keys can only be applied beyond this boot stage.

Despite the compromise, the latter approach seems to be the most reasonable in the circumstances.

Again for completeness, broadly, security can be divided into two categories:

10. Software security
11. Physical security

Quoted 7 lines

Controlling secure-boot in a way that requires physical presence rules out the ability to influence the boot process via (remote) software attacks. This is beneficial. The approach at the platform level does not yet solve for physical security, however given this is motivated by use on BMCs, physical security concerns could be viewed as taken care of in the sense that the systems are likely installed in a datacenter or some other controlled environment.

Quoted 3 lines

We can decouple HW RoT and runtime control on enforcing secure boot (requiring one or keys) on FIT image. Conflating two raises lot of questions.

Right. They are decoupled. What I'm proposing in the patch only affects FIT verification.

Cheers,

Andrew

#8 lore raw
In reply to Dhananjay Phadke
Quoted 5 lines · Dhananjay Phadke

On 2/13/2022 5:13 PM, Andrew Jeffery wrote:

We can decouple HW RoT and runtime control on enforcing secure boot (requiring one or keys) on FIT image. Conflating two raises lot of questions.

I won't claim to be a security expert but I don't understand this statement. What are the "lots of questions" that are raised?

Quoted 5 lines

There's not much case for disabling HW RoT, which implies the bootloader (U-Boot or more) has to be trusted after board is manufactured (OTPstraps, especially OTPCFG0[6], are programmed).

There's indeed a case for disabling secure boot on OS FIT image -

Why wouldn't you want to replace the bootloader just as easily as you can replace the kernel / OS itself? I don't understand why this is more special than any other software. Bootloaders are replaced on "real" systems all the time. There are multiple efforts to be able to replace BIOS/UEFI with a free implementation as well.

I would consider the "HW RoT" to be the software in ROMs and not anything which can be replaced, like u-boot. Why are you extending it to include u-boot?

Quoted 5 lines

If bootloader is trusted, it's possible to remotely push the policy to disable runtime FIT image secure boot. Such policy push must use secure transport (someway authenticated) and storage (simplest U-Boot env). This is helpful in cases like booting diagnostic images if board has to be RMA'ed and diagnostic images won't be signed by production keys.

For second-hand / recycled hardware, I'm not sure the bootloader _is_ trusted. It is also possible that I punt on some aspects of supply-chain security and simply replace it all when it arrives in my hands. ie. If I can securely replace all the bits, I really don't care if it was tampered with in transit.

Quoted 26 lines

There's a key-requirement policy already implemented [1].

[1]
https://lore.kernel.org/u-boot/[email protected]/

Board code can patch "required-policy" = none at runtime based appropriate logic.

Regards,
Dhananjay

Quoted 15 lines

With that in mind:

To escape the manufacturer's key-chain for owner-controlled signatures the concept is the manufacturer-signed SPL (or u-boot payload) will load keys from an external, write-protected EEPROM. These keys are used to verify the next element of the boot process, providing user control.

To configure owner-controlled keys the EEPROM write-protect must be disabled. This may, for example, be done via a physical jumper. If left with write-protection disabled the matching public key for the signature on the payload can arbitrarily be installed into the EEPROM which makes secure-boot verification moot. The patch avoids the run-around in this last behaviour by providing a platform hook to read the state of what is effectively the EEPROM write-protect pin.

Isn't this jumper proposal just like the TCG Physical Presence requirements? This is a software implementation and requires a particular hardware design for it to be done right, but it seems to be along the same lines.

Signature · 1 line
Patrick Williams
#9 lore raw
Quoted 9 lines · Patrick Williams
Quoted 5 lines · Dhananjay Phadke

On 2/13/2022 5:13 PM, Andrew Jeffery wrote:

We can decouple HW RoT and runtime control on enforcing secure boot (requiring one or keys) on FIT image. Conflating two raises lot of questions.

I won't claim to be a security expert but I don't understand this statement. What are the "lots of questions" that are raised?

I was trying to avoid derailing the review with this, but here we are.

I have the same question as Patrick. What are your concerns here?

Quoted 16 lines
Quoted 8 lines
Quoted 8 lines

With that in mind:

To escape the manufacturer's key-chain for owner-controlled signatures the concept is the manufacturer-signed SPL (or u-boot payload) will load keys from an external, write-protected EEPROM. These keys are used to verify the next element of the boot process, providing user control.

Quoted 7 lines
Quoted 7 lines

To configure owner-controlled keys the EEPROM write-protect must be disabled. This may, for example, be done via a physical jumper. If left with write-protection disabled the matching public key for the signature on the payload can arbitrarily be installed into the EEPROM which makes secure-boot verification moot. The patch avoids the run-around in this last behaviour by providing a platform hook to read the state of what is effectively the EEPROM write-protect pin.

Quoted 3 lines

Isn't this jumper proposal just like the TCG Physical Presence requirements? This is a software implementation and requires a particular hardware design for it to be done right, but it seems to be along the same lines.

Possibly. I'll defer to Chris on that.

Andrew

#10 lore raw
In reply to Patrick Williams
Quoted 16 lines · Patrick Williams
Quoted 5 lines · Dhananjay Phadke

On 2/13/2022 5:13 PM, Andrew Jeffery wrote:

We can decouple HW RoT and runtime control on enforcing secure boot (requiring one or keys) on FIT image. Conflating two raises lot of questions.

I won't claim to be a security expert but I don't understand this statement. What are the "lots of questions" that are raised?

Quoted 5 lines

There's not much case for disabling HW RoT, which implies the bootloader (U-Boot or more) has to be trusted after board is manufactured (OTPstraps, especially OTPCFG0[6], are programmed).

There's indeed a case for disabling secure boot on OS FIT image -

Quoted 8 lines

Why wouldn't you want to replace the bootloader just as easily as you can replace the kernel / OS itself? I don't understand why this is more special than any other software. Bootloaders are replaced on "real" systems all the time. There are multiple efforts to be able to replace BIOS/UEFI with a free implementation as well.

I would consider the "HW RoT" to be the software in ROMs and not anything which can be replaced, like u-boot. Why are you extending it to include u-boot?

Agree that ROM maybe just immutable code + some logic, but almost surely lacks high level stack e.g. network stack to communicate securely and change boot behavior (remote unlock).

Bootloader (U-Boot in Aspeed case) happens to be the first component with rich stack to enable such workflows without / before physical intervention.

It also means, for defense against physical attacks (e.g. replace boot SPI), first mutable component (bootloader) must be trusted by immutable component earlier in boot chain. Further secure boot chain may have its own control knobs from compile or runtime.

Quoted 20 lines
Quoted 6 lines

If bootloader is trusted, it's possible to remotely push the policy to disable runtime FIT image secure boot. Such policy push must use secure transport (someway authenticated) and storage (simplest U-Boot env). This is helpful in cases like booting diagnostic images if board has to be RMA'ed and diagnostic images won't be signed by production keys.

For second-hand / recycled hardware, I'm not sure the bootloader _is_ trusted. It is also possible that I punt on some aspects of supply-chain security and simply replace it all when it arrives in my hands. ie. If I can securely replace all the bits, I really don't care if it was tampered with in transit.

Quoted 8 lines

There's a key-requirement policy already implemented [1].

[1]
https://lore.kernel.org/u-boot/[email protected]/

Board code can patch "required-policy" = none at runtime based appropriate logic.

[...]

Quoted 4 lines

Isn't this jumper proposal just like the TCG Physical Presence requirements? This is a software implementation and requires a particular hardware design for it to be done right, but it seems to be along the same lines.

I'm supporting idea of having control on FIT verification, just pointed that it maybe done by board code by just patching U-Boot control FDT, either the "required-policy" property at /signature or "required" property in individual key nodes.

Regards,
Dhananjay

#11 lore raw
Quoted 14 lines · Dhananjay Phadke
Quoted 9 lines · Patrick Williams
Quoted 8 lines · Dhananjay Phadke

There's a key-requirement policy already implemented [1].

[1]
https://lore.kernel.org/u-boot/[email protected]/

Board code can patch "required-policy" = none at runtime based appropriate logic.

[...]

Quoted 1 line
Quoted 8 lines
Quoted 3 lines

Isn't this jumper proposal just like the TCG Physical Presence requirements? This is a software implementation and requires a particular hardware design for it to be done right, but it seems to be along the same lines.

I'm supporting idea of having control on FIT verification, just pointed that it maybe done by board code by just patching U-Boot control FDT, either the "required-policy" property at /signature or "required" property in individual key nodes.

This might separate the logic out in a way that's acceptable to Alex.

Let me poke at it.

Thanks,

Andrew

#12 lore raw
Quoted 19 lines · Andrew Jeffery
Quoted 18 lines · Dhananjay Phadke
Quoted 9 lines · Patrick Williams
Quoted 8 lines · Dhananjay Phadke

There's a key-requirement policy already implemented [1].

[1]
https://lore.kernel.org/u-boot/[email protected]/

Board code can patch "required-policy" = none at runtime based appropriate logic.

[...]

Quoted 4 lines

Isn't this jumper proposal just like the TCG Physical Presence requirements? This is a software implementation and requires a particular hardware design for it to be done right, but it seems to be along the same lines.

Quoted 8 lines
Quoted 4 lines

I'm supporting idea of having control on FIT verification, just pointed that it maybe done by board code by just patching U-Boot control FDT, either the "required-policy" property at /signature or "required" property in individual key nodes.

This might separate the logic out in a way that's acceptable to Alex.

Let me poke at it.

I've thought about this some more and adding support for required-mode = "none"; or similar seems like a massive footgun given that (as I understand it) the FIT image as a whole isn't verified. Only supporting "all" or "any" seems okay because some verification must succeed in the context of the keys available in the current stage.

After some internal discussion this effort has been set aside so I'm not going to pursue it further for the moment. I don't think it's easy to proceed anyway without feedback from Alex.

Andrew

#13 lore raw
Quoted 37 lines · Andrew Jeffery
Quoted 19 lines · Andrew Jeffery
Quoted 18 lines · Dhananjay Phadke
Quoted 9 lines · Patrick Williams
Quoted 8 lines · Dhananjay Phadke

There's a key-requirement policy already implemented [1].

[1]
https://lore.kernel.org/u-boot/[email protected]/

Board code can patch "required-policy" = none at runtime based appropriate logic.

[...]

Quoted 4 lines

Isn't this jumper proposal just like the TCG Physical Presence requirements? This is a software implementation and requires a particular hardware design for it to be done right, but it seems to be along the same lines.

Quoted 8 lines
Quoted 4 lines

I'm supporting idea of having control on FIT verification, just pointed that it maybe done by board code by just patching U-Boot control FDT, either the "required-policy" property at /signature or "required" property in individual key nodes.

This might separate the logic out in a way that's acceptable to Alex.

Let me poke at it.

I've thought about this some more and adding support for required-mode = "none"; or similar seems like a massive footgun given that (as I understand it) the FIT image as a whole isn't verified. Only supporting "all" or "any" seems okay because some verification must succeed in the context of the keys available in the current stage.

Quoted 3 lines

After some internal discussion this effort has been set aside so I'm not going to pursue it further for the moment. I don't think it's easy to proceed anyway without feedback from Alex.

Don't let my thoughts stop you. I don't think there is a perfect way to address this situation, and we don't have to. Code can be changed later.

As a general preference, I would like to see a single decision point on whether to verify/skip. It can be changing `required-mode = "none", or any other similar solution. Keep in mind that the FIT is the image you're trying to authenticate. It is completely different from "required-mode", which is part of u-boot's or SPL's embedded dtb.

Alex

#14 lore raw
Quoted 42 lines · Alex G.
Quoted 37 lines · Andrew Jeffery
Quoted 19 lines · Andrew Jeffery
Quoted 18 lines · Dhananjay Phadke
Quoted 9 lines · Patrick Williams
Quoted 8 lines · Dhananjay Phadke

There's a key-requirement policy already implemented [1].

[1]
https://lore.kernel.org/u-boot/[email protected]/

Board code can patch "required-policy" = none at runtime based appropriate logic.

[...]

Quoted 4 lines

Isn't this jumper proposal just like the TCG Physical Presence requirements? This is a software implementation and requires a particular hardware design for it to be done right, but it seems to be along the same lines.

Quoted 8 lines
Quoted 4 lines

I'm supporting idea of having control on FIT verification, just pointed that it maybe done by board code by just patching U-Boot control FDT, either the "required-policy" property at /signature or "required" property in individual key nodes.

This might separate the logic out in a way that's acceptable to Alex.

Let me poke at it.

I've thought about this some more and adding support for required-mode = "none"; or similar seems like a massive footgun given that (as I understand it) the FIT image as a whole isn't verified. Only supporting "all" or "any" seems okay because some verification must succeed in the context of the keys available in the current stage.

Quoted 3 lines

After some internal discussion this effort has been set aside so I'm not going to pursue it further for the moment. I don't think it's easy to proceed anyway without feedback from Alex.

Quoted 8 lines

Don't let my thoughts stop you. I don't think there is a perfect way to address this situation, and we don't have to. Code can be changed later.

As a general preference, I would like to see a single decision point on whether to verify/skip. It can be changing `required-mode = "none", or any other similar solution. Keep in mind that the FIT is the image you're trying to authenticate. It is completely different from "required-mode", which is part of u-boot's or SPL's embedded dtb.

Ah yes, I wasn't thinking of it that way, so maybe it could work. I'll consider it all again, but we also determined that we could get away without this functionality for now anyway.

Andrew