return 0;
}
+/* audit callback for net specific fields */
+static void audit_cb(struct audit_buffer *ab, void *va)
+{
+ struct common_audit_data *sa = va;
+
+ if (sa->aad->iface.ns) {
+ audit_log_format(ab, " ns=");
+ audit_log_untrustedstring(ab, sa->aad->iface.ns);
+ }
+}
+
/**
* aa_audit_policy - Do auditing of policy changes
* @profile: profile to check if it can manage policy
* @op: policy operation being performed
* @gfp: memory allocation flags
+ * @nsname: name of the ns being manipulated (MAY BE NULL)
* @name: name of profile being manipulated (NOT NULL)
* @info: any extra information to be audited (MAYBE NULL)
* @error: error code
* Returns: the error to be returned after audit is done
*/
static int audit_policy(struct aa_profile *profile, int op, gfp_t gfp,
- const char *name, const char *info, int error)
+ const char *nsname, const char *name,
+ const char *info, int error)
{
struct common_audit_data sa;
struct apparmor_audit_data aad = {0,};
sa.type = LSM_AUDIT_DATA_NONE;
sa.aad = &aad;
aad.op = op;
+ aad.iface.ns = nsname;
aad.name = name;
aad.info = info;
aad.error = error;
return aa_audit(AUDIT_APPARMOR_STATUS, profile, gfp,
- &sa, NULL);
+ &sa, audit_cb);
}
/**
{
/* check if loading policy is locked out */
if (aa_g_lock_policy)
- return audit_policy(profile, op, GFP_KERNEL, NULL,
+ return audit_policy(profile, op, GFP_KERNEL, NULL, NULL,
"policy_locked", -EACCES);
if (!policy_admin_capable(ns))
- return audit_policy(profile, op, GFP_KERNEL, NULL,
+ return audit_policy(profile, op, GFP_KERNEL, NULL, NULL,
"not policy admin", -EACCES);
/* TODO: add fine grained mediation of policy loads */
ns = aa_prepare_ns(view, ns_name);
if (!ns) {
error = audit_policy(__aa_current_profile(), op, GFP_KERNEL,
- ns_name,
+ NULL, ns_name,
"failed to prepare namespace", -ENOMEM);
goto free;
}
list_del_init(&ent->list);
op = (!ent->old && !ent->rename) ? OP_PROF_LOAD : OP_PROF_REPL;
- audit_policy(__aa_current_profile(), op, GFP_ATOMIC,
+ audit_policy(__aa_current_profile(), op, GFP_ATOMIC, NULL,
ent->new->base.hname, NULL, error);
if (ent->old) {
/* audit cause of failure */
op = (!ent->old) ? OP_PROF_LOAD : OP_PROF_REPL;
- audit_policy(__aa_current_profile(), op, GFP_KERNEL,
+ audit_policy(__aa_current_profile(), op, GFP_KERNEL, NULL,
ent->new->base.hname, info, error);
/* audit status that rest of profiles in the atomic set failed too */
info = "valid profile in failed atomic policy load";
continue;
}
op = (!ent->old) ? OP_PROF_LOAD : OP_PROF_REPL;
- audit_policy(__aa_current_profile(), op, GFP_KERNEL,
+ audit_policy(__aa_current_profile(), op, GFP_KERNEL, NULL,
tmp->new->base.hname, info, error);
}
free:
/* don't fail removal if audit fails */
(void) audit_policy(__aa_current_profile(), OP_PROF_RM, GFP_KERNEL,
- name, info, error);
+ NULL, name, info, error);
aa_put_ns(ns);
aa_put_profile(profile);
return size;
fail:
(void) audit_policy(__aa_current_profile(), OP_PROF_RM, GFP_KERNEL,
- name, info, error);
+ NULL, name, info, error);
return error;
}