From 190047f161ae6d0e7c7a20d2e9056d14a10c55df Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Wed, 31 Jul 2013 11:31:13 +0200 Subject: [PATCH] fips: handle checksum checks for RHEV kernels https://bugzilla.redhat.com/show_bug.cgi?id=947729 --- modules.d/01fips/fips.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh index 73a0c8b..f0a4c5c 100755 --- a/modules.d/01fips/fips.sh +++ b/modules.d/01fips/fips.sh @@ -55,6 +55,22 @@ mount_boot() fi } +do_rhevh_check() +{ + KERNEL=$(uname -r) + kpath=${1} + + # If we're on RHEV-H, the kernel is in /dev/.initramfs/live/vmlinuz0 + HMAC_SUM_ORIG=$(cat /boot/.vmlinuz-${KERNEL}.hmac | while read a b; do printf "%s\n" $a; done) + HMAC_SUM_CALC=$(sha512hmac $kpath | while read a b; do printf "%s\n" $a; done || return 1) + if [ -z "$HMAC_SUM_ORIG" ] || [ -z "$HMAC_SUM_CALC" ] || [ "${HMAC_SUM_ORIG}" != "${HMAC_SUM_CALC}" ]; then + warn "HMAC sum mismatch" + return 1 + fi + info "rhevh_check OK" + return 0 +} + do_fips() { local _v @@ -96,7 +112,13 @@ do_fips() rmmod tcrypt info "Checking integrity of kernel" - sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || return 1 + if [ -e "$NEWROOT/dev/.initramfs/live/vmlinuz0" ]; then + do_rhevh_check "$NEWROOT/dev/.initramfs/live/vmlinuz0" || return 1 + elif [ -e "$NEWROOT/dev/.initramfs/live/isolinux/vmlinuz0" ]; then + do_rhevh_check "$NEWROOT/dev/.initramfs/live/isolinux/vmlinuz0" || return 1 + else + sha512hmac -c "/boot/.vmlinuz-${KERNEL}.hmac" || return 1 + fi info "All initrd crypto checks done" -- 2.7.4