[pve-devel] applied: [PATCH v3 kernel-meta] fix #2403: exclude initrd entries from /proc/cmdline

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Oct 17 10:35:14 CEST 2019


On 10/17/19 10:13 AM, Fabian Grünbichler wrote:
> On October 17, 2019 7:45 am, Thomas Lamprecht wrote:
>> On 10/16/19 1:17 PM, Oguz Bektas wrote:
>>> if we fallback to /proc/cmdline, it can include the booted initrd.
>>>
>>> to avoid loader entries with initrd 'options' lines, we have to parse
>>> them out.
>>>
>>> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
>>> ---
>>>
>>> v2->v3:
>>> * match forward slashes
>>> * match underscore
>>> * match zero or more whitespace at the end
>>>
>>>  efiboot/zz-pve-efiboot | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/efiboot/zz-pve-efiboot b/efiboot/zz-pve-efiboot
>>> index 4756555..8771da9 100755
>>> --- a/efiboot/zz-pve-efiboot
>>> +++ b/efiboot/zz-pve-efiboot
>>> @@ -50,7 +50,8 @@ update_esps() {
>>>  		CMDLINE="$(cat /etc/kernel/cmdline)"
>>>  	else
>>>  		warn "No /etc/kernel/cmdline found - falling back to /proc/cmdline"
>>> -		CMDLINE="$(cat /proc/cmdline)"
>>> +		# remove initrd entries
>>> +		CMDLINE="$(awk '{gsub(/\yinitrd=([0-9a-zA-Z\/\\._-])*\s*/,x)}1' /proc/cmdline)"
>>
>> applied, but fixed up a few things, mostly style-wise so IMO no need for a v4:
>> * add some spaces for separation, increasing readability
>> * do not use the non-existent variable x as replacement, but an actual
>>   empty string ""
>> * don't use the "truth-y action" at end to make awk print the line ($0)
>>   but explicitly print $0 after the gsub, makes it easier to get for
>>   people with not much awk background ;)
>>
>> thanks!
> 
> a bit late to the party unfortunately, but AFAICT it's also valid to 
> have quoted parameter values with spaces inside - maybe it's worth a 
> follow-up? not relevant for our generated ones, but maybe for manually 
> built/added kernels..
> 

yeah, thought about that too, but initrd= should /normally/ not have them,
and if really something like:
> foo="bla bla initrd=oh-no-why"
comes along we need to either step up our awk game or use something
different, maybe bison ;)

> also not sure whether plain ascii alpha-numeric is the proper choice for 
> characters. we can also leave it as is until somebody reports actually 
> running into either issue though ;)
> 
>>
>>>  	fi
>>>  
>>>  	loop_esp_list update_esp_func
>>>





More information about the pve-devel mailing list