Handle special kernel parameter characters properly
Resolves: #RHEL-94342 Signed-off-by: Leo Sandoval <lsandova@redhat.com>
This commit is contained in:
parent
0127cb7cb1
commit
2be0734e9b
@ -0,0 +1,45 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Leo Sandoval <lsandova@redhat.com>
|
||||
Date: Wed, 7 May 2025 13:23:37 -0600
|
||||
Subject: [PATCH] 10_linux.in: escape kernel option characters properly
|
||||
|
||||
This handles cases where kernel options, specifically the values,
|
||||
contain special characters, in this case ';', '&' and '$'.
|
||||
|
||||
For example, the user defines the following GRUB_CMDLINE_LINUX on the
|
||||
default grub file /etc/default/grub, note the dolar sign on the 'memmap'
|
||||
option
|
||||
|
||||
GRUB_CMDLINE_LINUX="console=ttyS0 memmap=32g\\\$0x2000000000"
|
||||
|
||||
then regenerating the grub cfg and BLS options line with the
|
||||
grub2-mkconfig command, resulting into
|
||||
|
||||
options root=UUID=6baedf23-2510-499a-815d-48b58cf6e619 ro
|
||||
rootflags=subvol=root console=ttyS0 memmap=32g\$0x2000000000
|
||||
|
||||
without this patch, we would end up with
|
||||
|
||||
options root=UUID=6baedf23-2510-499a-815d-48b58cf6e619 ro
|
||||
rootflags=subvol=root console=ttyS0 memmap=32g$0x2000000000
|
||||
|
||||
Note the missing '\' which is required to escape the '$', otherwise
|
||||
it would be consider a variable by blscfg parser which is not the case.
|
||||
|
||||
Signed-off-by: Leo Sandoval <lsandova@redhat.com>
|
||||
---
|
||||
util/grub.d/10_linux.in | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
||||
index fafdfbc4d3..4276d5e240 100755
|
||||
--- a/util/grub.d/10_linux.in
|
||||
+++ b/util/grub.d/10_linux.in
|
||||
@@ -180,6 +180,7 @@ update_bls_cmdline()
|
||||
options="$(echo "${options}" | sed -e 's/\//\\\//g')"
|
||||
options="$(echo "${options}" | sed -e 's/\;/\\\;/g')"
|
||||
options="$(echo "${options}" | sed -e 's/\\&/\\\\&/g')"
|
||||
+ options="$(echo "${options}" | sed -e 's/\$/\\\$/g')"
|
||||
sed -i -e "s/^options.*/options ${options}/" "${blsdir}/${bls}.conf"
|
||||
done
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Leo Sandoval <lsandova@redhat.com>
|
||||
Date: Wed, 7 May 2025 13:49:47 -0600
|
||||
Subject: [PATCH] blscfg: check if variable is escaped before considering one
|
||||
|
||||
Otherwise escaped variables are considered real variables.
|
||||
|
||||
Signed-off-by: Leo Sandoval <lsandova@redhat.com>
|
||||
---
|
||||
grub-core/commands/blscfg.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/grub-core/commands/blscfg.c b/grub-core/commands/blscfg.c
|
||||
index 6e398fc175..5d931b0c9b 100644
|
||||
--- a/grub-core/commands/blscfg.c
|
||||
+++ b/grub-core/commands/blscfg.c
|
||||
@@ -695,7 +695,8 @@ static char *expand_val(const char *value)
|
||||
return NULL;
|
||||
|
||||
while (*value) {
|
||||
- if (*value == '$') {
|
||||
+ /* It's a variable only when *value is '$' and it is not escaped with '\'*/
|
||||
+ if (*value == '$' && *end != '\\') {
|
||||
if (start != end) {
|
||||
buffer = field_append(is_var, buffer, start, end);
|
||||
if (!buffer)
|
@ -364,3 +364,5 @@ Patch0364: 0364-grub-mkimage-Add-SBAT-metadata-into-ELF-note-for-Pow.patch
|
||||
Patch0365: 0365-loader-efi-Fix-RISC-V-build.patch
|
||||
Patch0366: 0366-kern-riscv-efi-init-Use-time-register-in-grub_efi_ge.patch
|
||||
Patch0367: 0367-Use-medany-instead-of-large-model-for-RISCV.patch
|
||||
Patch0368: 0368-10_linux.in-escape-kernel-option-characters-properly.patch
|
||||
Patch0369: 0369-blscfg-check-if-variable-is-escaped-before-consideri.patch
|
@ -17,7 +17,7 @@
|
||||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.12
|
||||
Release: 19%{?dist}
|
||||
Release: 20%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
License: GPL-3.0-or-later
|
||||
URL: http://www.gnu.org/software/grub/
|
||||
@ -583,6 +583,10 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Mon Jun 2 2025 Leo Sandoval <lsandova@redhat.com> 2.12-20
|
||||
- Handle special kernel parameter characters properly
|
||||
- Resolves: #RHEL-94342
|
||||
|
||||
* Wed May 14 2025 Nicolas Frayer <nfrayer@redhat.com> - 2.12-19
|
||||
- sbat: bump grub sbat for new shim release
|
||||
- Resolves: #RHEL-91277
|
||||
|
Loading…
Reference in New Issue
Block a user