|
@@ -238,20 +238,21 @@ out:
|
|
|
|
|
|
static void audit_watch_log_rule_change(struct audit_krule *r, struct audit_watch *w, char *op)
|
|
|
{
|
|
|
- if (audit_enabled) {
|
|
|
- struct audit_buffer *ab;
|
|
|
- ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE);
|
|
|
- if (unlikely(!ab))
|
|
|
- return;
|
|
|
- audit_log_format(ab, "auid=%u ses=%u op=%s",
|
|
|
- from_kuid(&init_user_ns, audit_get_loginuid(current)),
|
|
|
- audit_get_sessionid(current), op);
|
|
|
- audit_log_format(ab, " path=");
|
|
|
- audit_log_untrustedstring(ab, w->path);
|
|
|
- audit_log_key(ab, r->filterkey);
|
|
|
- audit_log_format(ab, " list=%d res=1", r->listnr);
|
|
|
- audit_log_end(ab);
|
|
|
- }
|
|
|
+ struct audit_buffer *ab;
|
|
|
+
|
|
|
+ if (!audit_enabled)
|
|
|
+ return;
|
|
|
+ ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE);
|
|
|
+ if (!ab)
|
|
|
+ return;
|
|
|
+ audit_log_format(ab, "auid=%u ses=%u op=%s",
|
|
|
+ from_kuid(&init_user_ns, audit_get_loginuid(current)),
|
|
|
+ audit_get_sessionid(current), op);
|
|
|
+ audit_log_format(ab, " path=");
|
|
|
+ audit_log_untrustedstring(ab, w->path);
|
|
|
+ audit_log_key(ab, r->filterkey);
|
|
|
+ audit_log_format(ab, " list=%d res=1", r->listnr);
|
|
|
+ audit_log_end(ab);
|
|
|
}
|
|
|
|
|
|
/* Update inode info in audit rules based on filesystem event. */
|
|
@@ -419,6 +420,13 @@ int audit_add_watch(struct audit_krule *krule, struct list_head **list)
|
|
|
struct path parent_path;
|
|
|
int h, ret = 0;
|
|
|
|
|
|
+ /*
|
|
|
+ * When we will be calling audit_add_to_parent, krule->watch might have
|
|
|
+ * been updated and watch might have been freed.
|
|
|
+ * So we need to keep a reference of watch.
|
|
|
+ */
|
|
|
+ audit_get_watch(watch);
|
|
|
+
|
|
|
mutex_unlock(&audit_filter_mutex);
|
|
|
|
|
|
/* Avoid calling path_lookup under audit_filter_mutex. */
|
|
@@ -427,8 +435,10 @@ int audit_add_watch(struct audit_krule *krule, struct list_head **list)
|
|
|
/* caller expects mutex locked */
|
|
|
mutex_lock(&audit_filter_mutex);
|
|
|
|
|
|
- if (ret)
|
|
|
+ if (ret) {
|
|
|
+ audit_put_watch(watch);
|
|
|
return ret;
|
|
|
+ }
|
|
|
|
|
|
/* either find an old parent or attach a new one */
|
|
|
parent = audit_find_parent(d_backing_inode(parent_path.dentry));
|
|
@@ -446,6 +456,7 @@ int audit_add_watch(struct audit_krule *krule, struct list_head **list)
|
|
|
*list = &audit_inode_hash[h];
|
|
|
error:
|
|
|
path_put(&parent_path);
|
|
|
+ audit_put_watch(watch);
|
|
|
return ret;
|
|
|
}
|
|
|
|