Skip to content

Commit 0ad0bb6

Browse files
pcmooregregkh
authored andcommitted
audit: ensure that 'audit=1' actually enables audit for PID 1
[ Upstream commit 173743d ] 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 <rgb@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4086f7c commit 0ad0bb6

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎kernel/audit.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ static int audit_initialized;
8585
#define AUDIT_OFF 0
8686
#define AUDIT_ON 1
8787
#define AUDIT_LOCKED 2
88-
u32 audit_enabled;
89-
u32 audit_ever_enabled;
88+
u32 audit_enabled = AUDIT_OFF;
89+
u32 audit_ever_enabled = !!AUDIT_OFF;
9090

9191
EXPORT_SYMBOL_GPL(audit_enabled);
9292

9393
/* Default state when kernel boots without any parameters. */
94-
static u32 audit_default;
94+
static u32 audit_default = AUDIT_OFF;
9595

9696
/* If auditing cannot proceed, audit_failure selects what happens. */
9797
static u32 audit_failure = AUDIT_FAIL_PRINTK;
@@ -1552,8 +1552,6 @@ static int __init audit_init(void)
15521552
register_pernet_subsys(&audit_net_ops);
15531553

15541554
audit_initialized = AUDIT_INITIALIZED;
1555-
audit_enabled = audit_default;
1556-
audit_ever_enabled |= !!audit_default;
15571555

15581556
kauditd_task = kthread_run(kauditd_thread, NULL, "kauditd");
15591557
if (IS_ERR(kauditd_task)) {
@@ -1575,6 +1573,8 @@ static int __init audit_enable(char *str)
15751573
audit_default = !!simple_strtol(str, NULL, 0);
15761574
if (!audit_default)
15771575
audit_initialized = AUDIT_DISABLED;
1576+
audit_enabled = audit_default;
1577+
audit_ever_enabled = !!audit_enabled;
15781578

15791579
pr_info("%s\n", audit_default ?
15801580
"enabled (after initialization)" : "disabled (until reboot)");

0 commit comments

Comments
 (0)