Skip to content

COCOS-432 - FDE support#553

Open
danko-miladinovic wants to merge 5 commits intoultravioletrs:mainfrom
danko-miladinovic:fde
Open

COCOS-432 - FDE support#553
danko-miladinovic wants to merge 5 commits intoultravioletrs:mainfrom
danko-miladinovic:fde

Conversation

@danko-miladinovic
Copy link
Contributor

@danko-miladinovic danko-miladinovic commented Nov 24, 2025

What type of PR is this?

This is a feature because it adds Full Disk Encryption (FDE) capability to the CVM.

What does this do?

This PR changes the Buildroot configuration to add support for FDE. The main idea is to run a QEMU-NBD source disk and alter the initramfs init script to read the connect and read the source disk. The init script would then copy the source disk into the disk attached to the CVM. After the copy process is done the init script will boot the encrypted disk.

The kernel configuration is altered to match Ubuntu Noble OS.

Which issue(s) does this PR fix/relate to?

Have you included tests for your changes?

Tests will be added.

Did you document any new/modified feature?

The documentation for launching the source disk image is added.

Notes

@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 69.56522% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.53%. Comparing base (a3265bc) to head (86f9b39).

Files with missing lines Patch % Lines
manager/qemu/vm.go 54.83% 11 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #553      +/-   ##
==========================================
+ Coverage   69.49%   69.53%   +0.03%     
==========================================
  Files          85       85              
  Lines        6075     6119      +44     
==========================================
+ Hits         4222     4255      +33     
- Misses       1485     1493       +8     
- Partials      368      371       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danko-miladinovic danko-miladinovic marked this pull request as ready for review December 1, 2025 12:12
@danko-miladinovic danko-miladinovic self-assigned this Dec 1, 2025
# Ensure /etc/fstab exists
if [ ! -f "${TARGET_DIR}/etc/fstab" ]; then
touch "${TARGET_DIR}/etc/fstab"
# Ensure /etc/fstab does not exists
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Ensure /etc/fstab does not exists
# Ensure /etc/fstab does not exist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

v.vmi.Config.OVMFVarsConfig.File = dstFile
}

if v.vmi.Config.EnableDisk {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If disk creation succeeds but VM startup fails later (e.g., in executableAndArgs or cmd.Start), the created qcow2 file in /tmp will be orphaned. Additionally, Stop() cleans up CertsMount and EnvMount but not DstFile.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stop() has been modified to delete the disk.

2. Creates a fresh encrypted LUKS2 disk
3. Copies the qcow2 contents into the encrypted disk
4. Hashes the content
5. Extends a vTPM PCR with that hash (onyl for vTPM with SEV-SNP)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
5. Extends a vTPM PCR with that hash (onyl for vTPM with SEV-SNP)
5. Extends a vTPM PCR with that hash (only for vTPM with SEV-SNP)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the WASM and all the other packages (Agent and so on) should be part of the source disk image. Not the initramfs that is being built here. The initramfs role with disk support is to copy the source disk to the destination disk and encrypt the destination disk in the process.

type Config struct {
EnableSEVSNP bool
EnableTDX bool
EnableDisk bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnableDisk has no env tag and isn't set programmatically in NewConfig(), so it always defaults to false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

BR2_PACKAGE_GCC=y
BR2_PACKAGE_GCC_TARGET=y
BR2_PACKAGE_LIBSTDCPP=y
BR2_PACKAGE_LIBSTDCPP=y No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
BR2_PACKAGE_LIBSTDCPP=y
BR2_PACKAGE_LIBSTDCPP=y

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

BR2_PACKAGE_NBD=y
BR2_PACKAGE_NBD_CLIENT=y
BR2_PACKAGE_CRYPTSETUP=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDE=y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a misspelling of EUDE to EUDEV

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my mistake. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants