Som: imx8mp
torizon version: 6.7.0
image: torizon-core-docker
distro: torizon
using the TEZI installer to program the SOM
I’m trying to create an encrypted partition on the emmc following instructions from meta-toradex-security
I started by just creating a data partition in the emmc
# local.conf
INHERIT += "tdx-tezi-data-partition"
This works exactly as expected.
Then I went to add encryption
# local.conf
INHERIT += "tdx-encrypted"
TDX_ENC_STORAGE_LOCATION = "/dev/mmcblk2p2"
This OS fails to boot with the following error.
Starting version 250.5+
[ TIME ] Timed out waiting for device /dev/disk/by-label/DATA.
[DEPEND] Dependency failed for /data.
[DEPEND] Dependency failed for Local File Systems.
You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systePress Enter for maintenance
(or press Control-D to continue):
Going into maintenance mode:
sh-5.1# ls /dev/disk/by-label/
DATA otaroot
sh-5.1# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
mmcblk2 179:0 0 14.8G 0 disk
|-mmcblk2p1 179:1 0 7.4G 0 part /var
| /usr
| /boot
| /
| /sysroot
`-mmcblk2p2 179:2 0 7.4G 0 part
`-encdata 253:0 0 7.4G 0 dm /run/encdata
mmcblk2boot0 179:32 0 31.5M 1 disk
mmcblk2boot1 179:64 0 31.5M 1 disk
I figured the easiest way out of this predicament is to disable auto mounting the data partition
# local.conf
TDX_TEZI_DATA_PARTITION_AUTOMOUNT = "0"
Now, the system will boot, but the encrypted data does not persist between reboots. Every time the system boots it gets to the point where it checks for an existing mapper device and doesn’t find it so it reformats the whole partition.
This seems like a pretty standard use case, so I have to imagine there’s a config line somewhere that I’m not understanding.
Update:
I decided to check if the encrypted data would remain if I restarted the encryption service
systemctl restart tdx-enc-handler.service
# journalctl indicates the existing partition was mounted
tdx-enc.sh[1083]: caam: Setting up partition with dm-crypt...
tdx-enc.sh[1095]: Name: encdata
tdx-enc.sh[1095]: State: ACTIVE
tdx-enc.sh[1095]: Read Ahead: 256
tdx-enc.sh[1095]: Tables present: LIVE
tdx-enc.sh[1095]: Open count: 0
tdx-enc.sh[1095]: Event number: 0
tdx-enc.sh[1095]: Major, minor: 253, 0
tdx-enc.sh[1095]: Number of targets: 1
tdx-enc.sh[1083]: caam: Mounting encrypted partition...
tdx-enc.sh[1104]: /dev/mapper/encdata: UUID="c475c16a-8177-478c-9f72-983871f91f6b" BLOCK_SIZE="4096" TYPE="ext4"
tdx-enc.sh[1083]: caam: Data preservation is not enabled
tdx-enc.sh[1083]: caam: Success!
However, adding data to the partition results in errors
echo hello > /run/encdata/test.txt
systemctl restart tdx-enc-handler.service
# journalctl output
systemd[1]: Stopping Encryption handler for Toradex modules...
tdx-enc.sh[1145]: caam: Unmounting dm-crypt partition...
tdx-enc.sh[1145]: caam: Removing dm-crypt partition...
tdx-enc.sh[1147]: device-mapper: remove ioctl on encdata failed: Device or resource busy
tdx-enc.sh[1147]: Command failed.
tdx-enc.sh[1145]: caam: Removing key from kernel keyring...
tdx-enc.sh[1145]: caam: Success!
systemd[1]: tdx-enc-handler.service: Deactivated successfully.
systemd[1]: Stopped Encryption handler for Toradex modules.
systemd[1]: Starting Encryption handler for Toradex modules...
tdx-enc.sh[1150]: caam: Preparing and checking system (generic)...
tdx-enc.sh[1150]: caam: Blocks to be encrypted: 15540224...
tdx-enc.sh[1150]: caam: Reserved blocks: 0...
tdx-enc.sh[1150]: caam: Preparing and checking system (caam)...
tdx-enc.sh[1150]: caam: Setting up encryption key for CAAM backend...
tdx-enc.sh[1150]: caam: Configuring key in kernel keyring (type=trusted keyname=tdxenc)...
tdx-enc.sh[1150]: caam: Encrypted key exists. Importing it...
tdx-enc.sh[1159]: 561625088
tdx-enc.sh[1150]: caam: Data preservation is not enabled
tdx-enc.sh[1150]: caam: Setting up partition with dm-crypt...
tdx-enc.sh[1162]: device-mapper: create ioctl on encdata failed: Device or resource busy
tdx-enc.sh[1162]: Command failed.
tdx-enc.sh[1150]: caam: ERROR: Error setting up dm-crypt partition!
systemd[1]: tdx-enc-handler.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: tdx-enc-handler.service: Failed with result 'exit-code'.
systemd[1]: Failed to start Encryption handler for Toradex modules.