Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Commit

Permalink
ima: show rules with IMA_INMASK correctly
Browse files Browse the repository at this point in the history
commit 8cdc23a upstream.

Show the '^' character when a policy rule has flag IMA_INMASK.

Fixes: 80eae20 ("IMA: allow reading back the current IMA policy")
Signed-off-by: Roberto Sassu <[email protected]>
Cc: [email protected]
Signed-off-by: Mimi Zohar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
robertosassu authored and gregkh committed Jun 9, 2019
1 parent 2115898 commit f85b87a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions security/integrity/ima/ima_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1059,10 +1059,10 @@ enum {
};

static const char *const mask_tokens[] = {
"MAY_EXEC",
"MAY_WRITE",
"MAY_READ",
"MAY_APPEND"
"^MAY_EXEC",
"^MAY_WRITE",
"^MAY_READ",
"^MAY_APPEND"
};

#define __ima_hook_stringify(str) (#str),
Expand Down Expand Up @@ -1122,6 +1122,7 @@ int ima_policy_show(struct seq_file *m, void *v)
struct ima_rule_entry *entry = v;
int i;
char tbuf[64] = {0,};
int offset = 0;

rcu_read_lock();

Expand All @@ -1145,15 +1146,17 @@ int ima_policy_show(struct seq_file *m, void *v)
if (entry->flags & IMA_FUNC)
policy_func_show(m, entry->func);

if (entry->flags & IMA_MASK) {
if ((entry->flags & IMA_MASK) || (entry->flags & IMA_INMASK)) {
if (entry->flags & IMA_MASK)
offset = 1;
if (entry->mask & MAY_EXEC)
seq_printf(m, pt(Opt_mask), mt(mask_exec));
seq_printf(m, pt(Opt_mask), mt(mask_exec) + offset);
if (entry->mask & MAY_WRITE)
seq_printf(m, pt(Opt_mask), mt(mask_write));
seq_printf(m, pt(Opt_mask), mt(mask_write) + offset);
if (entry->mask & MAY_READ)
seq_printf(m, pt(Opt_mask), mt(mask_read));
seq_printf(m, pt(Opt_mask), mt(mask_read) + offset);
if (entry->mask & MAY_APPEND)
seq_printf(m, pt(Opt_mask), mt(mask_append));
seq_printf(m, pt(Opt_mask), mt(mask_append) + offset);
seq_puts(m, " ");
}

Expand Down

0 comments on commit f85b87a

Please sign in to comment.