Skip to content

Commit b5b135c

Browse files
committed
ima_kexec.sh: Detect kernel image from BOOT_IMAGE from /proc/cmdline
Default value was suitable only for x86_64. This helps to use other archs on distros which set $BOOT_IMAGE. Link: https://lore.kernel.org/ltp/20250224171137.2893480-1-pvorel@suse.cz/ Signed-off-by: Petr Vorel <pvorel@suse.cz>
1 parent 1f5041b commit b5b135c

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

testcases/kernel/security/integrity/ima/tests/ima_kexec.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,32 @@ measure()
4242

4343
setup()
4444
{
45-
tst_res TINFO "using kernel $IMA_KEXEC_IMAGE"
45+
local arch
46+
47+
if [ ! -f "$IMA_KEXEC_IMAGE" ]; then
48+
for arg in $(cat /proc/cmdline); do
49+
if echo "$arg" |grep -q '^BOOT_IMAGE'; then
50+
eval "$arg"
51+
fi
52+
done
53+
54+
tst_res TINFO "using as kernel BOOT_IMAGE from /proc/cmdline: '$BOOT_IMAGE'"
55+
56+
# replace grub partition, e.g. (hd0,gpt2) => /boot
57+
if echo "$BOOT_IMAGE" |grep -q '(.d[0-9]'; then
58+
echo "$BOOT_IMAGE" | sed 's|(.*,.*)/|/boot/|'
59+
fi
60+
61+
if [ -f "$BOOT_IMAGE" ]; then
62+
IMA_KEXEC_IMAGE="$BOOT_IMAGE"
63+
fi
64+
fi
4665

4766
if [ ! -f "$IMA_KEXEC_IMAGE" ]; then
4867
tst_brk TCONF "kernel image not found, specify path in \$IMA_KEXEC_IMAGE"
4968
fi
69+
70+
tst_res TINFO "using kernel $IMA_KEXEC_IMAGE"
5071
}
5172

5273
kexec_failure_hint()

0 commit comments

Comments
 (0)