]>
Commit | Line | Data |
---|---|---|
7eb50402 GKH |
1 | From 76a658c20efd541a62838d9ff68ce94170d7a549 Mon Sep 17 00:00:00 2001 |
2 | From: Richard Guy Briggs <rgb@redhat.com> | |
3 | Date: Tue, 28 Jun 2016 12:06:58 -0400 | |
4 | Subject: audit: move calcs after alloc and check when logging set loginuid | |
5 | ||
6 | From: Richard Guy Briggs <rgb@redhat.com> | |
7 | ||
8 | commit 76a658c20efd541a62838d9ff68ce94170d7a549 upstream. | |
9 | ||
10 | Move the calculations of values after the allocation in case the | |
11 | allocation fails. This avoids wasting effort in the rare case that it | |
12 | fails, but more importantly saves us extra logic to release the tty | |
13 | ref. | |
14 | ||
15 | Signed-off-by: Richard Guy Briggs <rgb@redhat.com> | |
16 | Signed-off-by: Paul Moore <paul@paul-moore.com> | |
17 | Cc: Ben Hutchings <ben.hutchings@codethink.co.uk> | |
18 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
19 | ||
20 | --- | |
21 | kernel/auditsc.c | 7 ++++--- | |
22 | 1 file changed, 4 insertions(+), 3 deletions(-) | |
23 | ||
24 | --- a/kernel/auditsc.c | |
25 | +++ b/kernel/auditsc.c | |
26 | @@ -1981,14 +1981,15 @@ static void audit_log_set_loginuid(kuid_ | |
27 | if (!audit_enabled) | |
28 | return; | |
29 | ||
30 | + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); | |
31 | + if (!ab) | |
32 | + return; | |
33 | + | |
34 | uid = from_kuid(&init_user_ns, task_uid(current)); | |
35 | oldloginuid = from_kuid(&init_user_ns, koldloginuid); | |
36 | loginuid = from_kuid(&init_user_ns, kloginuid), | |
37 | tty = audit_get_tty(current); | |
38 | ||
39 | - ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); | |
40 | - if (!ab) | |
41 | - return; | |
42 | audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid); | |
43 | audit_log_task_context(ab); | |
44 | audit_log_format(ab, " old-auid=%u auid=%u tty=%s old-ses=%u ses=%u res=%d", |