Skip to content

Commit a2c97da

Browse files
rgbriggspcmoore
authored andcommitted
audit: use session_info helper
There are still a couple of places (mark and watch config changes) that open code auid and ses fields in sequence in records instead of using the audit_log_session_info() helper. Use the helper. Adjust the helper to accommodate being the first fields. Passes audit-testsuite. Signed-off-by: Richard Guy Briggs <rgb@redhat.com> [PM: fixed misspellings in the description] Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 0fe3c7f commit a2c97da

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

‎kernel/audit.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ static int audit_log_config_change(char *function_name, u32 new, u32 old,
400400
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONFIG_CHANGE);
401401
if (unlikely(!ab))
402402
return rc;
403-
audit_log_format(ab, "%s=%u old=%u", function_name, new, old);
403+
audit_log_format(ab, "%s=%u old=%u ", function_name, new, old);
404404
audit_log_session_info(ab);
405405
rc = audit_log_task_context(ab);
406406
if (rc)
@@ -1067,7 +1067,7 @@ static void audit_log_common_recv_msg(struct audit_buffer **ab, u16 msg_type)
10671067
*ab = audit_log_start(NULL, GFP_KERNEL, msg_type);
10681068
if (unlikely(!*ab))
10691069
return;
1070-
audit_log_format(*ab, "pid=%d uid=%u", pid, uid);
1070+
audit_log_format(*ab, "pid=%d uid=%u ", pid, uid);
10711071
audit_log_session_info(*ab);
10721072
audit_log_task_context(*ab);
10731073
}
@@ -2042,7 +2042,7 @@ void audit_log_session_info(struct audit_buffer *ab)
20422042
unsigned int sessionid = audit_get_sessionid(current);
20432043
uid_t auid = from_kuid(&init_user_ns, audit_get_loginuid(current));
20442044

2045-
audit_log_format(ab, " auid=%u ses=%u", auid, sessionid);
2045+
audit_log_format(ab, "auid=%u ses=%u", auid, sessionid);
20462046
}
20472047

20482048
void audit_log_key(struct audit_buffer *ab, char *key)

‎kernel/audit_fsnotify.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,8 @@ static void audit_mark_log_rule_change(struct audit_fsnotify_mark *audit_mark, c
130130
ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE);
131131
if (unlikely(!ab))
132132
return;
133-
audit_log_format(ab, "auid=%u ses=%u op=%s",
134-
from_kuid(&init_user_ns, audit_get_loginuid(current)),
135-
audit_get_sessionid(current), op);
133+
audit_log_session_info(ab);
134+
audit_log_format(ab, " op=%s", op);
136135
audit_log_format(ab, " path=");
137136
audit_log_untrustedstring(ab, audit_mark->path);
138137
audit_log_key(ab, rule->filterkey);

‎kernel/audit_watch.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,8 @@ static void audit_watch_log_rule_change(struct audit_krule *r, struct audit_watc
245245
ab = audit_log_start(NULL, GFP_NOFS, AUDIT_CONFIG_CHANGE);
246246
if (!ab)
247247
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);
248+
audit_log_session_info(ab);
249+
audit_log_format(ab, "op=%s", op);
251250
audit_log_format(ab, " path=");
252251
audit_log_untrustedstring(ab, w->path);
253252
audit_log_key(ab, r->filterkey);

0 commit comments

Comments
 (0)