diff options
| author | niko.mauno@vaisala.com <niko.mauno@vaisala.com> | 2020-09-10 16:17:54 +0000 |
|---|---|---|
| committer | Armin Kuster <akuster808@gmail.com> | 2020-09-12 08:55:28 -0700 |
| commit | 489f7c900c365e4b3198cff2f2fd7c38623b77e8 (patch) | |
| tree | e6fccd0c049605473cfa28e6053ce1f26b9ee567 /recipes-core/initrdscripts/initramfs-framework | |
| parent | 170945ff9f8835ab7b0045b722c2a480b450ef90 (diff) | |
| download | meta-security-489f7c900c365e4b3198cff2f2fd7c38623b77e8.tar.gz | |
initramfs-framework: Add dmverity module
Add 'initramfs-module-dmverity' as an extension to poky upstream
provided initramfs-framework suite via matchingly named bbappend file.
Together with pre-existing 'initramfs-module-udev' this module can be
used to facilitate dm-verity rootfs mounting from initramfs context
that is bundled with Linux kernel.
Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'recipes-core/initrdscripts/initramfs-framework')
| -rw-r--r-- | recipes-core/initrdscripts/initramfs-framework/dmverity | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/recipes-core/initrdscripts/initramfs-framework/dmverity b/recipes-core/initrdscripts/initramfs-framework/dmverity new file mode 100644 index 0000000..bb07aab --- /dev/null +++ b/recipes-core/initrdscripts/initramfs-framework/dmverity | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | dmverity_enabled() { | ||
| 4 | return 0 | ||
| 5 | } | ||
| 6 | |||
| 7 | dmverity_run() { | ||
| 8 | DATA_SIZE="__not_set__" | ||
| 9 | ROOT_HASH="__not_set__" | ||
| 10 | |||
| 11 | . /usr/share/misc/dm-verity.env | ||
| 12 | |||
| 13 | case "${bootparam_root}" in | ||
| 14 | ID=*) | ||
| 15 | RDEV="$(realpath /dev/disk/by-id/${bootparam_root#ID=})" | ||
| 16 | ;; | ||
| 17 | LABEL=*) | ||
| 18 | RDEV="$(realpath /dev/disk/by-label/${bootparam_root#LABEL=})" | ||
| 19 | ;; | ||
| 20 | PARTLABEL=*) | ||
| 21 | RDEV="$(realpath /dev/disk/by-partlabel/${bootparam_root#PARTLABEL=})" | ||
| 22 | ;; | ||
| 23 | PARTUUID=*) | ||
| 24 | RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})" | ||
| 25 | ;; | ||
| 26 | PATH=*) | ||
| 27 | RDEV="$(realpath /dev/disk/by-path/${bootparam_root#PATH=})" | ||
| 28 | ;; | ||
| 29 | UUID=*) | ||
| 30 | RDEV="$(realpath /dev/disk/by-uuid/${bootparam_root#UUID=})" | ||
| 31 | ;; | ||
| 32 | *) | ||
| 33 | RDEV="${bootparam_root}" | ||
| 34 | esac | ||
| 35 | |||
| 36 | if ! [ -b "${RDEV}" ]; then | ||
| 37 | echo "Root device resolution failed" | ||
| 38 | exit 1 | ||
| 39 | fi | ||
| 40 | |||
| 41 | veritysetup \ | ||
| 42 | --data-block-size=1024 \ | ||
| 43 | --hash-offset=${DATA_SIZE} \ | ||
| 44 | create rootfs \ | ||
| 45 | ${RDEV} \ | ||
| 46 | ${RDEV} \ | ||
| 47 | ${ROOT_HASH} | ||
| 48 | |||
| 49 | mount \ | ||
| 50 | -o ro \ | ||
| 51 | /dev/mapper/rootfs \ | ||
| 52 | ${ROOTFS_DIR} || exit 2 | ||
| 53 | } | ||
