Skip to content

Conversation

@0xC0ncord
Copy link
Contributor

Pull in the dracut policy module from Gentoo and get it working with modern systems. For this, we:

  1. Add the dracut policy module as-is from Gentoo.
  2. Also add a policy module for installkernel. This tool is used on several distros (including Gentoo) as a helper for calling the necessary utilities for installing a kernel. In our case, this tool can be used to call into dracut.
  3. Apply a bunch of a fixes to the dracut module to get it working as needed.

The workflow I tested is installing a hostonly kernel via the kernel's make install, which calls installkernel and then dracut. Happy to share the dracut config if needed.

Normally dracut has helper scripts that get installed by other system tools (e.g. ZFS) that allow it to handle installing those components as needed. I only tested the tools that I am using personally, so there may be others that need looking into as well.

corecmd_exec_bin(dracut_t)
corecmd_exec_shell(dracut_t)
corecmd_mmap_all_executables(dracut_t)
corecmd_delete_all_executables(dracut_t)
Copy link
Member

@pebenito pebenito Jan 21, 2026

Choose a reason for hiding this comment

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

What's happening here (the delete in particular)?

Copy link
Member

Choose a reason for hiding this comment

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

Related: there's also deletions in the files_* block and others.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's happening here is installkernel creates the staging area for the initrd in /tmp. dracut copies all the binaries, shared libs, config files, etc. for all the components needed to boot the system to its own directory in the staging area. dracut also relabels all the files to the correct type so that the SELinux contexts inside of the initrd are correct. After the initrd is created, dracut recursively deletes this temporary directory and all its contents.

The delete access here is a rather unfortunate byproduct of the fact that these objects are copied and then deleted while having their destination SELinux contexts.

Copy link
Member

Choose a reason for hiding this comment

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

Can you file a bug to have it use mv/install -Z? I would prefer to have a comment in the policy with a reference to a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't mind submitting an issue about the current behavior, but I'm not sure what mv/install -Z will do that is different from what is here currently. Let me know if I am misunderstanding something.

I think our shared concern is that the policy permits the deletion of sensitive files (e.g. shadow_t), so I think what we might really want is for dracut to be in a different domain that can only normally be transitioned to from dracut_t that does the cleanup, e.g. dracut_cleanup_t, and this domain is what is permitted to delete these files.

Copy link
Member

Choose a reason for hiding this comment

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

If they use install -Z then it would be getting the expected label as it is written out, without having to label it in the tmp dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I see now. I'll do some investigating. If the change is easy enough then we might be able to just submit a patch.

Signed-off-by: Kenton Groombridge <concord@gentoo.org>
Upstreaming current version of the dracut policy from Gentoo.

Signed-off-by: Kenton Groombridge <concord@gentoo.org>
Signed-off-by: Kenton Groombridge <concord@gentoo.org>
Signed-off-by: Kenton Groombridge <concord@gentoo.org>
dracut uses fsfreeze when building an initrd.

Signed-off-by: Kenton Groombridge <concord@gentoo.org>
Upstream a change from Gentoo to allow readers of udev rules runtime dir
access to read udev rules in /run/udev/rules.d.

Signed-off-by: Kenton Groombridge <concord@gentoo.org>
@0xC0ncord 0xC0ncord force-pushed the installkernel-dracut branch from fe293d4 to 88e9a96 Compare January 22, 2026 16:16
@0xC0ncord
Copy link
Contributor Author

Also upstreamed some minor adjustments to the udev_read_rules_files() and portage_read_config() interfaces found while rebasing this PR on top of my testing branch there.

udev_read_rules_files() now grants search acccess to /run/udev so that rules readers can access rules in /run/udev/rules.d.

portage_read_config() grants some additional accesses needed on config files.

## </summary>
## </param>
#
interface(`portage_read_config',`
Copy link
Member

Choose a reason for hiding this comment

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

Please split to portage_read_config and portage_mmap_read_config.

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.

2 participants