Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1433091

[PATCH] audit: move calcs after alloc and check when logging set loginuid

Path csiph.com!goblin2!goblin1!goblin.stu.neva.ru!news2.arglkargh.de!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod
From Richard Guy Briggs <rgb@redhat.com>
Newsgroups linux.kernel
Subject [PATCH] audit: move calcs after alloc and check when logging set loginuid
Date Tue, 28 Jun 2016 18:10:01 +0200
Message-ID <rP3Kh-Rj-19@gated-at.bofh.it> (permalink)
X-Scanned-By MIMEDefang 2.68 on 10.5.11.24
X-Greylist Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 28 Jun 2016 16:07:31 +0000 (UTC)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 34
Organization linux.* mail to news gateway
X-Original-Cc Richard Guy Briggs <rgb@redhat.com>, peter@hurleysoftware.com, sgrubb@redhat.com, pmoore@redhat.com, eparis@redhat.com
X-Original-Date Tue, 28 Jun 2016 12:06:58 -0400
X-Original-Message-ID <fbde8aaf26896ac6f177c4d87d721fdef21346b3.1467124299.git.rgb@redhat.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1433091

Show key headers only | View raw


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>
---
 kernel/auditsc.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 71e14d8..33dafa7 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1985,14 +1985,15 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
 	if (!audit_enabled)
 		return;
 
+	ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
+	if (!ab)
+		return;
+
 	uid = from_kuid(&init_user_ns, task_uid(current));
 	oldloginuid = from_kuid(&init_user_ns, koldloginuid);
 	loginuid = from_kuid(&init_user_ns, kloginuid),
 	tty = audit_get_tty(current);
 
-	ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN);
-	if (!ab)
-		return;
 	audit_log_format(ab, "pid=%d uid=%u", task_pid_nr(current), uid);
 	audit_log_task_context(ab);
 	audit_log_format(ab, " old-auid=%u auid=%u tty=%s old-ses=%u ses=%u res=%d",
-- 
1.7.1

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] audit: move calcs after alloc and check when logging set loginuid Richard Guy Briggs <rgb@redhat.com> - 2016-06-28 18:10 +0200
  Re: [PATCH] audit: move calcs after alloc and check when logging set loginuid Paul Moore <pmoore@redhat.com> - 2016-06-28 21:50 +0200

csiph-web