Skip to content

Signed, verity-protected, live configuration updates: confext #24864

Open

Description

@bluca

The ‘confext’ concept follows the same principle as the sysext functionality. sysext allows to extend the host filesystem (or a unit’s) at runtime with signed images that add new files to /usr and /opt, using OverlayFS. In the same fashion, confext will extend /etc (and only /etc).

And just like sysext, confext will be supported at the host level (e.g.: to update /etc/foo), at the system service level and at the portable service level. In the latter two cases, the update will happen only inside the private namespace of the relevant units. ExtensionImages will gain support for confexts, just as they already support sysexts.

confext volumes will support signed dm-verity, as sysext volumes already do, both with split artifacts (.raw, .verity, .roothash, .roothash.p7s), and in GPT volumes.

Host-wide images will be loaded from specific directories in /var and /run, like sysext. For units there will be a new unit setting that points to an individual image or to a directory containing multiple images, which can be located where desired.

The image names will follow the same rules as the sysext images, with an addition: unit-specific confext will need to be prefixed with the unit’s name.
The images will contain a /etc/extension-release.d/extension-release.<NAME>, where must match the image name (with the usual escape hatch of xattr), and with content being one or more of ID, VERSION_ID, and CONFEXT_LEVEL=. Config images will then be checked and matched against the base OS layer.

The systemd-sysext tools will be made multi-call, and when called with systemd-confext it will work on confext images instead of sysext images.

The systemctl reload, try-reload-or-restart, etc. verbs (and equivalent D-Bus APIs) will be enhanced to set up the new overlay for each unit, if a unit-specific new volume is found, before sending the reload/restart signal when the image is deployed.

Versioning will be fully supported, using the vpick mechanism. Following the RPM version comparison specification, the newest version of each image will be loaded automatically when a directory is specified.

There will be support for automatically marking every unit that is using ExtensionImages= with versioned confext for needs-reload, so that later the existing reload --marked can be issued.

For a rollback, it will happen automatically if the service fails after a try-reload-or-restart. For rollback protection, we have the dm-verity hash blocklist mechanism that is already used for all other verity images. The forthcoming TPM-based counter could also be used for this, after it has been implemented for UKIs (Unified Kernel Images).

Tasks:

  • Implement systemd-confext functionality to systemd-sysext and tests in TEST-50-DISSECT
  • Implement confext support in ExtensionImages=
  • Add support picking the newest image using vpick version comparison from directory
  • Hook up systemctl reload and other methods with reloading confext images configured via ExtensionImages= and tests in TEST-50-DISSECT
  • Add functionality that marks units using a confext with vpick, where a new version is available, with the 'needs-reload' marker
  • Hook up rollback of vpick confext with Restart= and good/bad counters

