Repository navigation
udev: new "image_dissect" builtin that can be used to generate symlinks based on partition designators - #36631
Merged
Merged
Conversation
daandemeyer
requested changes
Mar 6, 2025
YHNdnzj
reviewed
Mar 6, 2025
poettering
force-pushed
the
dissect-udev-prove-v2
branch
from
March 6, 2025 20:57
80e0643 to
3daeb32
Compare
Member
Author
|
this needs more thinking, don't bother reviewing. the security angle matters a lot, i.e. how to apply image policy. |
Member
Author
|
current thinking:
|
poettering
force-pushed
the
dissect-udev-prove-v2
branch
from
March 14, 2025 15:56
3daeb32 to
feddda9
Compare
Member
Author
|
So this is a much more comprehensive solution, fully taking the image policy into account. There's now /dev/disk/by-designator/* and it creates symlinks for verity + luks too there, so that everything's there. with this in place we can relatively easily add support for also setting up verity this way, so that we can finally take verity signature data into account for mounting the root/usr file systems too. |
Member
Author
|
(this would then also be an alternative to #34413) |
poettering
force-pushed
the
dissect-udev-prove-v2
branch
from
March 14, 2025 17:20
feddda9 to
5173db9
Compare
yuwata
requested changes
Mar 14, 2025
poettering
force-pushed
the
dissect-udev-prove-v2
branch
from
March 17, 2025 15:02
5173db9 to
009b095
Compare
Member
Author
|
(setting green label, since @bluca already gave it before) |
…just look at /
So far the gpt-auto symlinks would point to:
1. the disk the ESP/XBOOTLDR is located on
2. or to a loopback device whose filename field is set to "rootdisk"
or "rootdisk.raw"
This makes sense in the initrd. But once we transition to the host this
is quite confusing, since the symlinks might point to a different place
than what we actually ended up transitioning too: the actual backing
device of the root file system might be different from what gpt-auto
found.
Let's clean this up: let's avoid any ambiguities here: let's extend the
rules above with one more rule:
3. if we left the initrd, we'll make gpt-auto point to the selected
root file system, if it otherwise would have been a candidate.
Or in other words, the ID_PART_GPT_AUTO_ROOT_DISK=1 udev property now
always makes sense: in the initrd it points to the future root disk, and
on the host to the actual root disk.
Fixes: systemd#34319
…/verity-sig Previously, if during early enumeration of the partition table we figured out we have a verity + verity-sig partition, we determined we are "ready" to do verity/verity-sig, as reported by the "verity_ready" and "verity_ready_sig" fields of DissectedImage. Let's rework this: only determine we are ready in case the VeritySettings structure is fully populated. Mark verity-sig/verity only as ready once we actually *load* the verity sig metadata from the special partition. This is conceptually more correct, as we consider things "ready" only if we actually have all data for it loaded. It's also preparation for a later commit that guesses the verity root hash based on what we discover.
When dissecting an image, let's make use of the Verity data even if we got told no root hash explicitly: we can simply determine it by concatenating the data partition uuid with the verity partition uuid. Of course, on first thought this doesn't really add much: if the root hash is not pinned from somewhere, this does not guarantee trust in the image. However, this is very useful for attestation: if we have the root hash we can measure it before mounting things, even if we don't actually authenticate it. Hence, at best this helps us with attestation, at worst it doesn't improve security but certainly doesn't hurt it.
Previously if we found a verity signature partition in an image, and the image policy required "verity" (but did not allow "signature") we'd refuse the image. This is of course unnecessarily strict: if "verity" is allowed, we can make use of the verity data, and ignore the signature data. hence, relax the rules here: when we pick up a partition and want to test it against the policy, always consider all "weaker" uses too, maybe they are allowed if the "stronger" users isn't.
This introduces root=dissect, which is a lot like root=gpt-auto, but uses the image dissection logic to find the root partition. It's also based on the GPT efi var telling us about the root disk, but instead of just picking some suitable root disk manually it uses the dissection logic. This is a big step forward, since it means we can actually make use of the image policy logic for the root fs too.
This is useful when booting into storage target mode, where we do not want to enter a root fs, we just want to stay forever in the initrd, and hence there's value in not even generating and jobs to find the rootfs
So far, we did not support auto-discovery the /usr/ partition at boot. Change that: on explicit request (i.e. mount.usr=dissect) automatically discover the /usr/ partition based on our usual dissection logic.
…matically So far the gpt-auto-generator would only cover unprotected and encrypted partitions. Teach it handling of verity too.
DDIs may contain multiple versions of the same OS, or even multiple OSes. Hence it makes sense to not just pick the "newest", whatever that might be, but only partitions associated with specific images, or in a specific version. Let's a concept for such filtering: a per-designator glob expression that can be applied to the partition label string, and can be used for such filtering. Usecase: when picking UKI belonging to OS image X in version Y, make sure we only pick a /usr/ partition belonging to X in version Y, and a root and home partition belonging to X in any version. This only adds the basic infrastructure, but doesn't actually expose it anywhere.
…_mount() into a structure
…re logic, retry without Currently, there's no nice way to get a key into the dm-verity kernel keyring unless recompiling the kernel, or enabling SB or buying into shim. Neither sounds particularly attractive. hence provide a reasonable fallback: if unlocking with signed roothash doesn#t work, just try without. maybe the kernel policy allows this, maybe not. It's worth a try.
We generally let gpt-auto-generator write to the "late" generator dir, so that the explicit fstab-generator can write to the "middle" one. And I think we should leave it that way. But we also want to override the generic systemd-fsck-root.service service potentially, and if we'd do that in the "late" generator dir, it would be pointless, since that's ordered *after* the static version hence would never be taken into consdiration. Hence clean this up: keep writing to the late dir for everything, except for the fsck stuff.
poettering
force-pushed
the
dissect-udev-prove-v2
branch
from
April 3, 2025 09:09
1512780 to
50270ec
Compare
Member
Author
|
CI failures are unrelated. Let's merge. |
knelsonmeister
pushed a commit
to knelsonmeister/systemd
that referenced
this pull request
Apr 23, 2025
Needed for systemd/systemd#36631 Gbp-Dch: ignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This replaces #36209 and implements this via a new builtin, rather than by shelling out to systemd-dissect.
Replaces: #36209
Replaces: #28894
Fixes: #34319
Fixes: #33453
Fixes: #27897
Fixes: #18035