Path: blob/master/tools/testing/selftests/kexec/test_kexec_load.sh
26285 views
#!/bin/sh1# SPDX-License-Identifier: GPL-2.02#3# Prevent loading a kernel image via the kexec_load syscall when4# signatures are required. (Dependent on CONFIG_IMA_ARCH_POLICY.)56TEST="$0"7. ./kexec_common_lib.sh89# kexec requires root privileges10require_root_privileges1112# get the kernel config13get_kconfig1415kconfig_enabled "CONFIG_KEXEC=y" "kexec_load is enabled"16if [ $? -eq 0 ]; then17log_skip "kexec_load is not enabled"18fi1920kconfig_enabled "CONFIG_IMA_APPRAISE=y" "IMA enabled"21ima_appraise=$?2223kconfig_enabled "CONFIG_IMA_ARCH_POLICY=y" \24"IMA architecture specific policy enabled"25arch_policy=$?2627get_secureboot_mode28secureboot=$?2930# kexec_load should fail in secure boot mode and CONFIG_IMA_ARCH_POLICY enabled31kexec --load $KERNEL_IMAGE > /dev/null 2>&132if [ $? -eq 0 ]; then33kexec --unload34if [ $secureboot -eq 1 ] && [ $arch_policy -eq 1 ]; then35log_fail "kexec_load succeeded"36elif [ $ima_appraise -eq 0 -o $arch_policy -eq 0 ]; then37log_info "Either IMA or the IMA arch policy is not enabled"38fi39log_pass "kexec_load succeeded"40else41if [ $secureboot -eq 1 ] && [ $arch_policy -eq 1 ] ; then42log_pass "kexec_load failed"43else44log_fail "kexec_load failed"45fi46fi474849