![]() |
|
|||
0001 // SPDX-License-Identifier: GPL-2.0+ 0002 /* 0003 * Copyright (C) 2019 Microsoft Corporation 0004 * 0005 * Author: Lakshmi Ramasubramanian (nramas@linux.microsoft.com) 0006 * 0007 * File: ima_asymmetric_keys.c 0008 * Defines an IMA hook to measure asymmetric keys on key 0009 * create or update. 0010 */ 0011 0012 #include <keys/asymmetric-type.h> 0013 #include <linux/user_namespace.h> 0014 #include <linux/ima.h> 0015 #include "ima.h" 0016 0017 /** 0018 * ima_post_key_create_or_update - measure asymmetric keys 0019 * @keyring: keyring to which the key is linked to 0020 * @key: created or updated key 0021 * @payload: The data used to instantiate or update the key. 0022 * @payload_len: The length of @payload. 0023 * @flags: key flags 0024 * @create: flag indicating whether the key was created or updated 0025 * 0026 * Keys can only be measured, not appraised. 0027 * The payload data used to instantiate or update the key is measured. 0028 */ 0029 void ima_post_key_create_or_update(struct key *keyring, struct key *key, 0030 const void *payload, size_t payload_len, 0031 unsigned long flags, bool create) 0032 { 0033 bool queued = false; 0034 0035 /* Only asymmetric keys are handled by this hook. */ 0036 if (key->type != &key_type_asymmetric) 0037 return; 0038 0039 if (!payload || (payload_len == 0)) 0040 return; 0041 0042 if (ima_should_queue_key()) 0043 queued = ima_queue_key(keyring, payload, payload_len); 0044 0045 if (queued) 0046 return; 0047 0048 /* 0049 * keyring->description points to the name of the keyring 0050 * (such as ".builtin_trusted_keys", ".ima", etc.) to 0051 * which the given key is linked to. 0052 * 0053 * The name of the keyring is passed in the "eventname" 0054 * parameter to process_buffer_measurement() and is set 0055 * in the "eventname" field in ima_event_data for 0056 * the key measurement IMA event. 0057 * 0058 * The name of the keyring is also passed in the "keyring" 0059 * parameter to process_buffer_measurement() to check 0060 * if the IMA policy is configured to measure a key linked 0061 * to the given keyring. 0062 */ 0063 process_buffer_measurement(&init_user_ns, NULL, payload, payload_len, 0064 keyring->description, KEY_CHECK, 0, 0065 keyring->description, false, NULL, 0); 0066 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |