]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.4.133/audit-move-calcs-after-alloc-and-check-when-logging-set-loginuid.patch
Fixes for 5.10
[thirdparty/kernel/stable-queue.git] / releases / 4.4.133 / audit-move-calcs-after-alloc-and-check-when-logging-set-loginuid.patch
CommitLineData
7eb50402
GKH
1From 76a658c20efd541a62838d9ff68ce94170d7a549 Mon Sep 17 00:00:00 2001
2From: Richard Guy Briggs <rgb@redhat.com>
3Date: Tue, 28 Jun 2016 12:06:58 -0400
4Subject: audit: move calcs after alloc and check when logging set loginuid
5
6From: Richard Guy Briggs <rgb@redhat.com>
7
8commit 76a658c20efd541a62838d9ff68ce94170d7a549 upstream.
9
10Move the calculations of values after the allocation in case the
11allocation fails. This avoids wasting effort in the rare case that it
12fails, but more importantly saves us extra logic to release the tty
13ref.
14
15Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
16Signed-off-by: Paul Moore <paul@paul-moore.com>
17Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
18Signed-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",