Received: by 10.192.165.148 with SMTP id m20csp454468imm; Fri, 20 Apr 2018 09:23:04 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Tveio4SsiWaZ/gs7wGaCITOSS65HLatSoS+m3GHciSCMxlU6thZ85i0sVBR+DqqnHS7oj X-Received: by 10.98.233.11 with SMTP id j11mr10291521pfh.205.1524241384482; Fri, 20 Apr 2018 09:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524241384; cv=none; d=google.com; s=arc-20160816; b=BD7KSUHMVzTIdZBh9QNMQlSsJPK2QPTfqXgKMYYGil+tiK7xtQvT3lqpEdWXfJ5YVA ztCZK4ZOp065BvR/NV33UY1Koh4K3cVrBSL7ADyy0qB9Cl7hvJlZNOOpwwrjxraebhus ZrmYq93XPh1G05XkdFpfAyw/ioYB64rXQf1EOMTqBhCjO9+BI+3cOdtccQ8wvmhTgwGJ eiuGPr8IPvTcRtYbNuqXXv52GXwEuatSsNLSuxmOZbmC+16eNnpbElhx2HnKKa2+R+uv NKzgs1MeXBIhazIhC2e0RXTfdX+m/EtD/9DPH3Idg+sbYoCmFFicHpJH7a0pUrZPXhu6 XcBw== 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=VEtmDJ4VprYGDhPNREGKeHgonuGj60dhpYZcSX9+Zw0=; b=UGDEe5RkMj1OCnEDPvlz9V56WQxxPxZtAzLehW/nQ3wnDg6aoRpTMlcahsUjFMsELa QVRTtwKyGgdYVTaBYUERlwOKjdhr6qXWfCFdFz8IX4nlX4q4r79FGtno8oVQzCJISW4D ODem6zH+qY+FvPFnGyVALAs/IaXEUjg/k/QoD4C7Af8nAuvGp9RZgMmSLOk/YzkdKX1m iyEfDjESH5H8GJbBVvo5u9txF6MJePI8o3aBvX/qZ021nH7GdIrLzVJmhrL3pmLj2kVb 3nR/M9O7Nb/689C4kM9EGFAyzJxh7VJmEXVNPU5mHllTpiYcHrFux06Pb/G8ho6QZIZ9 TADA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=HHUxz6Ot; 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 s66si3979639pfj.164.2018.04.20.09.22.49; Fri, 20 Apr 2018 09:23:04 -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=HHUxz6Ot; 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 S1752350AbeDTQVj (ORCPT + 99 others); Fri, 20 Apr 2018 12:21:39 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:38022 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbeDTQVf (ORCPT ); Fri, 20 Apr 2018 12:21:35 -0400 Received: by mail-lf0-f65.google.com with SMTP id z130-v6so5968230lff.5 for ; Fri, 20 Apr 2018 09:21:35 -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=VEtmDJ4VprYGDhPNREGKeHgonuGj60dhpYZcSX9+Zw0=; b=HHUxz6Otd05ddJsYCfaDZWn4sVftwosXRw3gn03OAphj8NS/Z3NkbL7KoKhtltvQl9 UR5jiNp8RO322TtVbezOaXJe7v6Af/OeMsOa3izA8w/46B+OYh5vI7U2O/VCaqP/hido /FGGvtmsqVoWJFXIMLvFvXxmV0kyGNsx9m4BGHQtzjJvRCLxDXVljV08nDn15Ffl33g2 nsrEBkpPq2Y4LCCXvyFzAI+09lP55JhRpQyF9DX2TXJxZiYkHUHCaV3mh3LwltxVdMFo i06UHNaZ8kZ74PqJp6U9f0MYN7p5EeA+TfzfdCO7T+x5uapWyk6QljYEZ3iaGLR0Y/2b 8LOg== 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=VEtmDJ4VprYGDhPNREGKeHgonuGj60dhpYZcSX9+Zw0=; b=h9YbkvQ5kmB2B16DG4WThFdRqE1cqPBY459PYLlDgCHAYHn2mnQGYClbKer1eais0o eopAqXBEdtJGeTZG/ZKw5IOJPiSQNOc3mVrb6Fx2qKNr8kSCB4AaXN/2FseOD8cDgB+X o0G+0y36EeMpC8W7U+lI4xDDuP+FcoqzW2fGPUuS4zStQtmnaqQNB0tco2nH5IsEWKjC Mc8ySnTBFkZm6MSsBgxhTr5kswPI7rPLfXLsSzB7jp4kU9iCmWPTStjpIsMnZ0/wHQBj 05m5JimuAAUHeM963Q70/pES+eCrc3T9nCNGgMTBdbld2jyTfzN0wR+MCoPT1Z48NVBa F8sQ== X-Gm-Message-State: ALQs6tCPXVa/B2yRfC+ZOB8I/r16J+C73Xf3phUL5vOiUePOB2q9Ax7n 34LxgYoEfpERdonF8cz4Igv11Rts02yicuS6zcBR X-Received: by 10.46.135.7 with SMTP id m7mr7872782lji.106.1524241294243; Fri, 20 Apr 2018 09:21:34 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:a5c3:0:0:0:0:0 with HTTP; Fri, 20 Apr 2018 09:21:33 -0700 (PDT) X-Originating-IP: [108.20.156.165] In-Reply-To: <20180420012346.udnga5pfdjoazcfc@madcap2.tricolour.ca> References: <20180420012346.udnga5pfdjoazcfc@madcap2.tricolour.ca> From: Paul Moore Date: Fri, 20 Apr 2018 12:21:33 -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 Thu, Apr 19, 2018 at 9:23 PM, Richard Guy Briggs wrote: > On 2018-04-18 20:39, Paul Moore wrote: >> 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. > > Ok, I think I follow. When it wasn't exported, inline was fine, but now > that it has been exported, it should no longer be inlined ... Pretty much. Based on a few comments I've seen by compiler folks over the years, my current thinking is that we shouldn't worry about explicit inlining static functions in C files (header files are a different story). The basic idea being that the compiler almost always does a better job than us stupid developers. > ... or should use > an intermediate function name to export so that local uses of it can > remain inline. Possibly, but my guess is that the compiler could (will?) do that by itself for code that lives in the same file. -- paul moore www.paul-moore.com