Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2382682imm; Thu, 14 Jun 2018 13:24:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK7bSA3SBT4KXuDGYs4UX6JYRcJ10FSdD4QmMDnECEP11CJZ78YmNsQLIbIF5akDl3CI+fW X-Received: by 2002:a65:4487:: with SMTP id l7-v6mr3564814pgq.357.1529007878828; Thu, 14 Jun 2018 13:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529007878; cv=none; d=google.com; s=arc-20160816; b=Wz0eI3EaVEHH3HG+Sh4ltIZkEL5QYqJ8GtFO2qM3Ux6Do4yy2G1b7C7ZsQV2o3YkHY VHGgGRrWeKSMcpWKQ8BiiaO1ux5G9dontHEXjHcoL2ETP6gblWu8DXlNqzZlr+kT2zeA jNX8fK+uN4RbpigVrKvibaebMagmw5yWMqVgu1WOSAdR2+nbvhuqLocsmLpj2OFy9RdM EJ0IS/VsvgzSDLirRxbAOzOov9GQuhks0dnncoBsAwKR6bGPI+47CSjcSLOrIoQti4sH hpTMSq6MOl+fBEVwVYI25JD+9n3U4khmCmxlytZdmbz5+xKAVIUtHaD/ao5MohUhZamy Ii4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Uf6g0oLagiATMoIzP0/pUdUzLcypPvVHHH2JwpZjYxM=; b=E50LXLCZ1rfIa6dbXlVxfkvYcR3BOURo5xbJVdoutkAqxlRJtviIbCJoZIaqQnbY8y YA3wxwUHiVcabaoQY8ZGUb3I1iWmD7k2hFgqAO0TxFNfAEOhrpxkS4kfugPpiiXZlKQ7 tdA1SHfkPxCNqv61HS3NChjD4HTEbaoqcr+2Tqh/ZuaQ4+gY4v6oEFkw4JhxnO96w/zU /0J5KdjDOUXXA5wagIiGVeSy3+QvGOxhYMPvwpjcCq+3Df4T7Cq57ioZxZzNen3BDyoQ pBEhn9UgtXQMnyfutrGv08KfdumNEpJjkVUEu2sU2v0eh2G8wxkQxrr8QhBf7sqGx6g0 WhWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e72-v6si5666113pfl.132.2018.06.14.13.24.24; Thu, 14 Jun 2018 13:24:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936083AbeFNUXo (ORCPT + 99 others); Thu, 14 Jun 2018 16:23:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:39498 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755486AbeFNUXU (ORCPT ); Thu, 14 Jun 2018 16:23:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6B7FD738E9; Thu, 14 Jun 2018 20:23:19 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-45.rdu2.redhat.com [10.10.112.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0586D11166FE; Thu, 14 Jun 2018 20:23:17 +0000 (UTC) From: Richard Guy Briggs To: Linux-Audit Mailing List , LKML Cc: eparis@parisplace.org, Paul Moore , Steve Grubb , Alexander Viro , Richard Guy Briggs Subject: [RFC PATCH ghak59 V1 5/6] audit: move EOE record after kill_trees for exit/free Date: Thu, 14 Jun 2018 16:21:15 -0400 Message-Id: <65299efddc04e19e6ad4b06fbde0bb3db2643cb5.1529003588.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 14 Jun 2018 20:23:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Thu, 14 Jun 2018 20:23:19 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rgb@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The EOE record was being issued prior to the pruning of the killed_tree list. Move the EOE record creation out of audit_log_exit() and into its callers __audit_free() and __audit_syscall_exit() so that audit_kill_trees() can be called prior to the EOE record creation and any purged trees CONFIG_CHANGE records included in the syscall record event. See: https://github.com/linux-audit/audit-kernel/issues/50 See: https://github.com/linux-audit/audit-kernel/issues/59 Signed-off-by: Richard Guy Briggs --- kernel/auditsc.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 2590c9e..d56aead 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -1460,10 +1460,6 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts audit_log_proctitle(tsk, context); - /* Send end of event record to help user space know we are finished */ - ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE); - if (ab) - audit_log_end(ab); if (call_panic) audit_panic("error converting sid to string"); } @@ -1491,6 +1487,14 @@ void __audit_free(struct task_struct *tsk) audit_log_exit(context, tsk); if (!list_empty(&context->killed_trees)) audit_kill_trees(context); + if (context->in_syscall && context->current_state == AUDIT_RECORD_CONTEXT) { + struct audit_buffer *ab; + + /* Send end of event record to help user space know we are finished */ + ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE); + if (ab) + audit_log_end(ab); + } audit_free_context(context); } @@ -1572,13 +1576,19 @@ void __audit_syscall_exit(int success, long return_code) if (context->in_syscall && context->current_state == AUDIT_RECORD_CONTEXT) audit_log_exit(context, current); + if (!list_empty(&context->killed_trees)) + audit_kill_trees(context); + if (context->in_syscall && context->current_state == AUDIT_RECORD_CONTEXT) { + struct audit_buffer *ab; + /* Send end of event record to help user space know we are finished */ + ab = audit_log_start(context, GFP_KERNEL, AUDIT_EOE); + if (ab) + audit_log_end(ab); + } context->in_syscall = 0; context->prio = context->state == AUDIT_RECORD_CONTEXT ? ~0ULL : 0; - if (!list_empty(&context->killed_trees)) - audit_kill_trees(context); - audit_free_names(context); unroll_tree_refs(context, NULL, 0); audit_free_aux(context); -- 1.8.3.1