Skip to content

Commit ea78979

Browse files
nramasmimizohar
authored andcommitted
IMA: fix measuring asymmetric keys Kconfig
As a result of the asymmetric public keys subtype Kconfig option being defined as tristate, with the existing IMA Makefile, ima_asymmetric_keys.c could be built as a kernel module. To prevent this from happening, this patch defines and uses an intermediate Kconfig boolean option named IMA_MEASURE_ASYMMETRIC_KEYS. Signed-off-by: Lakshmi Ramasubramanian <[email protected]> Suggested-by: James.Bottomley <[email protected]> Cc: David Howells <[email protected]> Cc: Jarkko Sakkinen <[email protected]> Reported-by: kbuild test robot <[email protected]> # ima_asymmetric_keys.c is built as a kernel module. Fixes: 88e70da ("IMA: Define an IMA hook to measure keys") Fixes: cb1aa38 ("KEYS: Call the IMA hook to measure keys") [[email protected]: updated patch description] Signed-off-by: Mimi Zohar <[email protected]>
1 parent f47825c commit ea78979

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

include/linux/ima.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static inline void ima_add_kexec_buffer(struct kimage *image)
101101
{}
102102
#endif
103103

104-
#if defined(CONFIG_IMA) && defined(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE)
104+
#ifdef CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS
105105
extern void ima_post_key_create_or_update(struct key *keyring,
106106
struct key *key,
107107
const void *payload, size_t plen,
@@ -113,7 +113,7 @@ static inline void ima_post_key_create_or_update(struct key *keyring,
113113
size_t plen,
114114
unsigned long flags,
115115
bool create) {}
116-
#endif /* CONFIG_IMA && CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE */
116+
#endif /* CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS */
117117

118118
#ifdef CONFIG_IMA_APPRAISE
119119
extern bool is_ima_appraise_enabled(void);

security/integrity/ima/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,9 @@ config IMA_APPRAISE_SIGNED_INIT
310310
default n
311311
help
312312
This option requires user-space init to be signed.
313+
314+
config IMA_MEASURE_ASYMMETRIC_KEYS
315+
bool
316+
depends on IMA
317+
depends on ASYMMETRIC_PUBLIC_KEY_SUBTYPE=y
318+
default y

security/integrity/ima/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o
1212
ima-$(CONFIG_IMA_APPRAISE_MODSIG) += ima_modsig.o
1313
ima-$(CONFIG_HAVE_IMA_KEXEC) += ima_kexec.o
1414
obj-$(CONFIG_IMA_BLACKLIST_KEYRING) += ima_mok.o
15-
obj-$(CONFIG_ASYMMETRIC_PUBLIC_KEY_SUBTYPE) += ima_asymmetric_keys.o
15+
obj-$(CONFIG_IMA_MEASURE_ASYMMETRIC_KEYS) += ima_asymmetric_keys.o

0 commit comments

Comments
 (0)