Received: by 10.192.165.156 with SMTP id m28csp77050imm; Wed, 18 Apr 2018 17:40:37 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/V1f1W+7t8Hn41QVH4qjEw6WWqtsLaOSPLs2zoGGn6sVwwT7kTKFuqPNOgATO5snt7Zen3 X-Received: by 2002:a17:902:8283:: with SMTP id y3-v6mr4090374pln.10.1524098437697; Wed, 18 Apr 2018 17:40:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524098437; cv=none; d=google.com; s=arc-20160816; b=kdQQg6BS4FJf9yl1AK2JXTY11Lvwv+LGBlcnJ6g88d2zdUH8A8laWlbrBLNXdeQIO2 v/eiMIl8OXboaIN6uUeQC6Lj0jM+5ujOoCQ23+iD4dd+7+VT/QRlit8l691ZFmjc0wa1 lYtGxKthYKtReqG31Oa5wAPdwJJSDIesR/5IMkhKCYpe2VeeWlBRzXMoghiX4mhuGqb1 ZYRypX4vvCRm6BH3s4LqDxpRmA6HtJj9y9I7aYnXipS4sIIogeHxyoSO+qejjR/374Ta oWTLaDFfelbR/J3E4nciQdP7qAlMeUqWmcp6HT6IOI+fbBCK3A6YcZ9FNWLvc5zaETkf FhnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=dRgVugBt8bNUC/te4CdWC9bLt6VRuSfluTmE3udnjA8=; b=hnFkYtx6DrUqDT3OvroigJoCKs7ylQHbFgFYgUFx9v/qzb7TM7GWWtfEZd+q/Y0uRh 3ESc1qBHPthprvHYZ2YfLuT9Nq1bPJ7ScoIRNgmgJgJmq/O/8cqekV+9hWnMcTyjdDLI RZM5hAxje+cR1IP5dvS97AI/C2jhz+lxrzCrFbfo4AlplM7atpbooXTSXHNtuZMO6Jxa dxTW5tc9RqFsXNV2bhkPVnjH49O4KFWI6sjz+BzSoeqrqn96j1jCj5X5/Q8guij7kaAR Ien8f7Ld7TSn08V6HNDL5Q9OCAZ+pWvyyBygvaCl8UIs+Z5Hpa/DiCspHKhlwEYUy67S ybOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=n7KqngyO; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a90-v6si2277112plc.160.2018.04.18.17.40.24; Wed, 18 Apr 2018 17:40:37 -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; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=n7KqngyO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753180AbeDSAjR (ORCPT + 99 others); Wed, 18 Apr 2018 20:39:17 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:40211 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752511AbeDSAjO (ORCPT ); Wed, 18 Apr 2018 20:39:14 -0400 Received: by mail-lf0-f67.google.com with SMTP id i18-v6so5237842lfc.7 for ; Wed, 18 Apr 2018 17:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=dRgVugBt8bNUC/te4CdWC9bLt6VRuSfluTmE3udnjA8=; b=n7KqngyOnDRQ7qw7pmlgS5SKuKPyDpbViTS9LJuN/KYjp/OBQ7SW8isTqLeutnZ/Rp NxsyRoHSNEcMxw4TEwipVCcfSzfl5nl9BF+/vLNhYKdUoeuWeDWwJ5ayKlAek3ZpJG88 /Lxi2yl8EllITAaV1qDex75Tpgvqji+ulFsLYtekzyv8nL4kLYBYzHuygUK3mPvF1fGf mLF5nL4mLyzpEYP8khoxBnauOuLFtfudxnpHGkvVjy0IFgYZZBOhfmPjHEIOPMdJ4efU yz+oKVUA6652uUsRwv0i4KcR/8Pe78AuPU+s6IQUjk3LnKFNtcufKx8T12XgHt7cv51N M1iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=dRgVugBt8bNUC/te4CdWC9bLt6VRuSfluTmE3udnjA8=; b=f3rtF/+W/iNiG/smOtjy7LPCij1/Qnjn6nruKMlDMXpB2ApM2l275kStiVcZTYl75m 3mLIIMFdvsoNQvTj0m1kBG+ctzyTmhFCizzhL47Wa6VF7GAwdAFfy91QlXShLq3FJbAo 05i15HNd4muFcpmRmiFo3LoNqny+gU//soLOhpGs0hqdAPjIZ1eiB/zNFjydndc68B15 Q/TdJULBgRv83EGPse69xRvP0K6XtcEvjLWne7U2G1jMw3nIo1++5ZRzOIsnzvRsZzHU alPXeAyf232i5oavQn6eiBWKEw6+CQX+eZjImXV8RPd86cc9QuL8ND7MOi9157+RBy0u NSQA== X-Gm-Message-State: ALQs6tBwX0jZ5rUuH+A/4GDGAoeFsM5lWEhh9NlBnvap/2kNWleR4d5j LruDupZEHtpardA0iJkuKKZysfgtuSg4ATFVTMKs X-Received: by 10.46.153.206 with SMTP id l14mr2619036ljj.87.1524098352849; Wed, 18 Apr 2018 17:39:12 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:a5c3:0:0:0:0:0 with HTTP; Wed, 18 Apr 2018 17:39:12 -0700 (PDT) X-Originating-IP: [108.20.156.165] In-Reply-To: References: From: Paul Moore Date: Wed, 18 Apr 2018 20:39:12 -0400 Message-ID: Subject: Re: [RFC PATCH ghak32 V2 06/13] audit: add support for non-syscall auxiliary records To: Richard Guy Briggs Cc: 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, ebiederm@xmission.com, luto@kernel.org, jlayton@redhat.com, carlos@redhat.com, dhowells@redhat.com, viro@zeniv.linux.org.uk, simo@redhat.com, Eric Paris , serge@hallyn.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 16, 2018 at 5:00 AM, Richard Guy Briggs wrote: > Standalone audit records have the timestamp and serial number generated > on the fly and as such are unique, making them standalone. This new > function audit_alloc_local() generates a local audit context that will > be used only for a standalone record and its auxiliary record(s). 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 2932ef1..7103d23 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 (!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); I'm reserving the option to comment on this idea further as I make my way through the patchset, but audit_free_context() definitely shouldn't be declared as an inline function. -- paul moore www.paul-moore.com