Message ID | 20220125224645.79319-14-stefanb@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ima: Namespace IMA with audit support in IMA-ns | expand |
On Tue, Jan 25, 2022 at 05:46:35PM -0500, Stefan Berger wrote: > From: Stefan Berger <stefanb@linux.ibm.com> > > Only accept AUDIT rules for non-init_ima_ns namespaces rejecting all rules > that require support for measuring, appraisal, and hashing. > > Signed-off-by: Stefan Berger <stefanb@linux.ibm.com> > > --- Okay, seems sensible, Acked-by: Christian Brauner <brauner@kernel.org>
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 3b754b9f5ef7..e8140e73d80b 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -1794,6 +1794,17 @@ static int ima_parse_rule(struct ima_namespace *ns, result = -EINVAL; break; } + + /* IMA namespace only accepts AUDIT rules */ + if (ns != &init_ima_ns && result == 0) { + switch (entry->action) { + case MEASURE: + case APPRAISE: + case HASH: + result = -EINVAL; + goto err_audit; + } + } } if (!result && !ima_validate_rule(entry)) result = -EINVAL; @@ -1806,6 +1817,7 @@ static int ima_parse_rule(struct ima_namespace *ns, check_template_modsig(template_desc); } +err_audit: audit_log_format(ab, "res=%d", !result); audit_log_end(ab); return result;