Skip to content

Commit 345123d

Browse files
thejhmimizohar
authored andcommitted
ima: add dont_audit action to suppress audit actions
"measure", "appraise" and "hash" actions all have corresponding "dont_*" actions, but "audit" currently lacks that. This means it is not currently possible to have a policy that audits everything by default, but excludes specific cases. This seems to have been an oversight back when the "audit" action was added. Add a corresponding "dont_audit" action to enable such uses. Signed-off-by: Jann Horn <jannh@google.com> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
1 parent 8f3fc4f commit 345123d

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Documentation/ABI/testing/ima_policy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Description:
2020
rule format: action [condition ...]
2121

2222
action: measure | dont_measure | appraise | dont_appraise |
23-
audit | hash | dont_hash
23+
audit | dont_audit | hash | dont_hash
2424
condition:= base | lsm [option]
2525
base: [[func=] [mask=] [fsmagic=] [fsuuid=] [fsname=]
2626
[uid=] [euid=] [gid=] [egid=]

security/integrity/ima/ima_policy.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#define APPRAISE 0x0004 /* same as IMA_APPRAISE */
4646
#define DONT_APPRAISE 0x0008
4747
#define AUDIT 0x0040
48+
#define DONT_AUDIT 0x0080
4849
#define HASH 0x0100
4950
#define DONT_HASH 0x0200
5051

@@ -1064,7 +1065,7 @@ void ima_update_policy(void)
10641065
enum policy_opt {
10651066
Opt_measure, Opt_dont_measure,
10661067
Opt_appraise, Opt_dont_appraise,
1067-
Opt_audit, Opt_hash, Opt_dont_hash,
1068+
Opt_audit, Opt_dont_audit, Opt_hash, Opt_dont_hash,
10681069
Opt_obj_user, Opt_obj_role, Opt_obj_type,
10691070
Opt_subj_user, Opt_subj_role, Opt_subj_type,
10701071
Opt_func, Opt_mask, Opt_fsmagic, Opt_fsname, Opt_fsuuid,
@@ -1086,6 +1087,7 @@ static const match_table_t policy_tokens = {
10861087
{Opt_appraise, "appraise"},
10871088
{Opt_dont_appraise, "dont_appraise"},
10881089
{Opt_audit, "audit"},
1090+
{Opt_dont_audit, "dont_audit"},
10891091
{Opt_hash, "hash"},
10901092
{Opt_dont_hash, "dont_hash"},
10911093
{Opt_obj_user, "obj_user=%s"},
@@ -1478,6 +1480,14 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
14781480

14791481
entry->action = AUDIT;
14801482
break;
1483+
case Opt_dont_audit:
1484+
ima_log_string(ab, "action", "dont_audit");
1485+
1486+
if (entry->action != UNKNOWN)
1487+
result = -EINVAL;
1488+
1489+
entry->action = DONT_AUDIT;
1490+
break;
14811491
case Opt_hash:
14821492
ima_log_string(ab, "action", "hash");
14831493

@@ -2097,6 +2107,8 @@ int ima_policy_show(struct seq_file *m, void *v)
20972107
seq_puts(m, pt(Opt_dont_appraise));
20982108
if (entry->action & AUDIT)
20992109
seq_puts(m, pt(Opt_audit));
2110+
if (entry->action & DONT_AUDIT)
2111+
seq_puts(m, pt(Opt_dont_audit));
21002112
if (entry->action & HASH)
21012113
seq_puts(m, pt(Opt_hash));
21022114
if (entry->action & DONT_HASH)

0 commit comments

Comments
 (0)