Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support rpm-ostree initramfs --enable-overlay #1930

Closed
cgwalters opened this issue Oct 17, 2019 · 15 comments
Closed

Support rpm-ostree initramfs --enable-overlay #1930

cgwalters opened this issue Oct 17, 2019 · 15 comments

Comments

@cgwalters
Copy link
Member

Moving this from ostreedev/ostree#1936 - quoting

For CoreOS we have need for networking in the Initramfs for encrypted disks with Clevis/Tang unlock. The problem, though, is that we cannot reliably assume that the DHCP, as the user may have on-disk networking. In talking with @cgwalters the idea of having a layered Initramfs that provides certain files (such as Network configuration), would help to solve this use case and other others.

Basically we want rpm-ostree initramfs --enable-overlay.

This would also fix fedora-silverblue/issue-tracker#3

@cgwalters
Copy link
Member Author

OK so looking at this, we'd have to basically reimplement parts of dracut that "know" which files from /etc to grab.

And specifically for networking...ugh. A whole lot going on here.

@darkmuggle
Copy link

@cgwalters another interesting idea: KARGs? Dracut modules use /etc/cmdline.d for potential defaults. For OCP, setting KARGs could be easier if all the MCO has to do is drop a file, and then its picked up, instead of issuing a rpm-ostree command.

@cgwalters
Copy link
Member Author

Yeah, just requiring users specify kernel args for networking for the tang case would work.

@cgwalters
Copy link
Member Author

OK so this came up again for https://bugzilla.redhat.com/show_bug.cgi?id=1775917 and I realized that anyone who needs this today can do:

rpm-ostree initramfs --enable --arg=-I --arg=/etc/vconsole.conf
to include /etc/vconsole.conf - same for any other config files.

This doesn't scale really well in that one needs to enumerate all config files that one needs, but it's there if needed.

@cgwalters
Copy link
Member Author

@jlebon
Copy link
Member

jlebon commented Nov 28, 2019

This will require work in libostree too, since right now it can only handle one initrd key in the BLS configs.

@jlebon
Copy link
Member

jlebon commented Nov 28, 2019

The FIPS mode use case should also be taken into account when designing this. See: https://gitlab.com/redhat-crypto/fedora-crypto-policies/merge_requests/53#note_251907083.

@jlebon
Copy link
Member

jlebon commented Nov 28, 2019

Ahh OK, so the semantics you were thinking of was that there was a single overlay, and we have a list of /etc files somewhere that we know to bring in? Hmm, feels like we might need more flexibility than that.

Wonder if this shouldn't be a separate command instead, e.g. rpm-ostree initramfs-overlay [add|remove] [/etc/file1] [/etc/file2] ...?

Then rpm-ostree initramfs is solely about regenerating the primary initrd, while initramfs-overlay is just about the overlay. (The former being a more drastic measure than the latter. I guess this is parallel with how we split layering packages from base overrides too.)

@jlebon
Copy link
Member

jlebon commented Nov 28, 2019

(The former being a more drastic measure than the latter. I guess this is parallel with how we split layering packages from base overrides too.)

Although, testing now it seems like overlaid initrds will happily shadow base content. So it's not exactly the same situation (though... even layered packages can still change base content via scriptlets, so maybe it is still apt).

@jlebon
Copy link
Member

jlebon commented Apr 16, 2020

Cross-referencing: dracutdevs/dracut#792

One thing I wanted to follow up with @cgwalters here that was mentioned there:

Well I was pushing back against using initramfs mutation for this because it conflicts with any approach to signing, it's mixing code and configuration

When you say "initramfs mutation", are you still referring to overlaying a second initrd or rebuilding the initrd? (Though maybe the question is moot since overlaying is still definitely modifying the initrd rootfs in the end).

I'm not familiar with initrd signing, but it sounds interesting. Does that system not have mechanisms for initrds rebuilt on the machine (given that it's the case today for the majority of systems)? If so, we could reuse that for the overlay initrd.

@cgwalters
Copy link
Member Author

When you say "initramfs mutation", are you still referring to overlaying a second initrd or rebuilding the initrd? (Though maybe the question is moot since overlaying is still definitely modifying the initrd rootfs in the end).

Mostly the latter, but even an initramfs overlay is injecting code.

I'm not familiar with initrd signing, but it sounds interesting. Does that system not have mechanisms for initrds rebuilt on the machine (given that it's the case today for the majority of systems)? If so, we could reuse that for the overlay initrd.

Well, there are a few approaches to it. One is actually to concatenate the kernel+initramfs together and sign that whole thing.

And you're right, any system that allows signing can work "client side" too...if you follow the musings in ostreedev/ostree#1959 (and earlier) anything using signing/verity basically either needs to support users doing their own signatures on their privileged code, or not support privileged code at all.

jlebon added a commit to jlebon/rpm-ostree that referenced this issue Oct 23, 2020
This command allows users to cheaply inject configuration files in the
initramfs stage without having to regenerate the whole initramfs (or
even a new OSTree commit). This will be useful for configuring services
involved in bringing up the root block device.

```
$ echo 'hello world' > /etc/foobar
$ rpm-ostree ex initramfs-etc --track /etc/foobar
Staging deployment... done
Run "systemctl reboot" to start a reboot
$ rpm-ostree status
State: idle
Deployments:
  ostree://fedora:fedora/x86_64/coreos/testing-devel
                   Version: 32.20200716.dev.1 (2020-07-16T02:47:29Z)
                    Commit: 9a817d75bef81b955179be6e602d1e6ae350645b6323231a62ba2ee6e5b9644b
              GPGSignature: (unsigned)
              InitramfsEtc: /etc/foobar

● ostree://fedora:fedora/x86_64/coreos/testing-devel
                   Version: 32.20200716.dev.1 (2020-07-16T02:47:29Z)
                    Commit: 9a817d75bef81b955179be6e602d1e6ae350645b6323231a62ba2ee6e5b9644b
              GPGSignature: (unsigned)
$ reboot
(boot into rd.break)
sh-5.0# cat /etc/foobar
hello world
```

See the libostree side of this at:
ostreedev/ostree#2155

Lots more discussions in:
coreos/fedora-coreos-tracker#94

Closes: coreos#1930
@tunix
Copy link

tunix commented Dec 10, 2022

Would this also work for allowing bluetooth at LUKS decryption screen?

@jlebon
Copy link
Member

jlebon commented Dec 12, 2022

Would this also work for allowing bluetooth at LUKS decryption screen?

For that, I think you'd be better served by rpm-ostree initramfs --enable. And you'll likely also want to add --arg=--add --arg=bluetooth.

@tunix
Copy link

tunix commented Dec 12, 2022

Would this also work for allowing bluetooth at LUKS decryption screen?

For that, I think you'd be better served by rpm-ostree initramfs --enable. And you'll likely also want to add --arg=--add --arg=bluetooth.

Unfortunetely that only includes files inside /etc but not /var/lib/bluetooth so you miss the paired device metadata.

@jlebon
Copy link
Member

jlebon commented Dec 12, 2022

Would this also work for allowing bluetooth at LUKS decryption screen?

For that, I think you'd be better served by rpm-ostree initramfs --enable. And you'll likely also want to add --arg=--add --arg=bluetooth.

Unfortunetely that only includes files inside /etc but not /var/lib/bluetooth so you miss the paired device metadata.

Gotcha. Thanks for bringing this up. We currently don't expose /var to dracut but it could make sense to do so for use cases like this. Can you file a separate issue for this?

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

No branches or pull requests

4 participants