18 #include <linux/fcntl.h>
19 #include <linux/slab.h>
20 #include <linux/module.h>
28 static int valid_policy = 1;
40 static ssize_t ima_show_htable_violations(
struct file *filp,
42 size_t count, loff_t *ppos)
44 return ima_show_htable_value(buf, count, ppos, &
ima_htable.violations);
48 .read = ima_show_htable_violations,
52 static ssize_t ima_show_measurements_count(
struct file *filp,
54 size_t count, loff_t *ppos)
56 return ima_show_htable_value(buf, count, ppos, &
ima_htable.len);
61 .read = ima_show_measurements_count,
66 static void *ima_measurements_start(
struct seq_file *
m, loff_t *
pos)
73 list_for_each_entry_rcu(qe, &ima_measurements,
later) {
83 static void *ima_measurements_next(
struct seq_file *m,
void *
v, loff_t *pos)
91 qe = list_entry_rcu(qe->
later.next,
96 return (&qe->
later == &ima_measurements) ?
NULL : qe;
99 static void ima_measurements_stop(
struct seq_file *m,
void *v)
116 static int ima_measurements_show(
struct seq_file *m,
void *v)
122 u32 pcr = CONFIG_IMA_MEASURE_PCR_IDX;
134 ima_putc(m, &pcr,
sizeof pcr);
141 ima_putc(m, &namelen,
sizeof namelen);
153 .start = ima_measurements_start,
154 .next = ima_measurements_next,
155 .stop = ima_measurements_stop,
156 .show = ima_measurements_show
161 return seq_open(file, &ima_measurments_seqops);
165 .open = ima_measurements_open,
186 ima_print_digest(m, entry->
digest);
190 ima_putc(m, entry->
digest, IMA_DIGEST_SIZE);
193 ima_putc(m, &namelen,
sizeof namelen);
201 static int ima_ascii_measurements_show(
struct seq_file *m,
void *v)
213 seq_printf(m,
"%2d ", CONFIG_IMA_MEASURE_PCR_IDX);
216 ima_print_digest(m, e->
digest);
227 static const struct seq_operations ima_ascii_measurements_seqops = {
228 .start = ima_measurements_start,
229 .next = ima_measurements_next,
230 .stop = ima_measurements_stop,
231 .show = ima_ascii_measurements_show
236 return seq_open(file, &ima_ascii_measurements_seqops);
240 .open = ima_ascii_measurements_open,
247 size_t datalen, loff_t *ppos)
279 static struct dentry *ima_dir;
280 static struct dentry *binary_runtime_measurements;
281 static struct dentry *ascii_runtime_measurements;
282 static struct dentry *runtime_measurements_count;
283 static struct dentry *violations;
284 static struct dentry *ima_policy;
290 static int ima_open_policy(
struct inode *
inode,
struct file * filp)
307 static int ima_release_policy(
struct inode *inode,
struct file *file)
322 .open = ima_open_policy,
323 .write = ima_write_policy,
324 .release = ima_release_policy,
334 binary_runtime_measurements =
337 &ima_measurements_ops);
338 if (IS_ERR(binary_runtime_measurements))
341 ascii_runtime_measurements =
344 &ima_ascii_measurements_ops);
345 if (IS_ERR(ascii_runtime_measurements))
348 runtime_measurements_count =
351 &ima_measurements_count_ops);
352 if (IS_ERR(runtime_measurements_count))
357 ima_dir,
NULL, &ima_htable_violations_ops);
358 if (IS_ERR(violations))
364 &ima_measure_policy_ops);
365 if (IS_ERR(ima_policy))