History

powerpc/ima: Add support to initialize ima policy rules

PowerNV systems use a Linux-based bootloader, which rely on the IMA subsystem to enforce different secure boot modes. Since the verification policy may differ based on the secure boot mode of the system, the policies must be defined at runtime. This patch implements arch-specific support to define IMA policy rules based on the runtime secure boot mode of the system. This patch provides arch-specific IMA policies if PPC_SECURE_BOOT config is enabled.

Nayna Jain committed 7 years ago

Commit 4238fad1 parent 1a8916e4 files · +47 −2Browse files

Unified · Split

4 files
  1. arch/powerpc/Kconfig +1 −0
  2. arch/powerpc/kernel/Makefile +1 −1
  3. arch/powerpc/kernel/ima_arch.c +43 −0
  4. include/linux/ima.h +2 −1
arch/powerpc/Kconfig+1−0
@@ -938,6 +938,7 @@ config PPC_SECURE_BOOT · 937 unmodified lines
938938 prompt "Enable secure boot support"
939939 bool
940940 depends on PPC_POWERNV
941+ depends on IMA_ARCH_POLICY
941942 help
942943 Systems with firmware secure boot enabled need to define security
943944 policies to extend secure boot to the OS. This config allows a user
arch/powerpc/kernel/Makefile+1−1
@@ -161,7 +161,7 @@ ifneq ($(CONFIG_PPC_POWERNV)$(CONFIG_PPC_SVM),) · 160 unmodified lines
161161 obj-y += ucall.o
162162 endif
163163
164−obj-$(CONFIG_PPC_SECURE_BOOT) += secure_boot.o
164+obj-$(CONFIG_PPC_SECURE_BOOT) += secure_boot.o ima_arch.o
165165
166166 # Disable GCOV, KCOV & sanitizers in odd or sensitive code
167167 GCOV_PROFILE_prom_init.o := n
arch/powerpc/kernel/ima_arch.c+43−0
@@ -0,0 +1,43 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * Copyright (C) 2019 IBM Corporation
4+ * Author: Nayna Jain
5+ */
6+
7+#include <linux/ima.h>
8+#include <asm/secure_boot.h>
9+
10+bool arch_ima_get_secureboot(void)
11+{
12+ return is_ppc_secureboot_enabled();
13+}
14+
15+/*
16+ * The "secure_rules" are enabled only on "secureboot" enabled systems.
17+ * These rules verify the file signatures against known good values.
18+ * The "appraise_type=imasig|modsig" option allows the known good signature
19+ * to be stored as an xattr or as an appended signature.
20+ *
21+ * To avoid duplicate signature verification as much as possible, the IMA
22+ * policy rule for module appraisal is added only if CONFIG_MODULE_SIG_FORCE
23+ * is not enabled.
24+ */
25+static const char *const secure_rules[] = {
26+ "appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig",
27+#ifndef CONFIG_MODULE_SIG_FORCE
28+ "appraise func=MODULE_CHECK appraise_type=imasig|modsig",
29+#endif
30+ NULL
31+};
32+
33+/*
34+ * Returns the relevant IMA arch-specific policies based on the system secure
35+ * boot state.
36+ */
37+const char *const *arch_get_ima_policy(void)
38+{
39+ if (is_ppc_secureboot_enabled())
40+ return secure_rules;
41+
42+ return NULL;
43+}
include/linux/ima.h+2−1
@@ -29,7 +29,8 @@ extern void ima_kexec_cmdline(const void *buf, int size); · 28 unmodified lines
2929 extern void ima_add_kexec_buffer(struct kimage *image);
3030 #endif
3131
32−#if (defined(CONFIG_X86) && defined(CONFIG_EFI)) || defined(CONFIG_S390)
32+#if (defined(CONFIG_X86) && defined(CONFIG_EFI)) || defined(CONFIG_S390) \
33+ || defined(CONFIG_PPC_SECURE_BOOT)
3334 extern bool arch_ima_get_secureboot(void);
3435 extern const char * const *arch_get_ima_policy(void);
3536 #else

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t