-
Notifications
You must be signed in to change notification settings - Fork 881
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
Prevent from wrongly interpreting cc: in a BOOTIF=mac as config yaml #4477
Prevent from wrongly interpreting cc: in a BOOTIF=mac as config yaml #4477
Conversation
…onfig yaml When a mac address contains cc, such as ``` 01:02:03:04:cc:f4 ``` and when the kernel command line is ``` .... BOOTIF=01:02:03:04:cc:f4 ... ``` then cloudinit will wrongly think that ``` f4 ... ``` are a cloudinit config yaml, then the yaml parser fails. Normally this will not have a problem, but if the kernel command line embeds an important cloudinit instruction such as runcmd, then it will not be run, such as ``` ... ds=nocloud cc: datasource_list: [NoCloud] end_cc cc: runcmd: [[echo,a]] end_cc BOOTIF=01:02:03:04:cc:f4 ``` I have tested on a real UEFI PXE booted liveos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's add a comment and/or a test case to ensure we know why this exists
@@ -1166,7 +1166,7 @@ def read_cc_from_cmdline(cmdline=None): | |||
if cmdline is None: | |||
cmdline = get_cmdline() | |||
|
|||
tag_begin = "cc:" | |||
tag_begin = " cc:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is valid for the line to begin with cc:
, this won't work in that case.
I'm tempted to replace this entire section with regex parsing. Is that something you'd be interested in doing?
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging TheRealFalcon, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag TheRealFalcon to reopen it.) |
@jjqq2013 do you have any interest in making the requested change? Otherwise, I can take the effort over |
Doesn't |
@TheRealFalcon hi, sorry I don't have time to create a full PR, It would be great if you can take over this ticket. |
When I test the case |
Thanks all for taking a look at this issue.
The parser read the whole kernel command line, such as
case2:
case3:
You can see that case1 and case2 contains The case3 does not exist unless when someone insanely produced a kernel command line which starts with exactly So the And since this issue is a rare issue, no much system pass critical thing such as runcmd via kernel command line, I.e., just inserting a single space fixes this issue pratically. Just need someone to finish the whole process of a PR, such as passing tests. |
Let me take over this one. |
@jjqq2013 Not only is it possible, it is trivial. Consider: root@me:~# sudo kexec -l /boot/vmlinuz-5.15.0-1017-kvm --append 'cc: cloudinit_yml_here cc_end root=PARTUUID=2fec7223-75cc-463c-a987-85456171d574 ro console=tty1 console=ttyS0 panic=-1' --initrd=/boot/initrd.img-5.15.0-1017-kvm
root@me:~# kexec -e
(Log back into the instance with the new running kernel)
Therefore, as @TheRealFalcon already said, it is valid for the line to begin with |
Anyway, it would be beautiful if we can cover all the cases. |
This is being addressed in #4541. Please, @jjqq2013, see #4541 (review). Thanks. |
Addressed in #4541 . Closing this one. |
When a mac address contains cc, such as
and when the kernel command line is
then cloudinit will wrongly think that
are a cloudinit config yaml, then the yaml parser fails.
Normally this will not have a problem, but if the kernel command line embeds an important cloudinit instruction such as runcmd, then it will not be run, such as
I have tested on a real UEFI PXE booted liveos.
Proposed Commit Message
Additional Context
Test Steps
Checklist: