mirror of
https://github.com/torvalds/linux.git
synced 2024-12-28 13:51:44 +00:00
fa4f3f56cc
To prevent verifying the kernel module appended signature
twice (finit_module), once by the module_sig_check() and again by IMA,
powerpc secure boot rules define an IMA architecture specific policy
rule only if CONFIG_MODULE_SIG_FORCE is not enabled. This,
unfortunately, does not take into account the ability of enabling
"sig_enforce" on the boot command line (module.sig_enforce=1).
Including the IMA module appraise rule results in failing the
finit_module syscall, unless the module signing public key is loaded
onto the IMA keyring.
This patch fixes secure boot policy rules to be based on
CONFIG_MODULE_SIG instead.
Fixes: 4238fad366
("powerpc/ima: Add support to initialize ima policy rules")
Signed-off-by: Nayna Jain <nayna@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Link: https://lore.kernel.org/r/1588342612-14532-1-git-send-email-nayna@linux.ibm.com
79 lines
2.3 KiB
C
79 lines
2.3 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (C) 2019 IBM Corporation
|
|
* Author: Nayna Jain
|
|
*/
|
|
|
|
#include <linux/ima.h>
|
|
#include <asm/secure_boot.h>
|
|
|
|
bool arch_ima_get_secureboot(void)
|
|
{
|
|
return is_ppc_secureboot_enabled();
|
|
}
|
|
|
|
/*
|
|
* The "secure_rules" are enabled only on "secureboot" enabled systems.
|
|
* These rules verify the file signatures against known good values.
|
|
* The "appraise_type=imasig|modsig" option allows the known good signature
|
|
* to be stored as an xattr or as an appended signature.
|
|
*
|
|
* To avoid duplicate signature verification as much as possible, the IMA
|
|
* policy rule for module appraisal is added only if CONFIG_MODULE_SIG
|
|
* is not enabled.
|
|
*/
|
|
static const char *const secure_rules[] = {
|
|
"appraise func=KEXEC_KERNEL_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
|
|
#ifndef CONFIG_MODULE_SIG
|
|
"appraise func=MODULE_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
|
|
#endif
|
|
NULL
|
|
};
|
|
|
|
/*
|
|
* The "trusted_rules" are enabled only on "trustedboot" enabled systems.
|
|
* These rules add the kexec kernel image and kernel modules file hashes to
|
|
* the IMA measurement list.
|
|
*/
|
|
static const char *const trusted_rules[] = {
|
|
"measure func=KEXEC_KERNEL_CHECK",
|
|
"measure func=MODULE_CHECK",
|
|
NULL
|
|
};
|
|
|
|
/*
|
|
* The "secure_and_trusted_rules" contains rules for both the secure boot and
|
|
* trusted boot. The "template=ima-modsig" option includes the appended
|
|
* signature, when available, in the IMA measurement list.
|
|
*/
|
|
static const char *const secure_and_trusted_rules[] = {
|
|
"measure func=KEXEC_KERNEL_CHECK template=ima-modsig",
|
|
"measure func=MODULE_CHECK template=ima-modsig",
|
|
"appraise func=KEXEC_KERNEL_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
|
|
#ifndef CONFIG_MODULE_SIG
|
|
"appraise func=MODULE_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
|
|
#endif
|
|
NULL
|
|
};
|
|
|
|
/*
|
|
* Returns the relevant IMA arch-specific policies based on the system secure
|
|
* boot state.
|
|
*/
|
|
const char *const *arch_get_ima_policy(void)
|
|
{
|
|
if (is_ppc_secureboot_enabled()) {
|
|
if (IS_ENABLED(CONFIG_MODULE_SIG))
|
|
set_module_sig_enforced();
|
|
|
|
if (is_ppc_trustedboot_enabled())
|
|
return secure_and_trusted_rules;
|
|
else
|
|
return secure_rules;
|
|
} else if (is_ppc_trustedboot_enabled()) {
|
|
return trusted_rules;
|
|
}
|
|
|
|
return NULL;
|
|
}
|