mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Add a self test which exercises both the kexec-jump facility, and the kexec exception handling. Invoke a trivial payload which just does an int3 and returns, flip-flopping its entry point for the next invocation between two implementations of the same thing. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Brian Gerst <brgerst@gmail.com> Cc: Juergen Gross <jgross@suse.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Kees Cook <keescook@chromium.org> Cc: Ard Biesheuvel <ardb@kernel.org> Link: https://lore.kernel.org/r/20250326142404.256980-5-dwmw2@infradead.org
42 lines
1 KiB
Bash
Executable file
42 lines
1 KiB
Bash
Executable file
#!/bin/sh
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
#
|
|
# Prevent loading a kernel image via the kexec_load syscall when
|
|
# signatures are required. (Dependent on CONFIG_IMA_ARCH_POLICY.)
|
|
|
|
TEST="$0"
|
|
. ./kexec_common_lib.sh
|
|
|
|
# kexec requires root privileges
|
|
require_root_privileges
|
|
|
|
# get the kernel config
|
|
get_kconfig
|
|
|
|
kconfig_enabled "CONFIG_KEXEC_JUMP=y" "kexec_jump is enabled"
|
|
if [ $? -eq 0 ]; then
|
|
log_skip "kexec_jump is not enabled"
|
|
fi
|
|
|
|
kconfig_enabled "CONFIG_IMA_APPRAISE=y" "IMA enabled"
|
|
ima_appraise=$?
|
|
|
|
kconfig_enabled "CONFIG_IMA_ARCH_POLICY=y" \
|
|
"IMA architecture specific policy enabled"
|
|
arch_policy=$?
|
|
|
|
get_secureboot_mode
|
|
secureboot=$?
|
|
|
|
if [ $secureboot -eq 1 ] && [ $arch_policy -eq 1 ]; then
|
|
log_skip "Secure boot and CONFIG_IMA_ARCH_POLICY are enabled"
|
|
fi
|
|
|
|
./test_kexec_jump
|
|
if [ $? -eq 0 ]; then
|
|
log_pass "kexec_jump succeeded"
|
|
else
|
|
# The more likely failure mode if anything went wrong is that the
|
|
# kernel just crashes. But if we get back here, sure, whine anyway.
|
|
log_fail "kexec_jump failed"
|
|
fi
|