mirror of
https://git.yoctoproject.org/meta-ti
synced 2026-10-23 06:08:15 +00:00
dm-verity-upstream: Add dynamic layer for meta-security dm-verity
Add an optional dynamic layer enabling dm-verity block-level integrity verification of the root filesystem for TI K3 platforms, using meta-security's stock dm-verity mechanism as-is. Requires meta-security to be present in bblayers.conf. dm-verity hashes the rootfs at build time; at boot, a dedicated initramfs loads the root hash and the kernel checks every block read against it. Set DM_VERITY_IMAGE to enable all the verity-related recipes for that image; other images build as usual. Signed-off-by: Atharv Dubey <a-dubey@ti.com> Signed-off-by: Ryan Eatmon <reatmon@ti.com>
This commit is contained in:
1 parent
03e3d09e35
commit
9e9c26f8df
6 files changed
+47
No files matched your search
@@ -22,6 +22,7 @@ LAYERRECOMMENDS_meta-ti-bsp = " \
|
||||
multimedia-layer \
|
||||
openembedded-layer \
|
||||
tpm-layer \
|
||||
security \
|
||||
"
|
||||
|
||||
BBFILES_DYNAMIC += " \
|
||||
@@ -29,6 +30,8 @@ BBFILES_DYNAMIC += " \
|
||||
openembedded-layer:${LAYERDIR}/dynamic-layers/openembedded-layer/recipes*/*/*.bbappend \
|
||||
tpm-layer:${LAYERDIR}/dynamic-layers/tpm-layer/recipes*/*/*.bb \
|
||||
tpm-layer:${LAYERDIR}/dynamic-layers/tpm-layer/recipes*/*/*.bbappend \
|
||||
security:${LAYERDIR}/dynamic-layers/security-layer/recipes*/*/*.bb \
|
||||
security:${LAYERDIR}/dynamic-layers/security-layer/recipes*/*/*.bbappend \
|
||||
"
|
||||
|
||||
SIGGEN_EXCLUDERECIPES_ABISAFE += " \
|
||||
|
||||
@@ -61,3 +61,10 @@ FALCON_INCLUDE = ""
|
||||
FALCON_INCLUDE:ti-falcon = "conf/machine/include/ti-falcon.inc"
|
||||
|
||||
require ${FALCON_INCLUDE}
|
||||
|
||||
# dm-verity protects the rootfs listed in DM_VERITY_IMAGE; see dynamic-layers/security-layer/conf/include/dm-verity-upstream.inc for what that turns on.
|
||||
DM_VERITY_IMAGE ??= ""
|
||||
|
||||
DM_VERITY_UPSTREAM_INCLUDE = "${@'dynamic-layers/security-layer/conf/include/dm-verity-upstream.inc' if d.getVar('DM_VERITY_IMAGE') else ''}"
|
||||
|
||||
require ${DM_VERITY_UPSTREAM_INCLUDE}
|
||||
@@ -0,0 +1,21 @@
|
||||
# Enables dm-verity to check the rootfs for tampering on TI K3 boards.
|
||||
DM_VERITY_IMAGE_TYPE = "ext4"
|
||||
IMAGE_CLASSES += "dm-verity-img"
|
||||
|
||||
# ti-core-initramfs.bbappend already wires the initramfs into the boot partition once dm-verity is enabled, so we don't need to do it here.
|
||||
|
||||
python () {
|
||||
import uuid
|
||||
|
||||
if d.getVar('PN') != d.getVar('DM_VERITY_IMAGE'):
|
||||
return
|
||||
|
||||
# Derive the root partition's UUID from MACHINE so everyone computes the same one.
|
||||
if not d.getVar('DM_VERITY_ROOT_PARTUUID'):
|
||||
d.setVar('DM_VERITY_ROOT_PARTUUID',
|
||||
str(uuid.uuid5(uuid.NAMESPACE_DNS, 'dm-verity-root-%s' % d.getVar('MACHINE'))))
|
||||
|
||||
d.setVar('WKS_FILE', 'k3-verity.wks.in')
|
||||
d.appendVar('EXTRA_IMAGE_FEATURES', ' read-only-rootfs')
|
||||
d.appendVar('WICVARS', ' DM_VERITY_IMAGE DM_VERITY_IMAGE_TYPE IMAGE_NAME_SUFFIX IMGDEPLOYDIR DM_VERITY_ROOT_PARTUUID')
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
do_install:append() {
|
||||
if ${@'true' if d.getVar('DM_VERITY_IMAGE') else 'false'}; then
|
||||
: > ${D}${libdir}/udev/rules.d/50-arago.rules
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
# Nothing should ever get auto-mounted under dm-verity, so just kill the automounter.
|
||||
do_install:append() {
|
||||
if ${@'true' if d.getVar('DM_VERITY_IMAGE') else 'false'}; then
|
||||
: > ${D}${sysconfdir}/udev/rules.d/automount.rules
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Disk layout for a board that boots with dm-verity enabled.
|
||||
|
||||
bootloader --timeout=3 --append="rootfstype=ext4 root=PARTUUID=${DM_VERITY_ROOT_PARTUUID} ${TI_WKS_BOOTLOADER_APPEND}"
|
||||
part --source bootimg-efi --sourceparams="loader=${EFI_PROVIDER}${TI_WKS_INITRAMFS}" --fstype=vfat --label boot --active --align 1024 --use-uuid --fixed-size 128M
|
||||
part / --source rawcopy --sourceparams="file=${IMGDEPLOYDIR}/${DM_VERITY_IMAGE}-${MACHINE}${IMAGE_NAME_SUFFIX}.${DM_VERITY_IMAGE_TYPE}.verity" --align 1024 --uuid ${DM_VERITY_ROOT_PARTUUID}
|
||||
Reference in new issue
Block a user