| Summary: | Public key for U-Boot verified boot is not inserted in DTB when rebuilding from sstate | ||
|---|---|---|---|
| Product: | [Build System, Metadata & Runtime] OE-Core | Reporter: | Christian Andersen <c.andersen> |
| Component: | kernel | Assignee: | Robert Yang <liezhi.yang> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | major | ||
| Priority: | Medium+ | CC: | liezhi.yang, marek.vasut, otavio, randy.macleod, tom.rini |
| Version: | 2.3.2 | ||
| Target Milestone: | 2.7 M1 | ||
| Hardware: | All | ||
| OS: | Multiple | ||
| Whiteboard: | Backport 2.4.4, 2.5.1 | ||
| OS type for building Yocto: | --- | Type of Regression: | --- |
| Verified: | Documentation change: | No (bug/feature does not impact docs) | |
|
Description
Christian Andersen
2017-09-21 07:22:46 UTC
A possible solution would be to remove the dependency between kernel and U-Boot. But in this case it would be necessary to insert the public key into the DTB while building U-Boot without using the FIT image from the kernel build. Unfortunately uboot-mkimage does not support this at the moment. Christian, Since you can always wipe out part of the sstate-cache and rebuilt this doesn't seem like it would block you. Correct me if that's not accurate. Also, the error results in a functional but insecure system, and since it's a silent failure you may always be worried about whether the system is running a verified boot or not. Perhaps we could patch u-boot to issue a warning? Robert has agreed to investigate on the 2.4 branch next week and we'll see if we can get the defect resolved before the 2.4 release or soon thereafter and then backport it to 2.3.x . Since this involves u-boot and the kernel that could be a problem for 2.3.x so we'll see how that goes. Add Marek, Otavio and Tom Rini since RP said that you guys would be interested and I see you discussing u-boot/kernel/etc on the email list recently. Do you guys have any guidance for Robert (the problem is clearly explained). If the solution is too intrusive to add to 2.4 (and 2.3.x), is there a work-around other than doing a full build that we could implement until 2.5? Randy, yes, cleaning the sstate and ensuring a rebuild is a temporary solution, which I already do. So this is not a blocking issue. The only bad thing is, that this - as you also mentioned - results in an insecure system. Since there is no error message, it is difficult to recognize, unless you pay attention to the exact messages while U-Boot is verifying the image (sha1,rsa2048:...+). Christian, Is this still a problem on 2.4..master? It would be good to get some guidance from people who have more expertise with verified boot using u-boot... Randy, unfortunately we are still on 2.3.x, so I do not know if there was any change on 2.4.x or later. Our plan is to switch to 2.6 later this year. Next week I can try to construct a simple testcase for this issue for 2.4 and later and check if it is still a problem. Hi Christian Andersen, Do you have a reproducer for it, please ? Need a reproducer Unfortunately I am currently out of office and will be back on 17th of october. Nonetheless I will try to construct a testcase based on master or the current stable release within this week. It appears Christian has agreed to take this work. When you have a test case, please let Robert Yang know. Hi Robert Yang, I prepared a testcase to reproduce the issue (using the beaglebone-yocto machine included with poky). I uploaded the repo to github: https://github.com/kostal-industrie/yocto-test-12112 You may clone the repo (poky is embedded as submodule) or just download the local.conf and pre-generated u-boot signing keys from the build/conf folder. Otherwise just add the following lines to a default local.conf: MACHINE = "beaglebone-yocto" KERNEL_CLASSES += "kernel-fitimage" KERNEL_IMAGETYPE_beaglebone-yocto = "fitImage" UBOOT_MACHINE_beaglebone-yocto = "am335x_boneblack_vboot_config" UBOOT_MKIMAGE_DTCOPTS = "-I dts -O dtb -p 2000" UBOOT_SIGN_KEYDIR = "${TOPDIR}/conf" UBOOT_SIGN_KEYNAME = "dev" UBOOT_SIGN_ENABLE = "1" IMAGE_INSTALL_remove = "kernel-image-zimage" And then create a u-boot signing key pair in the build/conf directory: openssl genrsa -F4 -out dev.key 2048 openssl req -batch -new -x509 -key dev.key -out dev.crt Steps: * (Optional) Clone repository and initialize submodules (yocto poky 2.5.1) $ git clone --recurse-submodules https://github.com/kostal-industrie/yocto-test-12112.git $ cd yocto-test-12112 * (Optional) Initialize environment: $ . poky/oe-init-build-env build/ * Build kernel and u-boot: $ bitbake u-boot linux-yocto * Backup u-boot.* from tmp/deploy/images $ cp tmp/deploy/images/beaglebone-yocto/u-boot.img u-boot-clean.img $ cp tmp/deploy/images/beaglebone-yocto/u-boot.dtb u-boot-clean.dtb * Delete tmp dir $ rm -rf tmp * Build kernel and u-boot from sstate: $ bitbake u-boot linux-yocto * Copy new u-boot.* from tmp/deploy/images $ cp tmp/deploy/images/beaglebone-yocto/u-boot.img u-boot-sstate.img $ cp tmp/deploy/images/beaglebone-yocto/u-boot.dtb u-boot-sstate.dtb * Convert u-boot.dtb back to dts using dtc $ dtc -I dtb -O dts -s -o u-boot-clean.dts u-boot-clean.dtb $ dtc -I dtb -O dts -s -o u-boot-sstate.dts u-boot-sstate.dtb * Diff old and new u-boot.dts: /signature/key-dev node is missing in dtb restored from sstate $ diff u-boot-clean.dts u-boot-sstate.dts I tested this using yocto 2.5.1. At the moment I have a build running using the master branch of yocto. Note: I did not verify if the produced images boot on the real hardware. I stopped at the point, where it is possible to reproduce the issue with the missing keys. If you have any further questions, please let me know. My test build using master branch of yocto just completed. The issue remains the same. After deleting the tmp dir and rebuilding u-boot from sstate, the public key is missing from the u-boot dtb. Hi Christian, This bug is a little complicated. I've sent the patch again master branch: http://lists.openembedded.org/pipermail/openembedded-core/2018-November/276281.html It would be great if you can help test it. If you'd like to test it on 2.5.1, here is the patch for it: http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=rbt/uboot_sumo Note, I didn't do any testing on sumo branch, but I think it should work. Hi Robert, thank you very much for the patch. Yes, the nearly circular dependencies between U-Boot and kernel recipe are quite difficult. I tested the fix using a default poky build (thud). I also tested with our poky-based system using our test branch for thud. In both cases U-Boot is build correctly incl. the public key, even when rebuilding from sstate. So the fix looks fine from my side. I am going to review the changes in more detail asap. |