Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3836513ybt; Sun, 5 Jul 2020 08:13:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxY+Ppia4cajd9NwatbbMt8UPuzFr3lJ+oIAxcXWpPnua10PElHxFTeckK+zm9Nli60H6Hg X-Received: by 2002:a17:906:e299:: with SMTP id gg25mr39121901ejb.160.1593962033464; Sun, 05 Jul 2020 08:13:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593962033; cv=none; d=google.com; s=arc-20160816; b=YM7rxtdP08EwcS8tCxj48SeruJ57YsymPp2qY0JCnQHM8w8ebfiMtJtl3aZo9vd2Y0 EMHrw0gn2p26E8FCyBMluJCiaFiY1Z42tZ66ZdiGjMW9jpGhHSNXv/6ksLap6PmW6PUp z+nHikzmD4hVADan+HZ8rXJ5kT8h1MKeHtstzZ4EtyMY9/m6y0vpAMIXiLXDD9FFJtv/ g5OpjtNenYuz2sawblKxXJvN/cGWLRKTBktDoqB3DZLu4GDfwWPBW182NwXwdPSNTsG6 4T0nCASn+X7HBoDELpvDVVK6nDCgIxWRpaCG4+2b5+N3TLWHO5jkWyehjbRfEsMN/zFU XyjA== 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 :in-reply-to:references:mime-version:dkim-signature; bh=NjVTfMdZw6XwQbxDon7o4vpETM5NGTk+/7UWsjNsjd4=; b=UXgYS7ID8gW1zmsflibV6TBhGyT1MQNEXF7U8RhNML4UPPyEWBSYh1IpNZb4oT2C/n UVRS/L+M9AW5WO1AE8IrlOa/RfjJm/jt2+o1oiJRuEbBnpS4vd3KxtioQC1jtEH5ZE2T zxNun0Gj+pWkQcr08j6mOzx0QsLj15AS1yPMx3RFk1a75NYaJnbsW+pmGViynM2hwyCW lvvNNBYXqtLBR6hMlgMhXG2Ee4ZvcdHAvRl/6JYgxGQdzb6GlPlDO6GosLT39HiCtKff itAi0K7WbNR3A1u+STQy38L3KevMh7Do10qbvab8UQuaPoUyuwmdaF9XNf8X/Fyzt4Ig bnqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b="yX/nMhf/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a24si10923101ejk.208.2020.07.05.08.13.30; Sun, 05 Jul 2020 08:13:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b="yX/nMhf/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727953AbgGEPLQ (ORCPT + 99 others); Sun, 5 Jul 2020 11:11:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727908AbgGEPLO (ORCPT ); Sun, 5 Jul 2020 11:11:14 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB2B7C08C5DE for ; Sun, 5 Jul 2020 08:11:13 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id a1so39750868ejg.12 for ; Sun, 05 Jul 2020 08:11: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:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NjVTfMdZw6XwQbxDon7o4vpETM5NGTk+/7UWsjNsjd4=; b=yX/nMhf/TTT1hAEQCTePWhtOhrfGd8UFNU1+fpmAoISYSg+PJyyp6lGq8jXleK83FY 6dF9ZGgs+WyvBE0QaAyku9Fe8unIvrcbAerS+AExmzg/2tpVNlWkncMbzynrDzyw/SQ/ zp26+E8sCfXqdVOT8kB9foQtj+jQKLgAdUsbRHVI+AOPRLpy88eACwzBVU8jB5X5tYfc 0eMKTNWLc5SqU5rsSkI8MICAAHR4tM0TjLooUvmt8/O9V0EW7klVSrlOEpTbaWL1uJ0U mA/VwWZPZleKlF2X/5FJfLDnnsPmbUOcIqDw1hFFD9wGUicuGQfK4Br7dQA1V+dKi7zB vb9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NjVTfMdZw6XwQbxDon7o4vpETM5NGTk+/7UWsjNsjd4=; b=aCOIJ608jnPAFVZSTFcLBjWremUQZ1VZ6Ax0urjsCcJwC0wI9HOx70N4ZPHXkG0UMy JHBksPobmo0BcMf03AUOZBu1MU75o27a8JpbByBEL/vZz4ka+t28OAQ8MyqVP4Y4IlAU 4jPhbxkvcISr0F36q/bzFf2mptumW7Xw+wMCAEqPYrXMO4q0HQuPam78Z3C2pIerQaO5 AAADyJBHtDEH0R+ic+zzuQ1tWHTQnyV7RgAxXLJvZ9SOsOxva2cZ62lKkLRAVC5LmBeg YXyfQzHNjh4jsOFhexrru+Ne7Jt6KpZviZn2h90fIvhfZvtxE8RDfk8NKxBVPFopRnXI bQIA== X-Gm-Message-State: AOAM5317lW66gFBXQrIlJDbhcWv7sEzLZzLHNSM2I10aEElmZNPh4A/b eyzvEc7OoQrfEmy1jkxMBPXdbGL02PB+dmTxE5R3 X-Received: by 2002:a17:906:1403:: with SMTP id p3mr31517140ejc.106.1593961872347; Sun, 05 Jul 2020 08:11:12 -0700 (PDT) MIME-Version: 1.0 References: <21e6c4e1ac179c8dcf35803e603899ccfc69300a.1593198710.git.rgb@redhat.com> In-Reply-To: <21e6c4e1ac179c8dcf35803e603899ccfc69300a.1593198710.git.rgb@redhat.com> From: Paul Moore Date: Sun, 5 Jul 2020 11:11:00 -0400 Message-ID: Subject: Re: [PATCH ghak90 V9 07/13] audit: add support for non-syscall auxiliary records To: Richard Guy Briggs Cc: containers@lists.linux-foundation.org, linux-api@vger.kernel.org, Linux-Audit Mailing List , linux-fsdevel@vger.kernel.org, LKML , netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, sgrubb@redhat.com, Ondrej Mosnacek , dhowells@redhat.com, simo@redhat.com, Eric Paris , Serge Hallyn , ebiederm@xmission.com, nhorman@tuxdriver.com, Dan Walsh , mpatel@redhat.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 Sat, Jun 27, 2020 at 9:22 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. We've had some good discussions on the list about why we can't reuse the "in_syscall" field and need to add a "local" field, I think it would be good to address that here in the commit description. > Signed-off-by: Richard Guy Briggs > Acked-by: Serge Hallyn > Acked-by: Neil Horman > Reviewed-by: Ondrej Mosnacek > --- > include/linux/audit.h | 8 ++++++++ > kernel/audit.h | 1 + > kernel/auditsc.c | 33 ++++++++++++++++++++++++++++----- > 3 files changed, 37 insertions(+), 5 deletions(-) ... > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > index 9e79645e5c0e..935eb3d2cde9 100644 > --- a/kernel/auditsc.c > +++ b/kernel/auditsc.c > @@ -908,11 +908,13 @@ static inline void audit_free_aux(struct audit_context *context) > } > } > > -static inline struct audit_context *audit_alloc_context(enum audit_state state) > +static inline struct audit_context *audit_alloc_context(enum audit_state state, > + gfp_t gfpflags) > { > struct audit_context *context; > > - context = kzalloc(sizeof(*context), GFP_KERNEL); > + /* We can be called in atomic context via audit_tg() */ At this point I think it's clear we need a respin so I'm not going to preface all of my nitpick comments as such, although this definitely would qualify ... I don't believe audit_tg() doesn't exist yet, likely coming later in this patchset, so please remove this comment as it doesn't make sense in this context. To be frank, don't re-add the comment later in the patchset either. Comments like these tend to be fragile and don't really add any great insight. The audit_tg() function can, and most likely will, be modified at some point in the future such that the comment above no longer applies, and there is a reasonable chance that when it does the above comment will not be updated. Further, anyone modifying the audit_alloc_context() is going to look at the callers (rather they *should* look at the callers) and will notice the no-sleep requirements. > @@ -960,8 +963,27 @@ int audit_alloc_syscall(struct task_struct *tsk) > return 0; > } > > -static inline void audit_free_context(struct audit_context *context) > +struct audit_context *audit_alloc_local(gfp_t gfpflags) > { > + struct audit_context *context = NULL; > + > + context = audit_alloc_context(AUDIT_RECORD_CONTEXT, gfpflags); > + if (!context) { > + audit_log_lost("out of memory in audit_alloc_local"); > + goto out; You might as well just return NULL here, no need to jump and then return NULL. > + } > + context->serial = audit_serial(); > + ktime_get_coarse_real_ts64(&context->ctime); > + context->local = true; > +out: > + return context; > +} > +EXPORT_SYMBOL(audit_alloc_local); -- paul moore www.paul-moore.com