xref: /openbmc/linux/security/integrity/ima/Kconfig (revision 6b342707)
1# SPDX-License-Identifier: GPL-2.0-only
2# IBM Integrity Measurement Architecture
3#
4config IMA
5	bool "Integrity Measurement Architecture(IMA)"
6	select SECURITYFS
7	select CRYPTO
8	select CRYPTO_HMAC
9	select CRYPTO_SHA1
10	select CRYPTO_HASH_INFO
11	select TCG_TPM if HAS_IOMEM && !UML
12	select TCG_TIS if TCG_TPM && X86
13	select TCG_CRB if TCG_TPM && ACPI
14	select TCG_IBMVTPM if TCG_TPM && PPC_PSERIES
15	select INTEGRITY_AUDIT if AUDIT
16	help
17	  The Trusted Computing Group(TCG) runtime Integrity
18	  Measurement Architecture(IMA) maintains a list of hash
19	  values of executables and other sensitive system files,
20	  as they are read or executed. If an attacker manages
21	  to change the contents of an important system file
22	  being measured, we can tell.
23
24	  If your system has a TPM chip, then IMA also maintains
25	  an aggregate integrity value over this list inside the
26	  TPM hardware, so that the TPM can prove to a third party
27	  whether or not critical system files have been modified.
28	  Read <https://www.usenix.org/events/sec04/tech/sailer.html>
29	  to learn more about IMA.
30	  If unsure, say N.
31
32config IMA_KEXEC
33	bool "Enable carrying the IMA measurement list across a soft boot"
34	depends on IMA && TCG_TPM && HAVE_IMA_KEXEC
35	default n
36	help
37	   TPM PCRs are only reset on a hard reboot.  In order to validate
38	   a TPM's quote after a soft boot, the IMA measurement list of the
39	   running kernel must be saved and restored on boot.
40
41	   Depending on the IMA policy, the measurement list can grow to
42	   be very large.
43
44config IMA_MEASURE_PCR_IDX
45	int
46	depends on IMA
47	range 8 14
48	default 10
49	help
50	  IMA_MEASURE_PCR_IDX determines the TPM PCR register index
51	  that IMA uses to maintain the integrity aggregate of the
52	  measurement list.  If unsure, use the default 10.
53
54config IMA_LSM_RULES
55	bool
56	depends on IMA && AUDIT && (SECURITY_SELINUX || SECURITY_SMACK || SECURITY_APPARMOR)
57	default y
58	help
59	  Disabling this option will disregard LSM based policy rules.
60
61choice
62	prompt "Default template"
63	default IMA_NG_TEMPLATE
64	depends on IMA
65	help
66	  Select the default IMA measurement template.
67
68	  The original 'ima' measurement list template contains a
69	  hash, defined as 20 bytes, and a null terminated pathname,
70	  limited to 255 characters.  The 'ima-ng' measurement list
71	  template permits both larger hash digests and longer
72	  pathnames.
73
74	config IMA_TEMPLATE
75		bool "ima"
76	config IMA_NG_TEMPLATE
77		bool "ima-ng (default)"
78	config IMA_SIG_TEMPLATE
79		bool "ima-sig"
80endchoice
81
82config IMA_DEFAULT_TEMPLATE
83	string
84	depends on IMA
85	default "ima" if IMA_TEMPLATE
86	default "ima-ng" if IMA_NG_TEMPLATE
87	default "ima-sig" if IMA_SIG_TEMPLATE
88
89choice
90	prompt "Default integrity hash algorithm"
91	default IMA_DEFAULT_HASH_SHA1
92	depends on IMA
93	help
94	   Select the default hash algorithm used for the measurement
95	   list, integrity appraisal and audit log.  The compiled default
96	   hash algorithm can be overwritten using the kernel command
97	   line 'ima_hash=' option.
98
99	config IMA_DEFAULT_HASH_SHA1
100		bool "SHA1 (default)"
101		depends on CRYPTO_SHA1=y
102
103	config IMA_DEFAULT_HASH_SHA256
104		bool "SHA256"
105		depends on CRYPTO_SHA256=y && !IMA_TEMPLATE
106
107	config IMA_DEFAULT_HASH_SHA512
108		bool "SHA512"
109		depends on CRYPTO_SHA512=y && !IMA_TEMPLATE
110
111	config IMA_DEFAULT_HASH_WP512
112		bool "WP512"
113		depends on CRYPTO_WP512=y && !IMA_TEMPLATE
114
115	config IMA_DEFAULT_HASH_SM3
116		bool "SM3"
117		depends on CRYPTO_SM3=y && !IMA_TEMPLATE
118endchoice
119
120config IMA_DEFAULT_HASH
121	string
122	depends on IMA
123	default "sha1" if IMA_DEFAULT_HASH_SHA1
124	default "sha256" if IMA_DEFAULT_HASH_SHA256
125	default "sha512" if IMA_DEFAULT_HASH_SHA512
126	default "wp512" if IMA_DEFAULT_HASH_WP512
127	default "sm3" if IMA_DEFAULT_HASH_SM3
128
129config IMA_WRITE_POLICY
130	bool "Enable multiple writes to the IMA policy"
131	depends on IMA
132	default n
133	help
134	  IMA policy can now be updated multiple times.  The new rules get
135	  appended to the original policy.  Have in mind that the rules are
136	  scanned in FIFO order so be careful when you design and add new ones.
137
138	  If unsure, say N.
139
140config IMA_READ_POLICY
141	bool "Enable reading back the current IMA policy"
142	depends on IMA
143	default y if IMA_WRITE_POLICY
144	default n if !IMA_WRITE_POLICY
145	help
146	   It is often useful to be able to read back the IMA policy.  It is
147	   even more important after introducing CONFIG_IMA_WRITE_POLICY.
148	   This option allows the root user to see the current policy rules.
149
150config IMA_APPRAISE
151	bool "Appraise integrity measurements"
152	depends on IMA
153	default n
154	help
155	  This option enables local measurement integrity appraisal.
156	  It requires the system to be labeled with a security extended
157	  attribute containing the file hash measurement.  To protect
158	  the security extended attributes from offline attack, enable
159	  and configure EVM.
160
161	  For more information on integrity appraisal refer to:
162	  <http://linux-ima.sourceforge.net>
163	  If unsure, say N.
164
165config IMA_ARCH_POLICY
166        bool "Enable loading an IMA architecture specific policy"
167        depends on (KEXEC_SIG && IMA) || IMA_APPRAISE \
168		   && INTEGRITY_ASYMMETRIC_KEYS
169        default n
170        help
171          This option enables loading an IMA architecture specific policy
172          based on run time secure boot flags.
173
174config IMA_APPRAISE_BUILD_POLICY
175	bool "IMA build time configured policy rules"
176	depends on IMA_APPRAISE && INTEGRITY_ASYMMETRIC_KEYS
177	default n
178	help
179	  This option defines an IMA appraisal policy at build time, which
180	  is enforced at run time without having to specify a builtin
181	  policy name on the boot command line.  The build time appraisal
182	  policy rules persist after loading a custom policy.
183
184	  Depending on the rules configured, this policy may require kernel
185	  modules, firmware, the kexec kernel image, and/or the IMA policy
186	  to be signed.  Unsigned files might prevent the system from
187	  booting or applications from working properly.
188
189config IMA_APPRAISE_REQUIRE_FIRMWARE_SIGS
190	bool "Appraise firmware signatures"
191	depends on IMA_APPRAISE_BUILD_POLICY
192	default n
193	help
194	  This option defines a policy requiring all firmware to be signed,
195	  including the regulatory.db.  If both this option and
196	  CFG80211_REQUIRE_SIGNED_REGDB are enabled, then both signature
197	  verification methods are necessary.
198
199config IMA_APPRAISE_REQUIRE_KEXEC_SIGS
200	bool "Appraise kexec kernel image signatures"
201	depends on IMA_APPRAISE_BUILD_POLICY
202	default n
203	help
204	  Enabling this rule will require all kexec'ed kernel images to
205	  be signed and verified by a public key on the trusted IMA
206	  keyring.
207
208	  Kernel image signatures can not be verified by the original
209	  kexec_load syscall.  Enabling this rule will prevent its
210	  usage.
211
212config IMA_APPRAISE_REQUIRE_MODULE_SIGS
213	bool "Appraise kernel modules signatures"
214	depends on IMA_APPRAISE_BUILD_POLICY
215	default n
216	help
217	  Enabling this rule will require all kernel modules to be signed
218	  and verified by a public key on the trusted IMA keyring.
219
220	  Kernel module signatures can only be verified by IMA-appraisal,
221	  via the finit_module syscall. Enabling this rule will prevent
222	  the usage of the init_module syscall.
223
224config IMA_APPRAISE_REQUIRE_POLICY_SIGS
225	bool "Appraise IMA policy signature"
226	depends on IMA_APPRAISE_BUILD_POLICY
227	default n
228	help
229	  Enabling this rule will require the IMA policy to be signed and
230	  and verified by a key on the trusted IMA keyring.
231
232config IMA_APPRAISE_BOOTPARAM
233	bool "ima_appraise boot parameter"
234	depends on IMA_APPRAISE
235	default y
236	help
237	  This option enables the different "ima_appraise=" modes
238	  (eg. fix, log) from the boot command line.
239
240config IMA_APPRAISE_MODSIG
241	bool "Support module-style signatures for appraisal"
242	depends on IMA_APPRAISE
243	depends on INTEGRITY_ASYMMETRIC_KEYS
244	select PKCS7_MESSAGE_PARSER
245	select MODULE_SIG_FORMAT
246	default n
247	help
248	   Adds support for signatures appended to files. The format of the
249	   appended signature is the same used for signed kernel modules.
250	   The modsig keyword can be used in the IMA policy to allow a hook
251	   to accept such signatures.
252
253config IMA_TRUSTED_KEYRING
254	bool "Require all keys on the .ima keyring be signed (deprecated)"
255	depends on IMA_APPRAISE && SYSTEM_TRUSTED_KEYRING
256	depends on INTEGRITY_ASYMMETRIC_KEYS
257	select INTEGRITY_TRUSTED_KEYRING
258	default y
259	help
260	   This option requires that all keys added to the .ima
261	   keyring be signed by a key on the system trusted keyring.
262
263	   This option is deprecated in favor of INTEGRITY_TRUSTED_KEYRING
264
265config IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY
266	bool "Permit keys validly signed by a built-in or secondary CA cert (EXPERIMENTAL)"
267	depends on SYSTEM_TRUSTED_KEYRING
268	depends on SECONDARY_TRUSTED_KEYRING
269	depends on INTEGRITY_ASYMMETRIC_KEYS
270	select INTEGRITY_TRUSTED_KEYRING
271	default n
272	help
273	  Keys may be added to the IMA or IMA blacklist keyrings, if the
274	  key is validly signed by a CA cert in the system built-in or
275	  secondary trusted keyrings.
276
277	  Intermediate keys between those the kernel has compiled in and the
278	  IMA keys to be added may be added to the system secondary keyring,
279	  provided they are validly signed by a key already resident in the
280	  built-in or secondary trusted keyrings.
281
282config IMA_BLACKLIST_KEYRING
283	bool "Create IMA machine owner blacklist keyrings (EXPERIMENTAL)"
284	depends on SYSTEM_TRUSTED_KEYRING
285	depends on IMA_TRUSTED_KEYRING
286	default n
287	help
288	   This option creates an IMA blacklist keyring, which contains all
289	   revoked IMA keys.  It is consulted before any other keyring.  If
290	   the search is successful the requested operation is rejected and
291	   an error is returned to the caller.
292
293config IMA_LOAD_X509
294	bool "Load X509 certificate onto the '.ima' trusted keyring"
295	depends on IMA_TRUSTED_KEYRING
296	default n
297	help
298	   File signature verification is based on the public keys
299	   loaded on the .ima trusted keyring. These public keys are
300	   X509 certificates signed by a trusted key on the
301	   .system keyring.  This option enables X509 certificate
302	   loading from the kernel onto the '.ima' trusted keyring.
303
304config IMA_X509_PATH
305	string "IMA X509 certificate path"
306	depends on IMA_LOAD_X509
307	default "/etc/keys/x509_ima.der"
308	help
309	   This option defines IMA X509 certificate path.
310
311config IMA_APPRAISE_SIGNED_INIT
312	bool "Require signed user-space initialization"
313	depends on IMA_LOAD_X509
314	default n
315	help
316	   This option requires user-space init to be signed.
317
318config IMA_MEASURE_ASYMMETRIC_KEYS
319	bool
320	depends on IMA
321	depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y
322	default y
323
324config IMA_QUEUE_EARLY_BOOT_KEYS
325	bool
326	depends on IMA_MEASURE_ASYMMETRIC_KEYS
327	depends on SYSTEM_TRUSTED_KEYRING
328	default y
329
330config IMA_SECURE_AND_OR_TRUSTED_BOOT
331       bool
332       depends on IMA_ARCH_POLICY
333       help
334          This option is selected by architectures to enable secure and/or
335          trusted boot based on IMA runtime policies.
336
337config IMA_DISABLE_HTABLE
338	bool "Disable htable to allow measurement of duplicate records"
339	depends on IMA
340	default n
341	help
342	   This option disables htable to allow measurement of duplicate records.
343