Repository navigation
build: add Makefile front-end with fetch helpers and tests - #14
Igor Opaniuk (igoropaniuk) wants to merge 16 commits into
Conversation
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
|
FYI this based on the old PR #10 Michael Scott (@mike-scott) Sumit Garg (@b49020) happy to get your feedback on this |
d576096 to
4c08b63
Compare
4c08b63 to
9b41845
Compare
| PROFILE="${QCOM_SEC_PROFILE:-}" | ||
| DIR="${QCOM_SEC_PROFILES_DIR:-.security-profiles}" | ||
| REPO="${QCOM_SEC_PROFILES_REPO:-https://github.com/qualcomm/security-profiles.git}" | ||
| REV="${QCOM_SEC_PROFILES_REV:-bb3e8c735d6b7fee25227395249f9ec674867464}" |
There was a problem hiding this comment.
I wish there was a better way than a pinned SHA or maybe we leave this as current main?
|
I reviewed the patches and the overall approach is really nice. The I need some time to play test it. |
|
Selvam (@zelvam95) can you rather test this Makefile interface? Also, see if the fuse file generation logic can be built on top from this PR: #13. |
|
Michael Scott (@mike-scott) could you let me know if we want to proceed with this approach? |
sec.elf and basic_sec.elf are already signed by 'sectools fuse-blower' and cannot go through secure-image --sign again. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
--fuse-sec-key-derivation-key takes the secret that is blown into the fuses, and the argument parser echoed it like any other flag, so it ended up in terminal scrollback and CI logs. Report that it is set without its value, as genkeys.sh does for the FMP key password. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
9b41845 to
25dd1ec
Compare
25dd1ec to
7db1688
Compare
The UEFI enrollment read efi.bin from the current directory and reset the image in the output directory from an efi.bin.orig backup found there. With a build staged elsewhere it failed, or replaced the efi.bin that signimages.sh had already signed with an unsigned copy. Work on the efi.bin in the output directory. The enrollment only adds loader.conf and the key files, so the signed EFI binaries stay valid and no reset is needed to run it twice. A step failing after the mount, such as a missing .auth file, left the image mounted. Check for the key files before mounting and unmount from an EXIT trap. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
The fuses passed to 'sectools fuse-blower' were hard-coded, but every SoC has its own set: monaco has no secure-boot2/3 fuses and talos none of the shared debug ones, so sectools rejected the command line with "unrecognized arguments" and no image was built for them. Ask sectools which fuses the security profile has and leave out the defaults it lacks, with a warning naming them. --basic-fuses and --full-fuses replace the list of an image for a SoC that needs other fuses; a fuse given there must exist. Profiles without the pk-hash-0 and OEM ID fuses (nord, sariska) are refused instead of failing inside sectools. Each image gets a fuse list next to it, from 'fuse-blower --inspect', so the fuses can be checked before the image is programmed. An inspection of sec.elf prints the key derivation key, so its list is taken from an unsigned image built without the key. The images carry that key in the clear and are created readable by the owner only. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Resolve a sectools binary from QCOM_SECTOOLS, a previous download, or the Software Center. Version, URL, sha256 and per-arch layout follow the meta-qcom sectools-native recipe (1.50.0). A download is verified against its checksum, which needs sha256sum, and the checksum is recorded next to the unpacked archive: a cached binary is reused only if it comes from the archive asked for. The archive is unpacked aside and swapped in once complete. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Resolve a qdl binary from QCOM_QDL, a previous build, or a fresh clone of linux-msm/qdl built with meson. Needed for VIP table generation. The path is printed absolute, as qdl is run from the build directory. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Resolve a security profile from a path, or by bare filename from a clone of qualcomm/security-profiles, as meta-qcom does. The clone follows the main branch, so new and fixed profiles are picked up without bumping a revision here. QCOM_SEC_PROFILES_REV pins a commit, branch or tag for a reproducible build. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
7db1688 to
59cff55
Compare
XML jobs of the Makefile that sed and grep cannot do reliably: secdata-xml writes a rawprogram XML that programs only the secdata partition with a Fuse Blower image. The entry is copied from the rawprogram*.xml of the build, which must have exactly one, and those files are not modified. no-secdata fails if any secdata entry of the build has an image. qdl asks for --allow-fusing only when the first entry has one, so a populated entry after an empty one would be programmed. vip-format prints the image format a security profile declares for the VIP digest table. The files are read with expat and a document that declares a DTD is refused. Entities can only be defined there, so this rules out external entities and entity expansion without depending on defusedxml. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
.env holds local paths and secrets, .sectools/, .qdl/ and .security-profiles/ are downloaded by 'make deps', and signed-build/ with its vip-tables/ is the output of 'make sign-build', which works in the .staging directories next to them. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Wrap the scripts behind make targets (config, deps, generate-keys, sign-build, flash, gen-capsule, clean) driven by a single .env file. Required variables are checked by a guard-% target, which tests the value in make so that it is never quoted for the shell. sign-build stages QCOM_FLAT_BUILD, signs the copy and, unless QCOM_VIP_DISABLE, generates and signs a VIP digest table. All of it happens in <dir>.staging and is published at the end, so a run that fails leaves the previous build and its VIP table in place. The output and staging directories are removed by the recipes, so they are refused when they are /, hold the checkout or overlap QCOM_FLAT_BUILD; clean applies the same checks. With QCOM_UEFI_ENROLL the UEFI keys are enrolled into efi.bin ahead of the VIP table that covers it. The VIP table is generated for QCOM_STORAGE, as the digests differ per storage type. A security profile that wants another VIP format than the MBN one built here is rejected up front, and a table that signimages.sh left unsigned is an error. flash programs the signed build with qdl. It needs a build that sign-build has completed, which is marked by a .signed-build file, and fails without a VIP table unless QCOM_VIP_DISABLE is set. It never passes --allow-fusing, and since qdl only checks the first secdata entry, sign-build and flash refuse a build in which any secdata entry has an image. .env is created with mode 0600 and the FMP key password is not echoed. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
gen-fuse-blower generates the Fuse Blower images into the fuse directory of a build completed by sign-build, following the layout meta-qcom uses: each image gets a rawprogram_secdata-<stage>.xml that programs only the secdata partition and a signed VIP table of its own. The rawprogram*.xml of the build are left alone, so 'make flash' cannot blow fuses. The directory is kept to the owner, as sec.elf carries the key derivation key, and is marked complete only when every step succeeded. flash-fuse-blower programs one of the images, with the Firehose programmer signed by sign-build. It is the only target passing --allow-fusing to qdl and needs QCOM_FUSE_STAGE and QCOM_ALLOW_FUSING=1 on the command line; both are ignored in .env and the environment. QCOM_FUSE_BASIC_FUSES and QCOM_FUSE_FULL_FUSES choose the fuses of an image for a SoC whose security profile differs from the defaults of secure.sh. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Lead with the make workflow, link sectools and the security-profiles repository, and list every target. Flashing the signed build and blowing the fuses are documented as separate steps. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Run the Makefile against stub scripts that log their arguments, and wire the suite up as 'make test'. xmltool.py is not stubbed, so the generated secdata XML is checked as well. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Exercise fetch-sectools.sh with a local archive, fetch-security-profile.sh with a local repository and the path resolution of fetch-qdl.sh. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Run secure.sh against a stub sectools that reports the fuses of a security profile, to check which fuses end up in each image and that the key derivation key stays out of the log and the fuse list. The UEFI key enrollment runs with sudo and the mount stubbed, to check that the image is unmounted when a step fails. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Run 'make test' on pull requests and on pushes to main. The tests only use stubs and local fixtures, so the job needs no secrets and no network access. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
59cff55 to
0169425
Compare
Add a Makefile front-end so the signing flow is driven from a single
.envfile instead of long per-script flag lists:Fuse blower
Blowing fuses is a separate, explicit step, following the layout meta-qcom uses for the Fuse Blower images:
gen-fuse-blowerwritesbasic_sec.elf(stagebasic) andsec.elf(stagefull) toQCOM_SIGNED_BUILD/fuse/. Each gets arawprogram_secdata-<stage>.xmlthat programs onlysecdata, and a signed VIP table of its own. The build'srawprogram*.xmlare not modified.make flashnever passes--allow-fusing, and refuses a build in which anysecdataentry has an image. qdl's own guard only looks at the first entry.flash-fuse-bloweris the only target that can fuse.QCOM_FUSE_STAGEandQCOM_ALLOW_FUSING=1are accepted on the command line only, not from.envor the environment.