Skip to content

kernel_cmdline quoting equivalence #1737

@jeckersb

Description

@jeckersb

Side quest spawned from investigating ostreedev/ostree#3544 ...

Quoted kargs end up getting transformed between grub and the kernel, here's an example:

# Original kargs does not have a "foo" value
[root@ibm-p8-kvm-03-guest-02 ~]# rpm-ostree kargs
root=UUID=4f68bce3-e8cd-4db1-96e7-fbcaf984b709 rw ostree=/ostree/boot.1/default/944761db707ac4bce2b4e1362b79cfea486bcd764ac56131a30780b4927ee26b/0
# Append a quoted arg
[root@ibm-p8-kvm-03-guest-02 ~]# rpm-ostree kargs --append='foo="quoted value"'
Staging deployment... done
Changes queued for next boot. Run "systemctl reboot" to start a reboot
# Sanity check that the quoted arg was added, and in the format we expect
[root@ibm-p8-kvm-03-guest-02 ~]# rpm-ostree kargs
root=UUID=4f68bce3-e8cd-4db1-96e7-fbcaf984b709 rw ostree=/ostree/boot.1/default/944761db707ac4bce2b4e1362b79cfea486bcd764ac56131a30780b4927ee26b/0 foo="quoted value"
[root@ibm-p8-kvm-03-guest-02 ~]# systemctl reboot
[...]
# After reboot, boot loader entry looks correct
[root@ibm-p8-kvm-03-guest-02 ~]# grep options /boot/loader/entries/ostree-2.conf
options root=UUID=4f68bce3-e8cd-4db1-96e7-fbcaf984b709 rw ostree=/ostree/boot.0/default/944761db707ac4bce2b4e1362b79cfea486bcd764ac56131a30780b4927ee26b/0 foo="quoted value"
# However, the kernel sees the value as "externally" quoted in early boot
[root@ibm-p8-kvm-03-guest-02 ~]# journalctl -b --grep 'Command line:' --no-pager
Nov 06 18:55:24 localhost kernel: Command line: BOOT_IMAGE=(hd0,gpt3)/boot/ostree/default-944761db707ac4bce2b4e1362b79cfea486bcd764ac56131a30780b4927ee26b/vmlinuz-6.12.0-150.el10.x86_64 root=UUID=4f68bce3-e8cd-4db1-96e7-fbcaf984b709 rw ostree=/ostree/boot.0/default/944761db707ac4bce2b4e1362b79cfea486bcd764ac56131a30780b4927ee26b/0 "foo=quoted value"
# And the same format persists via /proc/cmdline
[root@ibm-p8-kvm-03-guest-02 ~]# cat /proc/cmdline
BOOT_IMAGE=(hd0,gpt3)/boot/ostree/default-944761db707ac4bce2b4e1362b79cfea486bcd764ac56131a30780b4927ee26b/vmlinuz-6.12.0-150.el10.x86_64 root=UUID=4f68bce3-e8cd-4db1-96e7-fbcaf984b709 rw ostree=/ostree/boot.0/default/944761db707ac4bce2b4e1362b79cfea486bcd764ac56131a30780b4927ee26b/0 "foo=quoted value"

This is a bit of a landmine. I noticed it while trying to write an integration tests for the above linked issue and it failed because it didn't match how I expected it to. At the very least I need to update the kernel_cmdline crate so these are equivalent:

let outside_quoted = param("\"foo=quoted value\"");
let value_quoted = param("foo=\"quoted value\"");
assert_eq!(outside_quoted, value_quoted);

As currently implemented, this does not parse correctly and these are considered two different values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triagedThis issue appears to be valid

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions