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

expose efi variables to privileged host containers #2714

Merged
merged 2 commits into from
Jan 9, 2023

Conversation

bcressey
Copy link
Contributor

@bcressey bcressey commented Jan 7, 2023

Issue number:

#2501

Description of changes:
Build systemd with the "efi" option set, so that systemd will mount efivarfs on boot under /sys/firmware/efi/efivars.

For privileged host containers, mount /sys/firmware with the "rbind" option so that child mounts such as efivarfs are also propagated.

Testing done:
Confirmed that /sys/firmware/efi/efivars shows up in the admin container, and that it can be read from and written to by commands like mokutil.

[bottlerocket@admin]$ mokutil --sb-state
SecureBoot disabled

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

The main side effect of this is to cause systemd to mount efivarfs,
when the system is booted under EFI.

Signed-off-by: Ben Cressey <[email protected]>
This makes `/sys/firmware/efi/efivars` available to superpowered host
containers, which is useful to allow administrators to inspect Secure
Boot state.

Signed-off-by: Ben Cressey <[email protected]>
Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦺

@@ -781,6 +781,12 @@ func withPrivilegedMounts() oci.SpecOpts {
Source: "/usr/src/kernels",
Type: "bind",
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it make sense to make this mount read-only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per efivarfs docs:

Due to the presence of numerous firmware bugs where removing non-standard UEFI variables causes the system firmware to fail to POST, efivarfs files that are not well-known standardized variables are created as immutable files. This doesn’t prevent removal - “chattr -i” will work - but it does prevent this kind of failure from being accomplished accidentally.

For the most part they're marked as immutable already, and anyone running in the admin container will also be able to remount the filesystem read-write.

mokutil uses some of these variables to pass update requests to shim, which then verifies physical presence (or at least console access) as well as knowledge of a password before actually updating the variable. So there's at least one use case for having a read-write filesystem, even though I don't expect it to be used very often.

@bcressey bcressey merged commit 756f33c into bottlerocket-os:develop Jan 9, 2023
@bcressey bcressey deleted the expose-efivars branch January 9, 2023 23:44
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.

5 participants