Skip to content

dracut: fall back to expected dm-verity hash offset#25

Merged
pothos merged 2 commits intoflatcar-masterfrom
kai/verity-hash-offset
Jul 28, 2021
Merged

dracut: fall back to expected dm-verity hash offset#25
pothos merged 2 commits intoflatcar-masterfrom
kai/verity-hash-offset

Conversation

@pothos
Copy link
Copy Markdown
Member

@pothos pothos commented Jul 14, 2021

  • dracut: fall back to expected dm-verity hash offset

    The hash offset is found by looking at the filesystem size. When
    e2size can't find the size it returns "Success" in stderr for whatever
    reason and fortunately still returns an error exit code, stdout stays
    empty. This means that the dm-verity device setup won't work because
    the hash offset is the empty string. However, the hash offset is
    actually fixed because the GPT disk layout has to stay the same in
    Flatcar Container Linux as the partition contents are swapped out
    when updating. In case another filesystem like btrfs is used, e2size
    doesn't work and it makes sense to fall back to the only value which
    is supported in general.
    Hard code the hash offset value coming from the /usr filesystem size
    defined in flatcar-scripts/build_library/disk_layout.json.

  • dracut: add norecovery mount option for /usr

    The /usr partition should not be modified during mounting, even if it
    has some corruption. Rewriting the filesystem log would cause dm-verity
    errors when dm-verity is enabled later again. While the /usr partition
    normally is on a dm-verity block device in read-only mode there is some
    option to mount the partition without dm-verity and it wouldn't be a
    read-only block device anymore.
    Add the norecovery mount option which is supported for ext4 and btrfs.

How to use/testing done

This was built and tested with the coreos-overlay branch kai/bootengine-verity-hashoffset from flatcar-archive/coreos-overlay#1106 and flatcar-scripts branch kai/btrfs-usr-oem from flatcar/scripts#131 in http://jenkins.infra.kinvolk.io:8080/job/os/job/manifest/3029/cldsv/ where the Flatcar image that has a btrfs /usr partition and OEM partition.
While the actual switch to a btrfs filesystem on the /usr partition is only possible when all changes are part of a Stable release because update-engine needs to know how to handle the new filesystem when updating, we can already do the switch for the OEM partition.

pothos added 2 commits July 23, 2021 16:44
The /usr partition should not be modified during mounting, even if it
has some corruption. Rewriting the filesystem log would cause dm-verity
errors when dm-verity is enabled later again. While the /usr partition
normally is on a dm-verity block device in read-only mode there is some
option to mount the partition without dm-verity and it wouldn't be a
read-only block device anymore.
Add the norecovery mount option which is supported for ext4 and btrfs.
The hash offset is found by looking at the filesystem size. When
e2size can't find the size it returns "Success" in stderr for whatever
reason and fortunately still returns an error exit code, stdout stays
empty. This means that the dm-verity device setup won't work because
the hash offset is the empty string. However, the hash offset is
actually fixed because the GPT disk layout has to stay the same in
Flatcar Container Linux as the partition contents are swapped out
when updating. In case another filesystem like btrfs is used, e2size
doesn't work and it makes sense to fall back to the only value which
is supported in general.
Hard code the hash offset value coming from the /usr filesystem size
defined in flatcar-scripts/build_library/disk_layout.json.
@pothos pothos force-pushed the kai/verity-hash-offset branch from 40815dd to 0568f03 Compare July 23, 2021 14:44
@pothos pothos merged commit d5bd238 into flatcar-master Jul 28, 2021
@pothos pothos deleted the kai/verity-hash-offset branch July 28, 2021 11:20
pothos added a commit to flatcar-archive/coreos-overlay that referenced this pull request Jul 28, 2021
t-lo pushed a commit to flatcar/scripts that referenced this pull request Apr 17, 2023
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.

3 participants