Return-Path: Received: from omzsmtpe03.verizonbusiness.com ([199.249.25.208]:37349 "EHLO omzsmtpe03.verizonbusiness.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752991AbdLBPyb (ORCPT ); Sat, 2 Dec 2017 10:54:31 -0500 From: alexander.levin@verizon.com Cc: Paul Moore , alexander.levin@verizon.com To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: [PATCH AUTOSEL for 4.4 20/20] audit: ensure that 'audit=1' actually enables audit for PID 1 Date: Sat, 2 Dec 2017 15:53:02 +0000 Message-ID: <20171202155243.7774-20-alexander.levin@verizon.com> References: <20171202155243.7774-1-alexander.levin@verizon.com> In-Reply-To: <20171202155243.7774-1-alexander.levin@verizon.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Paul Moore [ Upstream commit 173743dd99a49c956b124a74c8aacb0384739a4c ] Prior to this patch we enabled audit in audit_init(), which is too late for PID 1 as the standard initcalls are run after the PID 1 task is forked. This means that we never allocate an audit_context (see audit_alloc()) for PID 1 and therefore miss a lot of audit events generated by PID 1. This patch enables audit as early as possible to help ensure that when PID 1 is forked it can allocate an audit_context if required. Reviewed-by: Richard Guy Briggs Signed-off-by: Paul Moore Signed-off-by: Sasha Levin --- kernel/audit.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 5ffcbd354a52..41f9a38bb800 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -80,13 +80,13 @@ static int audit_initialized; #define AUDIT_OFF 0 #define AUDIT_ON 1 #define AUDIT_LOCKED 2 -u32 audit_enabled; -u32 audit_ever_enabled; +u32 audit_enabled =3D AUDIT_OFF; +u32 audit_ever_enabled =3D !!AUDIT_OFF; =20 EXPORT_SYMBOL_GPL(audit_enabled); =20 /* Default state when kernel boots without any parameters. */ -static u32 audit_default; +static u32 audit_default =3D AUDIT_OFF; =20 /* If auditing cannot proceed, audit_failure selects what happens. */ static u32 audit_failure =3D AUDIT_FAIL_PRINTK; @@ -1179,8 +1179,6 @@ static int __init audit_init(void) skb_queue_head_init(&audit_skb_queue); skb_queue_head_init(&audit_skb_hold_queue); audit_initialized =3D AUDIT_INITIALIZED; - audit_enabled =3D audit_default; - audit_ever_enabled |=3D !!audit_default; =20 audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL, "initialized"); =20 @@ -1197,6 +1195,8 @@ static int __init audit_enable(char *str) audit_default =3D !!simple_strtol(str, NULL, 0); if (!audit_default) audit_initialized =3D AUDIT_DISABLED; + audit_enabled =3D audit_default; + audit_ever_enabled =3D !!audit_enabled; =20 pr_info("%s\n", audit_default ? "enabled (after initialization)" : "disabled (until reboot)"); --=20 2.11.0