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 9rc=0 10 11# Kselftest framework requirement - SKIP code is 4. 12ksft_skip=4 13 14# kexec requires root privileges 15if [ $(id -ru) -ne 0 ]; then 16 echo "$TEST: requires root privileges" >&2 17 exit $ksft_skip 18fi 19 20get_secureboot_mode 21secureboot=$? 22 23# kexec_load should fail in secure boot mode 24KERNEL_IMAGE="/boot/vmlinuz-`uname -r`" 25kexec --load $KERNEL_IMAGE > /dev/null 2>&1 26if [ $? -eq 0 ]; then 27 kexec --unload 28 if [ $secureboot -eq 1 ]; then 29 echo "$TEST: kexec_load succeeded [FAIL]" 30 rc=1 31 else 32 echo "$TEST: kexec_load succeeded [PASS]" 33 fi 34else 35 if [ $secureboot -eq 1 ]; then 36 echo "$TEST: kexec_load failed [PASS]" 37 else 38 echo "$TEST: kexec_load failed [FAIL]" 39 rc=1 40 fi 41fi 42 43exit $rc 44