Skip to contentSkip to conversation

EFI: update the documentation to correctly order loading SB keys

PATCH In review [email protected] 2 participants 4 messages Nov 25, 2022 – Nov 28, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 EFI: update the documentation to correctly order loading SB keys

From: Luca Boccassi <[email protected]>

Loading the PK locks down the EFI variables, so it needs to be done last. Fix the order in the documentation and add a note.

---
 doc/develop/uefi/uefi.rst | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
doc/develop/uefi/uefi.rst +8 -4
index e0835beba4..68a0bb6832 100644
@@ -169,12 +169,16 @@ Sign an image with one of the keys in "db" on your host
 
 Now in U-Boot install the keys on your board::
 
-    fatload mmc 0:1 <tmpaddr> PK.auth
-    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
-    fatload mmc 0:1 <tmpaddr> KEK.auth
-    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK
     fatload mmc 0:1 <tmpaddr> db.auth
     setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize db
+    fatload mmc 0:1 <tmpaddr> KEK.auth
+    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK
+    fatload mmc 0:1 <tmpaddr> PK.auth
+    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
+
+Note that loading a key into PK automatically enables Secure Boot, and further
+unsigned updates of secure EFI variables will no longer be allowed, so PK should
+be loaded last.
 
 Set up boot parameters on your board::
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · On Fri, Nov 25, 2022 at 01:30:11PM +0000, [email protected] wrote:

From: Luca Boccassi <[email protected]>

Loading the PK locks down the EFI variables, so it needs to be done last.

No, it's not (always) correct.

Quoted 19 lines

Fix the order in the documentation and add a note.

---
 doc/develop/uefi/uefi.rst | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
doc/develop/uefi/uefi.rst +0 -4
index e0835beba4..68a0bb6832 100644
@@ -169,12 +169,16 @@ Sign an image with one of the keys in "db" on your host
 
 Now in U-Boot install the keys on your board::
 
-    fatload mmc 0:1 <tmpaddr> PK.auth
-    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
-    fatload mmc 0:1 <tmpaddr> KEK.auth
-    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK

doc/develop/uefi/uefi.rst Sign an image with one of the keys in "db" on your host · line 181

Quoted 10 lines
doc/develop/uefi/uefi.rst +8 -0
     fatload mmc 0:1 <tmpaddr> db.auth
     setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize db
+    fatload mmc 0:1 <tmpaddr> KEK.auth
+    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK
+    fatload mmc 0:1 <tmpaddr> PK.auth
+    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
+
+Note that loading a key into PK automatically enables Secure Boot, and further
+unsigned updates of secure EFI variables will no longer be allowed, so PK should
+be loaded last.

KEK.auth and db.auth are created by sign-efi-sig-list command (with valid keys) and contain authentication headers necessary for signature verification.
So the original sequence works perfectly.

-Takahiro Akashi

Quoted 5 lines
doc/develop/uefi/uefi.rst +0 -0
 Set up boot parameters on your board::
 
Signature · 1 line
2.34.1
#2 lore raw
Quoted 34 lines · AKASHI Takahiro
Quoted 3 lines · On Fri, Nov 25, 2022 at 01:30:11PM +0000, [email protected] wrote:

From: Luca Boccassi <[email protected]>

Loading the PK locks down the EFI variables, so it needs to be done last.

No, it's not (always) correct.

Quoted 26 lines

Fix the order in the documentation and add a note.

---
 doc/develop/uefi/uefi.rst | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
doc/develop/uefi/uefi.rst +5 -4
index e0835beba4..68a0bb6832 100644
@@ -169,12 +169,16 @@ Sign an image with one of the keys in "db" on your host
 
 Now in U-Boot install the keys on your board::
 
-    fatload mmc 0:1 <tmpaddr> PK.auth
-    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
-    fatload mmc 0:1 <tmpaddr> KEK.auth
-    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK
     fatload mmc 0:1 <tmpaddr> db.auth
     setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize db
+    fatload mmc 0:1 <tmpaddr> KEK.auth
+    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK
+    fatload mmc 0:1 <tmpaddr> PK.auth
+    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
+
Quoted 8 lines

doc/develop/uefi/uefi.rst Sign an image with one of the keys in "db" on your host · line 181

Quoted 3 lines
doc/develop/uefi/uefi.rst +3 -0
+Note that loading a key into PK automatically enables Secure Boot, and further
+unsigned updates of secure EFI variables will no longer be allowed, so PK should
+be loaded last.

KEK.auth and db.auth are created by sign-efi-sig-list command (with valid keys) and contain authentication headers necessary for signature verification.
So the original sequence works perfectly.

In theory. In practice u-boot (both 2022.07 and 2022.10 in qemu) refused to allow setting those variables after PK is set, which made me waste an unnecessary amount of time. Otherwise I wouldn't have bothered sending this...

Kind regards,
Luca Boccassi

#3 lore raw
Quoted 45 lines · Luca Boccassi
Quoted 34 lines · AKASHI Takahiro
Quoted 3 lines · On Fri, Nov 25, 2022 at 01:30:11PM +0000, [email protected] wrote:

From: Luca Boccassi <[email protected]>

Loading the PK locks down the EFI variables, so it needs to be done last.

No, it's not (always) correct.

Quoted 26 lines

Fix the order in the documentation and add a note.

---
 doc/develop/uefi/uefi.rst | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
doc/develop/uefi/uefi.rst +5 -4
index e0835beba4..68a0bb6832 100644
@@ -169,12 +169,16 @@ Sign an image with one of the keys in "db" on your host
 
 Now in U-Boot install the keys on your board::
 
-    fatload mmc 0:1 <tmpaddr> PK.auth
-    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
-    fatload mmc 0:1 <tmpaddr> KEK.auth
-    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK
     fatload mmc 0:1 <tmpaddr> db.auth
     setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize db
+    fatload mmc 0:1 <tmpaddr> KEK.auth
+    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize KEK
+    fatload mmc 0:1 <tmpaddr> PK.auth
+    setenv -e -nv -bs -rt -at -i <tmpaddr>:$filesize PK
+
Quoted 8 lines

doc/develop/uefi/uefi.rst Sign an image with one of the keys in "db" on your host · line 181

Quoted 3 lines
doc/develop/uefi/uefi.rst +3 -0
+Note that loading a key into PK automatically enables Secure Boot, and further
+unsigned updates of secure EFI variables will no longer be allowed, so PK should
+be loaded last.

KEK.auth and db.auth are created by sign-efi-sig-list command (with valid keys) and contain authentication headers necessary for signature verification.
So the original sequence works perfectly.

Quoted 4 lines

In theory. In practice u-boot (both 2022.07 and 2022.10 in qemu) refused to allow setting those variables after PK is set, which made me waste an unnecessary amount of time. Otherwise I wouldn't have bothered sending this...

I re-ran my test_efi_secboot test on v2022.10 with sandbox_defconfig and didn't see any error.
(Test case 1 verified that we could install PK, KEK and db in this order.)

If you see this kind of error, it's likely that you have wrong configuration.
If you're not sure, please describe what you did and saw in details.

-Takahiro Akashi

Quoted 2 lines

Kind regards,
Luca Boccassi