Thread (27 messages) 27 messages, 3 authors, 2017-06-13

[Linux-ima-devel] [PATCH 5/7] ima: add securityfs interface to save a measurements list with kexec header

From: Mimi Zohar <hidden>
Date: 2017-06-06 11:34:38
Also in: lkml

On Tue, 2017-06-06 at 11:13 +0200, Roberto Sassu wrote:
quoted
quoted
? /* returns pointer to hlist_node */
? static void *ima_measurements_start(struct seq_file *m, loff_t *pos)
? {
??????loff_t l = *pos;
??????struct ima_queue_entry *qe;
+????struct ima_queue_entry *qe_found = NULL;
+????unsigned long size = 0, count = 0;
+????bool khdr = m->file->f_path.dentry == binary_kexec_runtime_measurements;

??????/* we need a lock since pos could point beyond last element */
??????rcu_read_lock();
??????list_for_each_entry_rcu(qe, &ima_measurements, later) {
-????????????if (!l--) {
-????????????????????rcu_read_unlock();
-????????????????????return qe;
+????????????if (!l) {
+????????????????????qe_found = qe_found ? qe_found : qe;
What is this?
ima_measurements_start() should return the list entry at position *pos.
The line above prevents qe_found from being updated when the loop
continues until the last list entry.
Wouldn't a simple if/then be more appropriate here?
quoted
quoted
+
+????????????????????if (!khdr)
+????????????????????????????break;
Does this test need to be in the loop?
Yes. Otherwise, ima_measurements_start() would iterate over the whole
list when it is not necessary.
Oh, for displaying the measurement list you need to set qe_found
before returning.

thanks,

Mimi

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help