* [LTP] [PATCH] ima_kexec.sh: Use %s in printf to prevent evaluating cmdline backslashes
@ 2026-04-15 4:46 Avinesh Kumar via ltp
2026-04-15 5:29 ` [LTP] " linuxtestproject.agent
2026-04-16 18:39 ` [LTP] [PATCH] " Petr Vorel
0 siblings, 2 replies; 3+ messages in thread
From: Avinesh Kumar via ltp @ 2026-04-15 4:46 UTC (permalink / raw)
To: ltp
On systemd-boot systems, the kernel command line contains EFI paths
with backslashes (e.g., `initrd=\opensuse...\6.19...`).
Writing this to a file using `printf "$cmdline"` inadvertently evaluates
these backslashes as escape sequences, corrupting the expected digest
and causing a false test failure:
+ printf 'initrd=\opensuse-tumbleweed\6.19.11-1-default\initrd-...'
+ cat -v file1
initrd=\opensuse-tumbleweed^F.19.11-1-default\initrd-...
ima_kexec 1 TINFO: testing kexec -s -l /boot/Image-6.19.11-1-default --reuse-cmdline
ima_kexec 1 TFAIL: unable to find a correct measurement
Fix this by using `printf "%s" "$cmdline"` to ensure the command line
is treated as literal data.
Signed-off-by: Avinesh Kumar <avinesh.kumar@suse.com>
---
testcases/kernel/security/integrity/ima/tests/ima_kexec.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testcases/kernel/security/integrity/ima/tests/ima_kexec.sh b/testcases/kernel/security/integrity/ima/tests/ima_kexec.sh
index 4732df653..bbc82f30c 100755
--- a/testcases/kernel/security/integrity/ima/tests/ima_kexec.sh
+++ b/testcases/kernel/security/integrity/ima/tests/ima_kexec.sh
@@ -24,7 +24,7 @@ measure()
local cmdline="$1"
local algorithm digest expected_digest found
- printf "$cmdline" > file1
+ printf "%s" "$cmdline" > file1
grep "kexec-cmdline" $ASCII_MEASUREMENTS > file2
while read found
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] ima_kexec.sh: Use %s in printf to prevent evaluating cmdline backslashes
2026-04-15 4:46 [LTP] [PATCH] ima_kexec.sh: Use %s in printf to prevent evaluating cmdline backslashes Avinesh Kumar via ltp
@ 2026-04-15 5:29 ` linuxtestproject.agent
2026-04-16 18:39 ` [LTP] [PATCH] " Petr Vorel
1 sibling, 0 replies; 3+ messages in thread
From: linuxtestproject.agent @ 2026-04-15 5:29 UTC (permalink / raw)
To: Avinesh Kumar; +Cc: ltp
Hi Avinesh,
On Wed, 15 Apr 2026 06:46:36 +0200, Avinesh Kumar wrote:
> ima_kexec.sh: Use %s in printf to prevent evaluating cmdline backslashes
> - printf "$cmdline" > file1
> + printf "%s" "$cmdline" > file1
Fix is correct. Please add a Fixes: tag pointing to the commit that
introduced `printf "$cmdline"`.
---
Note:
Our agent completed the review of the patch. The full review can be
found at: https://github.com/linux-test-project/ltp-agent/actions/runs/24437929854
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] ima_kexec.sh: Use %s in printf to prevent evaluating cmdline backslashes
2026-04-15 4:46 [LTP] [PATCH] ima_kexec.sh: Use %s in printf to prevent evaluating cmdline backslashes Avinesh Kumar via ltp
2026-04-15 5:29 ` [LTP] " linuxtestproject.agent
@ 2026-04-16 18:39 ` Petr Vorel
1 sibling, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2026-04-16 18:39 UTC (permalink / raw)
To: Avinesh Kumar; +Cc: ltp
Hi Avinesh,
> On systemd-boot systems, the kernel command line contains EFI paths
> with backslashes (e.g., `initrd=\opensuse...\6.19...`).
> Writing this to a file using `printf "$cmdline"` inadvertently evaluates
> these backslashes as escape sequences, corrupting the expected digest
> and causing a false test failure:
> + printf 'initrd=\opensuse-tumbleweed\6.19.11-1-default\initrd-...'
> + cat -v file1
> initrd=\opensuse-tumbleweed^F.19.11-1-default\initrd-...
> ima_kexec 1 TINFO: testing kexec -s -l /boot/Image-6.19.11-1-default --reuse-cmdline
> ima_kexec 1 TFAIL: unable to find a correct measurement
> Fix this by using `printf "%s" "$cmdline"` to ensure the command line
> is treated as literal data.
Thanks a lot, merged!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-16 18:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-15 4:46 [LTP] [PATCH] ima_kexec.sh: Use %s in printf to prevent evaluating cmdline backslashes Avinesh Kumar via ltp
2026-04-15 5:29 ` [LTP] " linuxtestproject.agent
2026-04-16 18:39 ` [LTP] [PATCH] " Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox