1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# Loading a kernel image via the kexec_load syscall should fail 4# when the kernel is CONFIG_KEXEC_VERIFY_SIG enabled and the system 5# is booted in secureboot mode. 6 7TEST="$0" 8. ./kexec_common_lib.sh 9 10# kexec requires root privileges 11if [ $(id -ru) -ne 0 ]; then 12 log_skip "requires root privileges" 13fi 14 15get_secureboot_mode 16secureboot=$? 17 18# kexec_load should fail in secure boot mode 19KERNEL_IMAGE="/boot/vmlinuz-`uname -r`" 20kexec --load $KERNEL_IMAGE > /dev/null 2>&1 21if [ $? -eq 0 ]; then 22 kexec --unload 23 if [ $secureboot -eq 1 ]; then 24 log_fail "kexec_load succeeded" 25 else 26 log_pass "kexec_load succeeded" 27 fi 28else 29 if [ $secureboot -eq 1 ]; then 30 log_pass "kexec_load failed" 31 else 32 log_fail "kexec_load failed" 33 fi 34fi 35