8000 audit: move calcs after alloc and check when logging set loginuid · bsd-unix/linux@76a658c · GitHub
[go: up one dir, main page]

Skip to content 65F0

Commit 76a658c

Browse files
rgbriggspcmoore
authored andcommitted
audit: move calcs after alloc and check when logging set loginuid
Move the calculations of values after the allocation in case the allocation fails. This avoids wasting effort in the rare case that it fails, but more importantly saves us extra logic to release the tty ref. Signed-off-by: Richard Guy Briggs <rgb@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent 188e3c5 commit 76a658c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/auditsc.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,14 +1985,15 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
19851985
if (!audit_enabled)
19861986
return;
19871987

1988+
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
1989+
if (!ab)
1990+
return;
1991+
19881992
uid = from_kuid(&init_user_ns, task_uid(current));
19891993
oldloginuid = from_kuid(&init_user_ns, koldloginuid);
19901994
loginuid = from_kuid(&init_user_ns, kloginuid),
19911995
tty = audit_get_tty(current);
19921996

1993-
ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
1994-
if (!ab)
1995-
return;
19961997
audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid);
19971998
audit_log_task_context(ab);
19981999
audit_log_format(ab, " old-auid=%u auid=%u tty=%s old-ses=%u ses=%u res=%d",

0 commit comments

Comments
 (0)
0