uboot-sign: Fix u-boot dtb signatures
CC everyone from the original bug report
Am Donnerstag, dem 20.02.2025 um 15:40 +0100 schrieb Leonard Anderweit via lists.openembedded.org:
Quoted 102 lines
With
UBOOT_SIGN_ENABLEenabled commit3fb215a3af24(u-boot:
kernel-fitimage: Fix dependency loop ifUBOOT_SIGN_ENABLEandUBOOT_ENV
enabled) always adds the signature ofUBOOT_SIGN_IMG_KEYNAMEto the u-boot dtb, independent ofFIT_SIGN_INDIVIDUAL. The kernel fitimage configuration node is signed withUBOOT_SIGN_KEYNAMEbut the u-boot dtb
contains the signature ofUBOOT_SIGN_IMG_KEYNAME. U-boot is therefore unable to verify the signed kernel fitimage.
Before that commit the signature of all keys used in the kernel fitimage
would be added to the u-boot dtb.To fix this, always add the signature of
UBOOT_SIGN_KEYNAMEfor configuration nodes to the u-boot dtb. IfFIT_SIGN_INDIVIDUALis 1 also
add the signature ofUBOOT_SIGN_IMG_KEYNAMEfor individual images.This has one drawback at the moment: The signing of individual images is
not tested withfit_check_signduringconcat_dtb.Fixes 3fb215a3af24 (u-boot: kernel-fitimage: Fix dependency loop if
UBOOT_SIGN_ENABLEandUBOOT_ENVenabled)Reported-by Rogerio Guerra Borin <[email protected]>Signed-off-by Leonard Anderweit <[email protected]>---
Link to bug report:
https://lists.openembedded.org/g/openembedded-core/topic/111218371#msg211507
---
meta/classes-recipe/uboot-sign.bbclass | 26 ++++++++++++++++++------ --1 file changed, 18 insertions(+), 8 deletions(-)meta/classes- renamed from meta/classes-recipe/uboot-sign.bbclass +0
-0recipe/uboot-sign.bbclass
index96c47ab01651..b2fcb5a31546100644meta/classes-recipe/uboot-sign.bbclass +0
-0@@ -102,26 +102,36 @@ concat_dtb() {
if [ -e "${UBOOT_DTB_BINARY}" ]; then
# Re-sign the kernel in order to add the keys to our dtb
- UBOOT_MKIMAGE_MODE="auto-conf"
- # Signing individual images is not recommended as that
- # makes fitImage susceptible to mix-and-match attack. - if [ "${FIT_SIGN_INDIVIDUAL}" = "1" ] ; then - UBOOT_MKIMAGE_MODE="auto"
- fi
${UBOOT_MKIMAGE_SIGN} \
${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' iflen('${UBOOT_MKIMAGE_DTCOPTS}')else ''} \
- -f $UBOOT_MKIMAGE_MODE \
+ -f auto-conf \
-k "${UBOOT_SIGN_KEYDIR}" \
-o "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \
- -g "${UBOOT_SIGN_IMG_KEYNAME}" \
+ -g "${UBOOT_SIGN_KEYNAME}" \
-K "${UBOOT_DTB_BINARY}" \
-d/dev/null\
-r ${B}/unused.itb \
${UBOOT_MKIMAGE_SIGN_ARGS}
+
# Verify the kernel image and u-boot dtb ${UBOOT_FIT_CHECK_SIGN} \
-k "${UBOOT_DTB_BINARY}" \
-f ${B}/unused.itb
+
+ # Signing individual images is not recommended as that
+ # makes fitImage susceptible to mix-and-match attack. + if [ "${FIT_SIGN_INDIVIDUAL}" = "1" ] ; then + ${UBOOT_MKIMAGE_SIGN} \
+ ${@'-D "${UBOOT_MKIMAGE_DTCOPTS}"' iflen('${UBOOT_MKIMAGE_DTCOPTS}')else ''} \
+ -f auto \
+ -k "${UBOOT_SIGN_KEYDIR}" \
+ -o "${FIT_HASH_ALG},${FIT_SIGN_ALG}" \
+ -g "${UBOOT_SIGN_IMG_KEYNAME}" \
+ -K "${UBOOT_DTB_BINARY}" \
+ -d/dev/null\
+ -r ${B}/unused.itb \
+ ${UBOOT_MKIMAGE_SIGN_ARGS} + fi
cp ${UBOOT_DTB_BINARY} ${UBOOT_DTB_SIGNED} fi-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#211761):
https://lists.openembedded.org/g/openembedded-core/message/211761
Mute This Topic: https://lists.openembedded.org/mt/111289801/7270266
Group Owner: [email protected] Unsubscribe:
https://lists.openembedded.org/g/openembedded-core/unsub [
[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-