[next] Implement foundational changes for NILRT Device Encryption#977
Conversation
9b23cc6 to
7fa4d0e
Compare
Patch v2
|
ff44451 to
154e4c0
Compare
Patch v3
|
| partitions for NILRT. Installs the ni-cryptdisks.sh initscript.\ | ||
| " | ||
| HOMEPAGE = "https://github.com/ni/meta-nilrt" | ||
| SECTION = "test" |
There was a problem hiding this comment.
Does this belong in test section?
There was a problem hiding this comment.
Fixed in Patch V4.
| efibootmgr \ | ||
| efivar \ | ||
| pstore-save \ | ||
| clevis \ |
There was a problem hiding this comment.
nit: not sorted. Maybe break out tpm related packages into their own RDEPENDS:${PN}:append:x64 section if we want to keep them together?
There was a problem hiding this comment.
It gets fixed up by the final commit in the patchset. These items are moved into packagegroup-ni-tpm.
There was a problem hiding this comment.
Should be fixed in Patch V4. I decided to backport the change that moves clevis into packagegroup-ni-tpm.
| CONFIG_TAP=m | ||
| CONFIG_TARGET_CORE=m | ||
| CONFIG_TCG_ATMEL=m | ||
| CONFIG_TCG_CRB=m |
There was a problem hiding this comment.
Same as #957 we don't need CONFIG_TCG_CRB, CONFIG_TCG_TIS, CONFIG_TCG_TIS_CORE, CONFIG_TCG_TPM
There was a problem hiding this comment.
I have a commit from a later patchset that I will backport to fix this. But honestly, I'm considering just implementing the allmoddefconfig task that we discussed offline.
There was a problem hiding this comment.
Backported the commit from the later patchset to remove these lines. Fixed in Patch V4.
|
Offline conversation: We've decided to merge this after release is done. |
When LUKS-based disk encryption is implemented, safemode and runmode will need utilties to interact with the encrypted partitions. Add these utilities to the base packagegroup to ensure they are present in the base images. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Remove the old RAUC grub components so that they are not confused with the contemporary components. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
All NILRT images will require TPM-interaction tools like 'clevis' to open LUKS-encrypted partitions on boot. So add them to the base packagegroup. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The OE-core ovmf recipe generates raw OVMF image files, but then converts them to qcow2 images, and moves only the qcow2 files to the deploy directory. QEMU can use either format, but only the raw format supports writable EFI variables - which NILRT uses and which upstream OE core testing does not. So add a NILRT-specific bbappend which also outputs the raw-formatted OVMF files, for use in NILRT QEMU virtual machines. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Create a recipe which installs an /init script to the new runmode initramfs. The initscript's primary mission is to unlock any LUKS-encrypted partitions, before switching into the real rootfs. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The init-nilrt-ramfs is an old initrdscripts recipe for the previous RAUC prototype. It is unused. Remove it for codebase cleanliness. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
To support full Device Encryption, NILRT runmode requires an unencrypted initramfs that understands how to interact with the device TPM and decrypt and mount LUKS partitons. Create nilrt-runmode-initramfs.bb to act as such an image. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The meta-nilrt styleguide has an example bitbake recipe at its end. Update that recipe with some better headings and comments and break it out into its own file, so that it is easier to reuse in new recipes. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The ni-device-encryption recipe will contain content supporting fundamental LUKS-encryption of NILRT devices. At the moment, it only packages an initscript which will handle opening/closing LUKS partitions during early boot. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The TCG TPM TIS kernel driver is now built into the x64 kernel and there is no module package for it. Remove the invalid reference to it from the restoremode (recovery initramfs) RRECOMMENDS. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The base packagegroup requires ni-device-encryption so that all images will understand how to unlock LUKS-encrypted partitions during boot (especially safemode). The initramfs packagegroup is used to populate the rootfs for the runmode initramfs. It requires ni-device-encryption to unlock the LUKS partitions prior to switching into the real rootfs. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
154e4c0 to
ea838b3
Compare
Patch V4
This should be the last revision of this PR. I would like to get it merged so that we can move on to the subsequent measured boot PR I have staged and then on to complete the feature. |
There was a problem hiding this comment.
Pull request overview
This PR introduces the core Yocto-layer plumbing needed to support NILRT x64 measured boot and future LUKS device encryption, including TPM2 tooling, GRUB boot flow updates, and a new runmode initramfs path to unlock encrypted disks before switching into the real runmode rootfs.
Changes:
- Add TPM2 / crypto userspace dependencies (including clevis) to base and initramfs package composition.
- Introduce
ni-device-encryption(scripts + initscript) and a new runmode initramfs image + PID1/init. - Update GRUB runmode boot logic and clean up legacy RAUC-related grub/initramfs content; adjust OVMF deploy outputs for QEMU TPM testing.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| recipes-ni/ni-device-encryption/ni-device-encryption/share/pkg.sh.in | Template for exported package/version variables. |
| recipes-ni/ni-device-encryption/ni-device-encryption/share/const_luks.sh | Adds shared constants for LUKS keyslot conventions. |
| recipes-ni/ni-device-encryption/ni-device-encryption/Makefile | Build/install rules for ni-device-encryption utilities. |
| recipes-ni/ni-device-encryption/ni-device-encryption/init/ni-cryptdisks.sh.in | SysV init script to unlock LUKS volumes via clevis. |
| recipes-ni/ni-device-encryption/ni-device-encryption/bin/ni-reseal-luks.sh | Tooling to (re)bind clevis TPM2 policies for LUKS slots. |
| recipes-ni/ni-device-encryption/ni-device-encryption/.gitignore | Ignores generated script artifacts. |
| recipes-ni/ni-device-encryption/ni-device-encryption.bb | BitBake recipe packaging the encryption helper scripts + initscript. |
| recipes-kernel/linux/files/extra_x64.cfg | Removes TPM/securityfs-related configs from extra module list (now builtin elsewhere). |
| recipes-core/packagegroups/packagegroup-ni-tpm.bb | Updates TPM packagegroup dependencies (drops upstream packagegroup-security-tpm2). |
| recipes-core/packagegroups/packagegroup-ni-restoremode.bb | Removes invalid kernel-module-tpm-tis recommendation on x64. |
| recipes-core/packagegroups/packagegroup-ni-initramfs.bb | New packagegroup defining common initramfs package set + TPM bits on x64. |
| recipes-core/packagegroups/packagegroup-ni-base.bb | Pulls TPM + device-encryption dependencies into x64 base images. |
| recipes-core/packagegroups/packagefeed-ni-extra.bb | Removes redundant cryptsetup from extra feed dependencies. |
| recipes-core/packagegroups/packagefeed-ni-core.bb | Adds initramfs packagegroup and builds runmode initramfs init package into the core feed. |
| recipes-core/ovmf/ovmf_%.bbappend | Deploys raw OVMF code/vars images alongside qcow2 for QEMU testing. |
| recipes-core/initrdscripts/init-nilrt-runmode-initramfs/test/test_kernel-vars.sh | Adds a shell test runner for cmdline parsing helpers. |
| recipes-core/initrdscripts/init-nilrt-runmode-initramfs/reboot.sh | Adds initramfs reboot implementation (sysrq-based). |
| recipes-core/initrdscripts/init-nilrt-runmode-initramfs/kernel-vars.sh | Parses /proc/cmdline into exported vars used by initramfs scripts. |
| recipes-core/initrdscripts/init-nilrt-runmode-initramfs/init.sh.in | New runmode initramfs PID1 /init to unlock disks and switch_root. |
| recipes-core/initrdscripts/init-nilrt-runmode-initramfs/halt.sh | Adds initramfs halt implementation (sysrq-based). |
| recipes-core/initrdscripts/init-nilrt-runmode-initramfs.bb | Recipe installing /init, cmdline parser, and halt/reboot alternatives. |
| recipes-core/initrdscripts/init-nilrt-ramfs.bb | Removes legacy initrdscripts recipe from previous RAUC prototype. |
| recipes-core/initrdscripts/files/init-nilrt-ramfs.sh | Removes legacy initramfs /init implementation. |
| recipes-core/images/nilrt-runmode-rootfs.bb | Adds runmode initramfs into boot staging and refactors kernel/boot fixups into rootfs postprocess. |
| recipes-core/images/nilrt-runmode-initramfs.bb | New image for producing the runmode initramfs (cpio.xz). |
| recipes-bsp/grub/grub/grub.cfg | Removes unused legacy grub.cfg artifact from layer. |
| recipes-bsp/grub/grub/grub-safemode.cfg | Updates validation and runmode boot logic to optionally use a runmode ramdisk. |
| recipes-bsp/grub/grub/grub-runmode-bootimage.cfg | Adds ramdisk_path pointing to /runmode/ramdisk.xz. |
| recipes-bsp/grub/grub-nilrt.inc | Drops grub.cfg from grub recipe sources. |
| recipes-bsp/grub/grub-bootconf_%.bbappend | Removes legacy grub-bootconf bbappend (RAUC-era configuration packaging). |
| docs/styleguide.md | Removes embedded example recipe (moved to its own file). |
| docs/example.bb | New standalone example BitBake recipe referenced by the styleguide. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The initscript doesn't "mount" any disks that it unlocks. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The current implementation might use invalid regex characters, and anyway can be made simpler by evaluating each token using bash semantics. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
If the cryptsetup actions in the initscript fail, the script might bail out before printing important logging information. Adjust the bash commands to keep this from happening. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The pkglibdir path is not removed by the Makefile uninstall target. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The update-alternatives recipe BBClass needs the full path to the link
location and target. So provide that.
Also, there is a typo in the ``ALTERNATIVES:${PN}`` variable, it should
actually be ``ALTERNATIVE``.
Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Patch V5
|
Use the '[[:space:]]` POSIX-compliant regex metacharacter to ensure that grep properly parses cryptsetup output. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
The ni-cryptsetup initscript uses ``dmcrypt`` from the lvm2 package. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Not all machine arches use ``lib`` as the main library name - eg. lib64. So we should reuse the ``libdir`` OE variable when creating symlinks. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
We need to coordinate the INITRAMFS_FSTYPES and IMAGE_FSTYPES, but we're doing it implicitly here. Instead, set the INITRAMFS_FSTYPES explicitly and then copy the value into the IMAGE_FSTYPES in the anonymous python function. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Patch V6
|
Bash source files should not 'exit', they should 'return'. When they 'exit', they kill the sourcing bash process. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
class-target appends are more often ordered like ``:append:class-target`` in the OE layers. Signed-off-by: Alex Stewart <alex.stewart@emerson.com>
Patch V7
|
Summary of Changes
This PR contains all the foundational changes necessary for the core features of Measured Boot / Device Encryption on NILRT. It stops short of the changes to
nisystemformatwhich will actually affect the LUKS encryption - they will be in their own PR after this one.Changes in this PR:
extra_x64set. The core TPM2 drivers have already been built into the 6.12 kernel as of ni/linux#270.TPM2to the NILRT x64 machine features. This will coerce recipes to build with TPM2 support./sysso that users can interrogate TPM boot measurements.ni-cryptdisks- which will try to find and open any LUKS-encrypted disks using the TPM state (through clevis).nilrt-runmode-initramfswith a custom /init that will try to mount any LUKS-encrypted disks using the TPM state. Then it pivot_roots into the real runmode rootfs (that might have been on an encrypted disk).Justification
Testing
bitbake packagefeed-ni-core)Procedure