ima: Introduce ima_dump_measurement()

Introduce ima_dump_measurement() to simplify the code of
ima_dump_measurement_list() and to avoid repeating the
ima_dump_measurement() code block if iteration occurs on multiple lists.

No functional change: only code moved to a separate function.

Link: https://github.com/linux-integrity/linux/issues/1
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
This commit is contained in:
Roberto Sassu 2026-06-05 19:22:32 +02:00 committed by Mimi Zohar
parent 56275ec766
commit 292bc492f3

View File

@ -80,6 +80,17 @@ static int ima_alloc_kexec_file_buf(size_t segment_size)
return 0;
}
static int ima_dump_measurement(struct ima_kexec_hdr *khdr,
struct ima_queue_entry *qe)
{
if (ima_kexec_file.count >= ima_kexec_file.size)
return -EINVAL;
khdr->count++;
ima_measurements_show(&ima_kexec_file, qe);
return 0;
}
static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
unsigned long segment_size)
{
@ -97,13 +108,9 @@ static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
khdr.version = 1;
/* This is an append-only list, no need to hold the RCU read lock */
list_for_each_entry_rcu(qe, &ima_measurements, later, true) {
if (ima_kexec_file.count < ima_kexec_file.size) {
khdr.count++;
ima_measurements_show(&ima_kexec_file, qe);
} else {
ret = -EINVAL;
ret = ima_dump_measurement(&khdr, qe);
if (ret < 0)
break;
}
}
/*