[Bug 2112179] Re: Cannot pass unescaped double quotes to the linux command line
Mate Kukri
2112179 at bugs.launchpad.net
Fri Aug 1 13:33:57 UTC 2025
** Changed in: grub2 (Ubuntu)
Status: New => In Progress
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/2112179
Title:
Cannot pass unescaped double quotes to the linux command line
Status in grub2 package in Ubuntu:
In Progress
Bug description:
I am writing a `grub.cfg` which contains this:
```
linux /boot/kernel \
root=/dev/mapper/verity-root \
dm_mod.create="\"verity-root,,ro,0 163840 verity 1 /dev/vda3 /dev/vda3 4096 4096 10240 10240 sha256 ${ROOT_HASH_A} -\"" \
${kernel_common_cmdline}
```
The problem I have is that the kernel then ultimately sees this:
`dm_mod.create=\"verity-root,,ro,0 163840 verity 1 /dev/vda3 /dev/vda3
4096 4096 10240 10240 sha256
4b2693f593b5472ae2661fa9b4a499dce2301e6b66d385d1d7ee8bde1466e87f -\"`
And not
`dm_mod.create="verity-root,,ro,0 163840 verity 1 /dev/vda3 /dev/vda3
4096 4096 10240 10240 sha256
4b2693f593b5472ae2661fa9b4a499dce2301e6b66d385d1d7ee8bde1466e87f -"`
as I intended (and what the documentation states should be the result,
see the paragraph on quoting here:
https://www.gnu.org/software/grub/manual/grub/html_node/Shell_002dlike-
scripting.html).
There are various ways to try and work around the issue, but none result in a command line that the kernel then interprets correctly.
What appears to be the solution intended by the grub authors gives this result:
`"dm_mod.create=verity-root,,ro,0 163840 verity 1 /dev/vda3 /dev/vda3
4096 4096 10240 10240 sha256
4b2693f593b5472ae2661fa9b4a499dce2301e6b66d385d1d7ee8bde1466e87f -"`
However the kernel does not parse this correctly.
One can also try to use escaped spaces to go around the quoting issue, however the backslashes themselves are then automatically escaped by grub in the output, and thus the kernel fails to parse the line correctly too.
In effect, it is not possible to produce a linux command line that
contains unescaped double quotes or backslashes, except in the very
specific way that grub handles the "argument containing a space" case,
which does not function correctly with the kernel parser.
This bug is a known issue and patches have been suggested to solve it,
see here: https://lists.gnu.org/archive/html/grub-
devel/2023-07/msg00089.html
This bug is also related to
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/445952 but is
more narrow: my issue is exclusively about grub adding unwanted escape
characters to the linux command line, not about how it interprets
quotes coming from environment variables.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2112179/+subscriptions
More information about the foundations-bugs
mailing list