public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [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

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