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