Received: by 10.223.185.116 with SMTP id b49csp7828273wrg; Thu, 1 Mar 2018 11:51:26 -0800 (PST) X-Google-Smtp-Source: AG47ELsgX0772VI8T1MknYoRJf7uT3MNZ2dlAKuFg2zGY/ZKmO9HA6jnyQSZDH0cP3BPOCdBKhcA X-Received: by 2002:a17:902:7290:: with SMTP id d16-v6mr2907630pll.31.1519933886628; Thu, 01 Mar 2018 11:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519933886; cv=none; d=google.com; s=arc-20160816; b=t0uucmd52xdjNM9BqVYzxc1zrA/HyovJmurvUUhmpjGr7eImxVy2DZLXxsBsemqHTC 9Dr/26qcdvcXECRc1yZwPwnrl8D1CXCs4O+cKgy68ICJlG9wOUxUbU+7puf49AUnWrA+ Iiygc5YxPTDCn/bLccxrSR3OIkt/tUbwY7n/OV0SzVwT/klHfO5Ymn86fwJ1efpKwefG SZoQphNIMbkm8PB11mnBKsNMXLU0MRE8YtEuf1vYfxe3vuWdj1uAxipLmCLlqnaCx+h/ fm4GZVVXhVHUymfJhUhoNtyu/kiqd7ytfUSpzkvsLjRR+maBJNo7wiLQk2pJqKJvfHmP xyyg== 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=XfhP8Sbj0sYsXZ9F2X48ipS+F3bEAOa/ofKi2LSDsYs=; b=NfPlIlRcMkEOdRUT0JWloLW2ArcKnCLVk4v9Vx0wOB15rrcgaQPpkkQ6ehhm/H0TtN SIi/hTYCX8q1b4l1sqzvZgYMVT55k3szNxYJnh8T7CRbQ++9KRv6Yvfsp+jIdZceg2Oh teKrGhPNKSv7QTIbW7FEodb05c21lKLOF0A303Wctaj4yNqbsru2Cw6cVZW+JXOxf3bj N8R/4ouZ01qIeZQke+Gs0Fh0RAceytJfvfoySrOuHMpneGNIF4caCVZp0DVMp3Xb2il8 VsAaxB5KAWUQGrY+8YApwO5Smvseft8f/68DNbj7m3YWPn6vOjqx0VfNXavbBLeFTpa8 rEPw== 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 a16si2831229pgd.373.2018.03.01.11.51.11; Thu, 01 Mar 2018 11:51:26 -0800 (PST) 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 S1034177AbeCATq7 (ORCPT + 99 others); Thu, 1 Mar 2018 14:46:59 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43684 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1033276AbeCATqz (ORCPT ); Thu, 1 Mar 2018 14:46:55 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F4994040852; Thu, 1 Mar 2018 19:46:55 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 95DD49C070; Thu, 1 Mar 2018 19:46:43 +0000 (UTC) From: Richard Guy Briggs To: cgroups@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, Linux-Audit Mailing List , linux-fsdevel@vger.kernel.org, LKML , netdev@vger.kernel.org Cc: mszeredi@redhat.com, luto@kernel.org, jlayton@redhat.com, carlos@redhat.com, viro@zeniv.linux.org.uk, dhowells@redhat.com, simo@redhat.com, trondmy@primarydata.com, eparis@parisplace.org, serge@hallyn.com, ebiederm@xmission.com, madzcar@gmail.com, Richard Guy Briggs Subject: [RFC PATCH V1 06/12] audit: add support for non-syscall auxiliary records Date: Thu, 1 Mar 2018 14:41:09 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 01 Mar 2018 19:46:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 01 Mar 2018 19:46:55 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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 Standalone audit records have the timestamp and serial number generated on the fly and as such are unique, making them standalone. This is a prototype of a method to generate a local audit context that will be used only for a standalone record and its auxiliary record. The context is discarded immediately after the local associated records are produced. Signed-off-by: Richard Guy Briggs --- include/linux/audit.h | 8 ++++++++ kernel/auditsc.c | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/linux/audit.h b/include/linux/audit.h index ed16bb6..c0b83cb 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -227,7 +227,9 @@ static inline int audit_log_container_info(struct audit_context *context, /* These are defined in auditsc.c */ /* Public API */ extern int audit_alloc(struct task_struct *task); +extern struct audit_context *audit_alloc_local(void); extern void __audit_free(struct task_struct *task); +extern void audit_free_context(struct audit_context *context); extern void __audit_syscall_entry(int major, unsigned long a0, unsigned long a1, unsigned long a2, unsigned long a3); extern void __audit_syscall_exit(int ret_success, long ret_value); @@ -472,6 +474,12 @@ static inline int audit_alloc(struct task_struct *task) { return 0; } +static inline struct audit_context *audit_alloc_local(void) +{ + return NULL; +} +static inline void audit_free_context(struct audit_context *context) +{ } static inline void audit_free(struct task_struct *task) { } static inline void audit_syscall_entry(int major, unsigned long a0, diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 0e41884..0cbd762 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -959,8 +959,26 @@ int audit_alloc(struct task_struct *tsk) return 0; } -static inline void audit_free_context(struct audit_context *context) +struct audit_context *audit_alloc_local(void) { + struct audit_context *context; + + if (likely(!audit_ever_enabled)) + return NULL; /* Return if not auditing. */ + + context = audit_alloc_context(AUDIT_RECORD_CONTEXT); + if (!context) + return NULL; + context->serial = audit_serial(); + context->ctime = current_kernel_time64(); + context->in_syscall = 1; + return context; +} + +inline void audit_free_context(struct audit_context *context) +{ + if (!context) + return; audit_free_names(context); unroll_tree_refs(context, NULL, 0); free_tree_refs(context); -- 1.8.3.1