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

Advanced parser for kernel boot params #73

Closed
anatol opened this issue Mar 28, 2021 · 2 comments
Closed

Advanced parser for kernel boot params #73

anatol opened this issue Mar 28, 2021 · 2 comments

Comments

@anatol
Copy link
Owner

anatol commented Mar 28, 2021

Currently booster reads proc/cmdline and splits it by space. It works for majority of simple cases but it will fail if something more advanced is used in the command line.

For example parameters itself may use space. In this case quoting around the params need to be used. Per kernel documentation:

Double-quotes can be used to protect spaces in values

But it also looks like some bootloaders (e.g. grub) add quoting in a different way, like this "param=value with a space". So booster needs to handle quoting in both ways: param="value with a space" and "param=value with a space". This in addition to quotes around UUID handled here #6.

Besides spaces the values might contain escape symbols param="foo \" bar". And parser probably needs to handle other param delimiter, e.g. params might be separated with tabs.

It looks like we need a real advanced parser that handles all these cases. It worth reviewing kmod cmdline parser here to see if we can go similar way https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git/tree/libkmod/libkmod-config.c?id=8742be0aa5ed14d28980eb706b08e8bdf650f21c#n528

@anatol
Copy link
Owner Author

anatol commented Aug 10, 2022

TestLUKS2WithQuotesOverUUID test is failing now with

[    0.807449] booster: while parsing cmdline parameter unexpected " found at 98, input may be malformed, attempting to proceed
[    0.808704] booster: while parsing cmdline parameter unexpected " found at 135, input may be malformed, attempting to proceed
[    0.809946] booster: root=UUID="7bbf9363-eb42-4476-8c1c-9f1f4d091385": unable to parse UUID parameter UUID="7bbf9363-eb42-4476-8c1c-9f1f4d091385": expected input length is 36, got length 38
[    0.811831] booster: Press ENTER to reboot

@jacobmyers-codeninja
Copy link
Contributor

I know whats causing this, I should have a small fix to address it and a few tests cases to ensure its covered better.

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

No branches or pull requests

2 participants