Skip to content

Commit 4fa7f08

Browse files
rgbriggspcmoore
authored andcommitted
audit: simplify audit_enabled check in audit_watch_log_rule_change()
Check the audit_enabled flag and bail immediately. This does not change the functionality, but brings the code format in line with similar checks in audit_tree_log_remove_rule(), audit_mark_log_rule_change(), and elsewhere in the audit code. See: linux-audit/audit-kernel#50 Signed-off-by: Richard Guy Briggs <rgb@redhat.com> [PM: tweaked subject line] Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 65a8766 commit 4fa7f08

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

‎kernel/audit_watch.c‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -238,20 +238,21 @@ static struct audit_watch *audit_dupe_watch(struct audit_watch *old)
238238

239239
static void audit_watch_log_rule_change(struct audit_krule *r, struct audit_watch *w, char *op)
240240
{
241-
if (audit_enabled) {
242-
struct audit_buffer *ab;
243-
ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE);
244-
if (unlikely(!ab))
245-
return;
246-
audit_log_format(ab, "auid=%u ses=%u op=%s",
247-
from_kuid(&init_user_ns, audit_get_loginuid(current)),
248-
audit_get_sessionid(current), op);
249-
audit_log_format(ab, " path=");
250-
audit_log_untrustedstring(ab, w->path);
251-
audit_log_key(ab, r->filterkey);
252-
audit_log_format(ab, " list=%d res=1", r->listnr);
253-
audit_log_end(ab);
254-
}
241+
struct audit_buffer *ab;
242+
243+
if (!audit_enabled)
244+
return;
245+
ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE);
246+
if (!ab)
247+
return;
248+
audit_log_format(ab, "auid=%u ses=%u op=%s",
249+
from_kuid(&init_user_ns, audit_get_loginuid(current)),
250+
audit_get_sessionid(current), op);
251+
audit_log_format(ab, " path=");
252+
audit_log_untrustedstring(ab, w->path);
253+
audit_log_key(ab, r->filterkey);
254+
audit_log_format(ab, " list=%d res=1", r->listnr);
255+
audit_log_end(ab);
255256
}
256257

257258
/* Update inode info in audit rules based on filesystem event. */

0 commit comments

Comments
 (0)