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

Dracut module: fix parsing of root= kernel command-line argument #13589

Closed
wants to merge 1 commit into from

Conversation

ahesford
Copy link
Contributor

Some Dracut modules may read the root= kernel command-line argument and rewrite it; in particular, rootfs-block installs a command-line hook that to canonicalize arguments that specify block devices. If the zfs module is added to an initramfs (which it is, by default, as long as the core ZFS utilities are available) on a system that does not use a ZFS root filesystem, the zfs module will overwrite the root shell variable with the contents of the kernel command-line in the process of determining if it should control mounting the root. This breaks the initramfs.

Motivation and Context

If the zfs dracut module will be automatically included in initramfs images, it should avoid corrupting root arguments when those arguments refer to non-ZFS filesystems.

This bug was identified in void-linux/void-packages#37667 and should be fixed by this patch.

Description

Simply check if the root shell variable is non-empty, which means it has already been parsed (and possibly rewritten); prefer a previously parsed version if possible. Otherwise, parse the kernel command-line directly to populate the root shell variable. Subsequent decisions about rewriting root based on the existence of ZFS indicators remain unchanged.

How Has This Been Tested?

I have no systems without ZFS roots, so this was "tested" by reasoning in a thought experiment.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

Some Dracut modules may read the `root=` kernel command-line argument
and rewrite it; in particular, `rootfs-block` installs a command-line
hook that to canonicalize arguments that specify block devices. If the
`zfs` module is added to an initramfs (which it is, by default, as long
as the core ZFS utilities are available) on a system that does not use a
ZFS root filesystem, the `zfs` module will overwrite the `root` shell
variable with the contents of the kernel command-line in the process of
determining if it should control mounting the root. This breaks the
initramfs. To solve this problem, only parse the kernel command-line
directly if the `root` shell variable is empty; otherwise, rely on the
parsing (and possible rewriting) done by other modules.

Signed-off-by: Andrew J. Hesford <ajh@sideband.org>
@ahesford
Copy link
Contributor Author

Deferring to #13592

@ahesford ahesford closed this Jun 30, 2022
@ahesford ahesford deleted the dracut-root-fix branch July 6, 2022 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Dracut dracut integration Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants