Skip to content

Commit 52c2083

Browse files
Tushar Sugandhimimizohar
authored andcommitted
IMA: support for duplicate measurement records
IMA measures contents of a given file/buffer/critical-data record, and properly re-measures it on change. However, IMA does not measure the duplicate value for a given record, since TPM extend is a very expensive operation. For example, if the record changes from value 'v#1' to 'v#2', and then back to 'v#1', IMA will not measure and log the last change to 'v#1', since the hash of 'v#1' for that record is already present in the IMA htable. This limits the ability of an external attestation service to accurately determine the current state of the system. The service would incorrectly conclude that the latest value of the given record on the system is 'v#2', and act accordingly. Define and use a new Kconfig option IMA_DISABLE_HTABLE to permit duplicate records in the IMA measurement list. In addition to the duplicate measurement records described above, other duplicate file measurement records may be included in the log, when CONFIG_IMA_DISABLE_HTABLE is enabled. For example, - i_version is not enabled, - i_generation changed, - same file present on different filesystems, - an inode is evicted from dcache Signed-off-by: Tushar Sugandhi <tusharsu@linux.microsoft.com> Reviewed-by: Petr Vorel <pvorel@suse.cz> [zohar@linux.ibm.com: updated list of duplicate measurement records] Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent c679134 commit 52c2083

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

security/integrity/ima/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,10 @@ config IMA_SECURE_AND_OR_TRUSTED_BOOT
334334
help
335335
This option is selected by architectures to enable secure and/or
336336
trusted boot based on IMA runtime policies.
337+
338+
config IMA_DISABLE_HTABLE
339+
bool "Disable htable to allow measurement of duplicate records"
340+
depends on IMA
341+
default n
342+
help
343+
This option disables htable to allow measurement of duplicate records.

security/integrity/ima/ima_queue.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,16 @@ int ima_add_template_entry(struct ima_template_entry *entry, int violation,
168168
int result = 0, tpmresult = 0;
169169

170170
mutex_lock(&ima_extend_list_mutex);
171-
if (!violation) {
171+
if (!violation && !IS_ENABLED(CONFIG_IMA_DISABLE_HTABLE)) {
172172
if (ima_lookup_digest_entry(digest, entry->pcr)) {
173173
audit_cause = "hash_exists";
174174
result = -EEXIST;
175175
goto out;
176176
}
177177
}
178178

179-
result = ima_add_digest_entry(entry, 1);
179+
result = ima_add_digest_entry(entry,
180+
!IS_ENABLED(CONFIG_IMA_DISABLE_HTABLE));
180181
if (result < 0) {
181182
audit_cause = "ENOMEM";
182183
audit_info = 0;

0 commit comments

Comments
 (0)