Activity

  1. added
    RFE 🎁
    on Sep 29, 2022
  2. poettering commented on Sep 30, 2022

    @poettering
    Member

    hmm, I wonder if we should have something similar to the extension-release stuff. I think we need to make sure:

    1. that syscfg images are recognizable as that internally
    2. that you can securely enumerate active syscfg entries
    3. that the name of the syscfg image file on disk can be validated somehow against cryptographically protected information (i.e. something stored inside the image).

    Hence dunno what to propose here, but I am pretty sure we want something like /etc/configuration-release.d/ or so?

  3. poettering commented on Sep 30, 2022

    @poettering
    Member

    also, i wonder if syscfg and sysext should be somehow validated against different keyrings. i.e. I'd assume sysext would come from a vendor, while syscfg might come from a tenant, if you so will, so they probably should by signed and validated against different keyrings.

  4. poettering commented on Sep 30, 2022

    @poettering
    Member

    next question: mutability.

    For sysext I think there's an easy case to be made that /usr/ is immutable, always.

    But for syscfg//etc/ I think immutability is much less of an obvious choice. There certainly usecases I agree with where a mutable /etc/ + syscfg makes a ton of sense. Think a ChromeBook style device that shall carry local settings in combination with employer settings (i.e. signed syscfg). While I don't think we have to support such "half-way" mutability of /etc/ right away I think we should at least think about it, and have an avenue for it. I mean, we have hostnamed/localed and so on, which make local system changes, we probably should allow them to do something useful somehow...

    So what could mutability with syscfg mean? I guess it could mean:

    1. We change the stacking of the overlayfs, and put the host /etc/ on top, instead of bottom, and allow it to be written to.
    2. We introduce /etc.local/ or so, which is overlayed on top of the stack, and is writable.

    I think I dislike the first option, because it systematically changes what can override what. The second option sounds much better to me. So what about this: eventually add --mutable= to systemd-sysext/systemd-syscfg that takes one of "no" (default), "local", "ephemeral", "auto". They would mean:

    1. no = evertyhing is immutable
    2. local = we create /etc.local/ if it is missing and put it on top of the overlayfs stack, and make the stack writable
    3. ephemeral = we mount an otherwise not mounted tmpfs as top layer of the overlayfs, so that changes can be made, but they are lost when the system goes down.
    4. auto = if /etc.local/ exists act like local, otherwise like no.

    (and we might want to allow the same for /usr/ I guess, with /usr.local/, because there's little reason not to, and it's easy to add.)

  5. bluca commented on Sep 30, 2022

    @bluca
    MemberAuthor

    hmm, I wonder if we should have something similar to the extension-release stuff. I think we need to make sure:

    1. that syscfg images are recognizable as that internally
    2. that you can securely enumerate active syscfg entries
    3. that the name of the syscfg image file on disk can be validated somehow against cryptographically protected information (i.e. something stored inside the image).

    Hence dunno what to propose here, but I am pretty sure we want something like /etc/configuration-release.d/ or so?

    What would be the content? For sysext it's used to enforce ABI.

    also, i wonder if syscfg and sysext should be somehow validated against different keyrings. i.e. I'd assume sysext would come from a vendor, while syscfg might come from a tenant, if you so will, so they probably should by signed and validated against different keyrings.

    We can't quite do that kernel-wise right now, so it would have to be handled separately. Also keys used to sign can be changed, our implementation should be independent.

    next question: mutability.

    For sysext I think there's an easy case to be made that /usr/ is immutable, always.

    But for syscfg//etc/ I think immutability is much less of an obvious choice. There certainly usecases I agree with where a mutable /etc/ + syscfg makes a ton of sense. Think a ChromeBook style device that shall carry local settings in combination with employer settings (i.e. signed syscfg). While I don't think we have to support such "half-way" mutability of /etc/ right away I think we should at least think about it, and have an avenue for it. I mean, we have hostnamed/localed and so on, which make local system changes, we probably should allow them to do something useful somehow...

    So what could mutability with syscfg mean? I guess it could mean:

    1. We change the stacking of the overlayfs, and put the host /etc/ on top, instead of bottom, and allow it to be written to.
    2. We introduce /etc.local/ or so, which is overlayed on top of the stack, and is writable.

    I think I dislike the first option, because it systematically changes what can override what. The second option sounds much better to me. So what about this: eventually add --mutable= to systemd-sysext/systemd-syscfg that takes one of "no" (default), "local", "ephemeral", "auto". They would mean:

    1. no = evertyhing is immutable
    2. local = we create /etc.local/ if it is missing and put it on top of the overlayfs stack, and make the stack writable
    3. ephemeral = we mount an otherwise not mounted tmpfs as top layer of the overlayfs, so that changes can be made, but they are lost when the system goes down.
    4. auto = if /etc.local/ exists act like local, otherwise like no.

    (and we might want to allow the same for /usr/ I guess, with /usr.local/, because there's little reason not to, and it's easy to add.)

    I'm not sure, for these use cases immutability (and changes via small additive images) is what we want? If changing things locally, unsigned, is allowed, then the whole concept of being able to track exactly what is changed by what and cryptographically verify it goes out of the window, no?

  6. poettering commented on Sep 30, 2022

    @poettering
    Member

    What would be the content? For sysext it's used to enforce ABI.

    Well, IMAGE_ID comes to mind, and I think something like sysext api level probably also makes sense: there's value in being able to say that some config is for some specific type of underlying image.

  7. poettering commented on Sep 30, 2022

    @poettering
    Member

    I'm not sure, for these use cases immutability (and changes via small additive images) is what we want? If changing things locally, unsigned, is allowed, then the whole concept of being able to track exactly what is changed by what and cryptographically verify it goes out of the window, no?

    Well, depends on the usecase. Being able to clearly say "this is local configuration" for stuff that was modified locally is worth a lot already. Really depends on policy.

    The way I see it, configuration can come from different sources, different teams, and it is combined locally into one thing. Being able to say "hey, this is from source/team Y" and "this other stuff is from source team X" and "this other stuff was locally changed" is worth a lot. That doesn't mean one wants to allow Y, or Y or local stuff to always even make changes, but that's something to solve via keyrings, and the aforementioned --mutable= switch.

    What I would love btw, if overlayfs would pass through the FS_IMMUTABLE_FL thing. If we had that then layers could mark files and directories with that, and this would disallow changes via the topmost, writable layer? I think that would be quite nice: allowing lower layers to control where the uppermost writable layer actually allows changes and where not.

  8. daandemeyer commented on Nov 1, 2022

    @daandemeyer
    Collaborator

    Supporting some way of declaring global ConfigurationImages= might make sense to reload/restart all services if a crucial "global" shared configuration file changes, with maybe an exclude mechanism for the few services that would need to ignore these global syscfgs. Global service overrides are already a thing which would enable this, and services that need to override the global list could assign the empty string to empty the list, so I'm not sure if we need to add anything specific to support this.

  9. pothos commented on Feb 14, 2023

    @pothos
    Collaborator
    • no = evertyhing is immutable

    • local = we create /etc.local/ if it is missing and put it on top of the overlayfs stack, and make the stack writable

    • ephemeral = we mount an otherwise not mounted tmpfs as top layer of the overlayfs, so that changes can be made, but they are lost when the system goes down.

    • auto = if /etc.local/ exists act like local, otherwise like no.

    For local it would be nicer to directly mount with upperdir=/etc instead of creating a new separate folder. That leaves the same /etc path usable with or without syscfg running. The only drawback I see is that the overlayfs marker device nodes for wiped out files will be in there but it prevents many other problems that would occur when the mount is not set up.
    With this done we could let auto case be based on whether the workdir exists or not.

  10. poettering commented on Feb 14, 2023

    @poettering
    Member

    @pothos so far we said that any installed sysext override the underlying data in /usr/, though we try to tell people that sysext images should be additive, and thus not make changes or delete stuff. But we can't really stop people from doing so. I'd alaways assume that syscfg and sysext would use the same stacking order. Which conflicts with your proposal, since you'd put the local config top, not bottom...

    But that certainly raises the question: should the stacking order for syscfg and sysext be different in this regard?

  11. pothos commented on Feb 14, 2023

    @pothos
    Collaborator

    Yes, I should have better quoted the first two items for this general question. Re-reading it I now understood that the original /etc contents would be around in the other case, too, but changes are done in /etc.local? I'm not sure that is easy to handle for users when syscfgs don't load or aren't wanted anymore. While I think a read-only overlay mode that behaves exactly like sysext somehow makes sense, I see more use cases for the mutable mode because a vendor syscfg would supply the underlying configuration that the user can customize where needed and all other files still get updated when the vendor syscfg changes. So yes, the stacking order for the mutable case should be different from my perspective, and sysext contents always have a lower priority (that is also the case with the /etc.local proposal once something triggers the up-copy).
    The ready-only overlay mode could have a different stacking order in general compared to sysext but I think what makes sense depends on the nature of the underlying /etc - it could be a full blown setup like in Debian as of now and we want to make sure that a syscfg takes priority because there could be stuff in /etc that we are not aware of, or it could be that the local state in /etc is so minimal and intentional that it could be treated like a local syscfg that (while not dm-verity protected unless we have some on-the-fly-machine-id-syscfg generator) gets "sealed" on boot and could be layered on top no problem because of it's intentional and minimal content. To keep at least some consistency between syscfg and sysext I would say that for the read-only default we follow the current behavior of sysext but for the mutable mode we use a different order and support /etc or /usr as direct upper dir (For /usr I really think that /usr.local is a bad idea because for traditional systems the package DBs get copied and can't expect sysext to be always on, e.g., in repair scenarios or after it got disabled for whatever reason).

  12. pothos commented on Mar 17, 2023

    @pothos
    Collaborator

    We have done such a setup now in Flatcar for /etc where we have /usr/share/flatcar/etc as lowerdir and the original /etc as upperdir. It works well to disable the overlay mount again and use the system as before. In our case we expect upcopies to be done because the lowerdir provides OS defaults which the user can change - I think providing OS defaults would be a nice usecase for syscfg and we would be happy to migrate away from our custom initrd mount logic. The upcopies are handled quite ok with the redirect_dir=on,metacopy=off,noatime options. Of course, when stopping to use the overlay after upcopies were done, there remains are left in the original /etc but shouldn't be a big problem (overlay xattrs for directories or the special masking character devices when deleting files from the lowerdir) compared to ending up in a split state as would be the case with, e.g., /etc.local as upperdir.
    As mentioned before, such a mutable overlay setup would work well with sysext for /usr, too, and allow sysext images to be used on Debian or Fedora. With sysext images only providing additional files, the system works exactly as before, just in the case where the sysext would provide same files the real /usr wins but that's anyway the case as soon as the file gets overwritten since the syscfg/sysext is not on top of the stack but changes in /etc.local//usr.local would win. So I don't see a real benefit and would rather focus on making it easy for users to run syscfg/sysext and stop using them again without having to reconcile their broken system.

  13. changed the title [-]Signed, verity-protected, live configuration updates: syscfg[/-] [+]Signed, verity-protected, live configuration updates: confext[/+] on Apr 12, 2023
  14. pothos commented on May 31, 2023

    @pothos
    Collaborator

    @t-lo, @poettering, and myself got a chance to discuss the above in person. Here is a short summary:

    • Three modes make sense, read-only (the current default), writable, and ephemeral.
    • The default would be to detect the wanted mode based on the presence of the additional /X.local directory (where X is "etc", "usr", or "opt").
    • The configuration of a wanted mode could be done through a config file (confext.conf/sysext.conf) or command line flag.
    • Currently we only set up an overlay mount on /opt if /opt is shipped by a sysext (and we only set up the mount on /etc or /usr if a confext/sysext exists), this should change and the "merge" should always result in a mount, even if no extension image ships files for the path.
    • The writable mode could be clever during overlay assembly: If /X.local points to /X then we skip /X as lowerdir and only use it as upperdir (extra redirect_dir/metacopy_off/noatime mount options mentioned in the post above for this special case could either be added by default or through configuration). Never use a read-only mount as upperdir, this will always be the last lowerdir then. These two should allow for /opt being writable with a read-only /usr.

    Did I forget anything?

  15. 4 remaining items

  16. poettering commented on Jun 1, 2023

    @poettering
    Member
    • Currently we only set up an overlay mount on /opt if /opt is shipped by a sysext (and we only set up the mount on /etc or /usr if a confext/sysext exists), this should change and the "merge" should always result in a mount, even if no extension image ships files for the path.

    quick note: this mount could just be a read-only bind mount onto itself btw. i.e. no need to use overlayfs with its slightly unposix semantics if only a single layer is in effect and we just need to make it read-only.

  17. poettering commented on Jun 1, 2023

    @poettering
    Member

    write ups sounds good to me, btw.

  18. poettering commented on Jun 1, 2023

    @poettering
    Member

    and in case anyone wonders: if /usr.local/ exists and people call systemd-sysext refresh --mode=ephemeral then this should mean that /usr.local/ is included in the read-only stack of layers and the ephemeral tmpfs is used as writable layer. or in other words: if /usr.local/ exists it is always honoured, in all three modes. The --mode=read-only|writable|ephemeral choice simply controls whether to make top layer writable, and which one.

  19. jcpunk commented on Jun 1, 2023

    @jcpunk
    Contributor

    How would this interact with selinux labels as /usr/ has a bunch of mappings in place, but /usr.local does not.

  20. bluca commented on Jun 1, 2023

    @bluca
    MemberAuthor

    The default would be to detect the wanted mode based on the presence of the additional /X.local directory (where X is "etc", "usr", or "opt").

    Not super enthusiastic about locating these on the root filesystem. We just managed to clean it up a bit (some still are...) from the legacy spread of directories. Extensions are stored in /var anyway, so I'd prefer if these local overrides were stored under /var too. Apart from decluttering the root directory, it also allows it to be read-only. On a read-only root system, you wouldn't be able to move the symlink as suggested to achieve the different layouts.

    Currently we only set up an overlay mount on /opt if /opt is shipped by a sysext (and we only set up the mount on /etc or /usr if a confext/sysext exists), this should change and the "merge" should always result in a mount, even if no extension image ships files for the path.

    Why is this necessary? It will result in extra moving parts (and thus extra things that can go wrong), could that be avoided?

  21. pothos commented on Jun 5, 2023

    @pothos
    Collaborator

    How would this interact with selinux labels as /usr/ has a bunch of mappings in place, but /usr.local does not.

    The /usr.local as backing folder for the overlayfs upperdir shouldn't be used directly, only through /usr - nothing special should be needed from my understanding.

    Regarding always setting up a mount for, e.g., /opt independent on the sysext contents or if there are syexts, I think it's necessary for consistent behavior. The first case about changing contents of a sysext is already a problem, and you get /opt read-only or not depending on whether /opt files are shipped or whether this sysext stopped matching. The second about usable sysexts being there or not is also good to ensure that merge --mode= always sets up the same mount and we don't switch between writable or read-only depending on sysexts being there or stopping to match.

  22. t-lo commented on Jun 5, 2023

    @t-lo
    Contributor

    The default would be to detect the wanted mode based on the presence of the additional /X.local directory (where X is "etc", "usr", or "opt").

    Not super enthusiastic about locating these on the root filesystem. We just managed to clean it up a bit (some still are...) from the legacy spread of directories. Extensions are stored in /var anyway, so I'd prefer if these local overrides were stored under /var too. Apart from decluttering the root directory, it also allows it to be read-only. On a read-only root system, you wouldn't be able to move the symlink as suggested to achieve the different layouts.

    Not feeling strongly towards either - e.g. /var/extensions/usr.local would work fine for us too, or even /run/extensions/usr.local for ephemeral mode. @poettering how do you feel about this?

  23. linked a pull request that will close this issuemaanya/portable and portablectl #28848on Aug 16, 2023
  24. goenkam commented on Mar 18, 2024

    @goenkam
    Contributor

    @bluca could you please attach a link to the 'reload --marked' PR / work item to the description too, if there is one?

  25. reopened this on May 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFE 🎁pid1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions