]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ima: Introduce ima_dump_measurement()
authorRoberto Sassu <roberto.sassu@huawei.com>
Fri, 5 Jun 2026 17:22:32 +0000 (19:22 +0200)
committerMimi Zohar <zohar@linux.ibm.com>
Mon, 8 Jun 2026 15:43:15 +0000 (11:43 -0400)
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>
security/integrity/ima/ima_kexec.c

index 8dc9459622b39816ff943017df714686d801b183..26d41974429e4da16f6f376e9acebdcdd3b6470b 100644 (file)
@@ -80,6 +80,17 @@ out:
        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;
-               }
        }
 
        /*