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

fix(dracut): correct regression with multiple rd.break= options #2607

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aafeijoo-suse
Copy link
Member

Since the introduction of the dracut-util binary to parse kernel command line arguments, if the user inputs multiple rd.break= options, dracut only stops the boot process at the last one.

[    0.985362] localhost dracut-cmdline[245]: /bin/dracut-cmdline@18(): info 'Using kernel command line parameters:' ' ... rd.debug rd.break=cmdline rd.break=pre-pivot'
...
[    1.044979] localhost dracut-cmdline[245]: /bin/dracut-cmdline@48(): getarg rd.break=cmdline -d rdbreak=cmdline
[    1.044979] localhost dracut-cmdline[245]: /lib/dracut-lib.sh@155(getarg): debug_off
[    1.044979] localhost dracut-cmdline[245]: /lib/dracut-lib.sh@23(debug_off): set +x
[    1.044979] localhost dracut-cmdline[245]: /lib/dracut-lib.sh@218(getarg): return 1

For options that can be specified multiple times, getargs should be used instead.

master> export CMDLINE="rd.break=cmdline rd.break=pre-udev rd.break=pre-pivot"
master> ./dracut-getarg rd.break=cmdline
master> echo $?
1
master> ./dracut-getarg rd.break=pre-udev
master> echo $?
1
master> ./dracut-getarg rd.break=pre-pivot
master> echo $?
0
master> ./dracut-getargs rd.break=cmdline
cmdline
master> echo $?
0
master> ./dracut-getargs rd.break=pre-udev
pre-udev
master> echo $?
0
master> ./dracut-getargs rd.break=pre-pivot
pre-pivot
master> echo $?
0

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

Fixes 501d82f

@github-actions github-actions bot added modules Issue tracker for all modules dracut-systemd Issues related to the dracut-systemd module base Issues related to the base module shutdown Issues related to the shutdown module labels Jan 16, 2024
@LaszloGombos
Copy link
Collaborator

if the user inputs multiple rd.break= options, dracut only stops the boot process at the last one.

The dracut documentation seems to suggest that dracut works as intended and this is not a bug.

rd.break={cmdline|pre-udev|pre-trigger|initqueue|pre-mount|mount|pre-pivot|cleanup}
           drop to a shell before the defined breakpoint starts

I think if this PR lands, the PR should also change the documentation.

@aafeijoo-suse
Copy link
Member Author

if the user inputs multiple rd.break= options, dracut only stops the boot process at the last one.

The dracut documentation seems to suggest that dracut works as intended and this is not a bug.

Then why the following excerpt of the documentation states that we can stop at pre-shutdown and shutdown?

# echo "rd.debug rd.break=pre-shutdown rd.break=shutdown" > /run/initramfs/etc/cmdline.d/debug.conf

This used to work at least until dracut-049 (SLE15-SP3), so it's a clear regression.

The behavior of `strcmp` is undefined if any of its arguments is NULL, which
can lead to a segfault depending on the implementation. So, this check is
required to be able to use `getargs` with options where the value is optional,
e.g., with `rd.break`.
Since the introduction of the `dracut-util` binary to parse kernel command line
arguments, if the user inputs multiple `rd.break=` options, dracut only stops
the boot process at the last one.

```
[    0.985362] localhost dracut-cmdline[245]: /bin/dracut-cmdline@18(): info 'Using kernel command line parameters:' ' ... rd.debug rd.break=cmdline rd.break=pre-pivot'
...
[    1.044979] localhost dracut-cmdline[245]: /bin/dracut-cmdline@48(): getarg rd.break=cmdline -d rdbreak=cmdline
[    1.044979] localhost dracut-cmdline[245]: /lib/dracut-lib.sh@155(getarg): debug_off
[    1.044979] localhost dracut-cmdline[245]: /lib/dracut-lib.sh@23(debug_off): set +x
[    1.044979] localhost dracut-cmdline[245]: /lib/dracut-lib.sh@218(getarg): return 1
```

For options that can be specified multiple times, `getargs` should be used
instead.

```
master> export CMDLINE="rd.break=cmdline rd.break=pre-udev rd.break=pre-pivot"
master> ./dracut-getarg rd.break=cmdline
master> echo $?
1
master> ./dracut-getarg rd.break=pre-udev
master> echo $?
1
master> ./dracut-getarg rd.break=pre-pivot
master> echo $?
0
master> ./dracut-getargs rd.break=cmdline
cmdline
master> echo $?
0
master> ./dracut-getargs rd.break=pre-udev
pre-udev
master> echo $?
0
master> ./dracut-getargs rd.break=pre-pivot
pre-pivot
master> echo $?
0
```

Fixes 501d82f
Copy link

stale bot commented Apr 22, 2024

This issue is being marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. If this is still an issue in the latest release of Dracut and you would like to keep it open please comment on this issue within the next 7 days. Thank you for your contributions.

@stale stale bot added the stale communication is stuck label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
base Issues related to the base module dracut-systemd Issues related to the dracut-systemd module dracut-util modules Issue tracker for all modules shutdown Issues related to the shutdown module stale communication is stuck
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants