Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 41c89b64 authored by Petko Manolov's avatar Petko Manolov Committed by Mimi Zohar
Browse files

IMA: create machine owner and blacklist keyrings



This option creates IMA MOK and blacklist keyrings.  IMA MOK is an
intermediate keyring that sits between .system and .ima keyrings,
effectively forming a simple CA hierarchy.  To successfully import a key
into .ima_mok it must be signed by a key which CA is in .system keyring.
On turn any key that needs to go in .ima keyring must be signed by CA in
either .system or .ima_mok keyrings. IMA MOK is empty at kernel boot.

IMA blacklist keyring contains all revoked IMA keys.  It is consulted
before any other keyring.  If the search is successful the requested
operation is rejected and error is returned to the caller.

Signed-off-by: default avatarPetko Manolov <petkan@mip-labs.com>
Signed-off-by: default avatarMimi Zohar <zohar@linux.vnet.ibm.com>
parent 38d859f9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -321,6 +321,8 @@ static int x509_key_preparse(struct key_preparsed_payload *prep)
			goto error_free_cert;
	} else if (!prep->trusted) {
		ret = x509_validate_trust(cert, get_system_trusted_keyring());
		if (ret)
			ret = x509_validate_trust(cert, get_ima_mok_keyring());
		if (!ret)
			prep->trusted = 1;
	}
+24 −0
Original line number Diff line number Diff line
@@ -35,4 +35,28 @@ extern int system_verify_data(const void *data, unsigned long len,
			      enum key_being_used_for usage);
#endif

#ifdef CONFIG_IMA_MOK_KEYRING
extern struct key *ima_mok_keyring;
extern struct key *ima_blacklist_keyring;

static inline struct key *get_ima_mok_keyring(void)
{
	return ima_mok_keyring;
}
static inline struct key *get_ima_blacklist_keyring(void)
{
	return ima_blacklist_keyring;
}
#else
static inline struct key *get_ima_mok_keyring(void)
{
	return NULL;
}
static inline struct key *get_ima_blacklist_keyring(void)
{
	return NULL;
}
#endif /* CONFIG_IMA_MOK_KEYRING */


#endif /* _KEYS_SYSTEM_KEYRING_H */
+14 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <linux/key-type.h>
#include <crypto/public_key.h>
#include <keys/asymmetric-type.h>
#include <keys/system_keyring.h>

#include "integrity.h"

@@ -32,9 +33,22 @@ static struct key *request_asymmetric_key(struct key *keyring, uint32_t keyid)

	pr_debug("key search: \"%s\"\n", name);

	key = get_ima_blacklist_keyring();
	if (key) {
		key_ref_t kref;

		kref = keyring_search(make_key_ref(key, 1),
				     &key_type_asymmetric, name);
		if (!IS_ERR(kref)) {
			pr_err("Key '%s' is in ima_blacklist_keyring\n", name);
			return ERR_PTR(-EKEYREJECTED);
		}
	}

	if (keyring) {
		/* search in specific keyring */
		key_ref_t kref;

		kref = keyring_search(make_key_ref(keyring, 1),
				      &key_type_asymmetric, name);
		if (IS_ERR(kref))
+18 −0
Original line number Diff line number Diff line
@@ -145,6 +145,24 @@ config IMA_TRUSTED_KEYRING

	   This option is deprecated in favor of INTEGRITY_TRUSTED_KEYRING

config IMA_MOK_KEYRING
	bool "Create IMA machine owner keys (MOK) and blacklist keyrings"
	depends on SYSTEM_TRUSTED_KEYRING
	depends on IMA_TRUSTED_KEYRING
	default n
	help
	   This option creates IMA MOK and blacklist keyrings.  IMA MOK is an
	   intermediate keyring that sits between .system and .ima keyrings,
	   effectively forming a simple CA hierarchy.  To successfully import a
	   key into .ima_mok it must be signed by a key which CA is in .system
	   keyring.  On turn any key that needs to go in .ima keyring must be
	   signed by CA in either .system or .ima_mok keyrings. IMA MOK is empty
	   at kernel boot.

	   IMA blacklist keyring contains all revoked IMA keys.  It is consulted
	   before any other keyring.  If the search is successful the requested
	   operation is rejected and error is returned to the caller.

config IMA_LOAD_X509
	bool "Load X509 certificate onto the '.ima' trusted keyring"
	depends on IMA_TRUSTED_KEYRING
+1 −0
Original line number Diff line number Diff line
@@ -8,3 +8,4 @@ obj-$(CONFIG_IMA) += ima.o
ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \
	 ima_policy.o ima_template.o ima_template_lib.o
ima-$(CONFIG_IMA_APPRAISE) += ima_appraise.o
obj-$(CONFIG_IMA_MOK_KEYRING) += ima_mok.o
Loading