Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6330479ybv; Tue, 18 Feb 2020 14:48:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzQ9zIa5+4pDBdfbo26wd+9uKsX+ZQShjbb5PJrseB+Ve+biX3mj3GjkIqPQ06jiOaZTZkw X-Received: by 2002:a9d:5786:: with SMTP id q6mr16825548oth.164.1582066093867; Tue, 18 Feb 2020 14:48:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582066093; cv=none; d=google.com; s=arc-20160816; b=zZ7/IszhoxfznlVygBPNYmW4KLRMidPRVL21u8HsTeQt1iajMMoxSP/u45h4GFmeXE WZ34vbcN9S6vZ9MB8Yl71KN957bS6yKIhJ3exD/omP1KmPboYXF3ZSC01mHLt5pr8i2O HZBBIA1CQpGwceMH3FTMxdnh9LvzI6dvWHj4o+8GOnTEC1Lxlfr2phMHQ6MjLmo2QH2u 3vmY5gsI0JdG2L5mE8lyNnI2ItZEUt5PiHppsiumaP6u8SIP9CMueHvaH5nPrsfkUTSo X/Ev8S22gR8Po8Ai0RnnkGMHD7r94/WaRHZtPMm7rBJbO1eHUbRntn4hc6mDYjLs0Z3/ ypgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=UdLjC4QY0dRRlMObceUJJ6AgKC0QDK6iC3rlvBmMiGI=; b=mM9U/2XG82k/4xul9C2fj6AwSV3Jn3ZnteoDqKL1rE+wcw5vHkzImi4zjdSZAvF7qL wskmARr9wTnC0QdFppc2fouIUB8nTHQYEPXPYs1ucfSHP4xt9BbOCgtMiBmi1LJpLJ0q Di1Z/9BpETsvlb8sk8edrC2VGorVqIh66jYcjw/Wpr+yRpWP5T/PC/XxuWs4aQ3mpy9W 3WTmIb251xSvA+gFzR2NBfQCD854+38SEPkQ9LCGGA4zsY/0sa3NRuLFLkdFt9exCW7b MftPkejmagr99EFqJhuURqEBDj3cBMn6hOswEhAjjUhIxblvN53rNxGDlFF47qYyhnbK TyHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dMdinklJ; 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=pass (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 l14si8536958oic.222.2020.02.18.14.48.01; Tue, 18 Feb 2020 14:48:13 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dMdinklJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726801AbgBRWrj (ORCPT + 99 others); Tue, 18 Feb 2020 17:47:39 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:32717 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726556AbgBRWrj (ORCPT ); Tue, 18 Feb 2020 17:47:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582066057; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UdLjC4QY0dRRlMObceUJJ6AgKC0QDK6iC3rlvBmMiGI=; b=dMdinklJ0xIgLLgrsBYMENItsDaa4lQ+vApWxP534sVlt9b/o9MqhHBwVrFhpnlfohT1hy 9X466LyzEcJqS8n0XXX1WLaHN102KCgq0YHkeN6GdpWPSPmTdZq82a5gvr2VdvAmJ+Ikab +vo8JWjmjlD0AJh612nCRavVUD9QbZU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-199-bqp_KELENdqb7_5NzKddPw-1; Tue, 18 Feb 2020 17:47:32 -0500 X-MC-Unique: bqp_KELENdqb7_5NzKddPw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B51C61005512; Tue, 18 Feb 2020 22:47:30 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-16.rdu2.redhat.com [10.10.112.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD69460BE1; Tue, 18 Feb 2020 22:47:22 +0000 (UTC) Date: Tue, 18 Feb 2020 17:47:20 -0500 From: Richard Guy Briggs To: Paul Moore Cc: Linux-Audit Mailing List , LKML , netfilter-devel@vger.kernel.org, sgrubb@redhat.com, omosnace@redhat.com, fw@strlen.de, twoerner@redhat.com, Eric Paris , ebiederm@xmission.com, tgraf@infradead.org Subject: Re: [PATCH ghak25 v2 4/9] audit: record nfcfg params Message-ID: <20200218224720.dwe4ibxxca3mesha@madcap2.tricolour.ca> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-01-30 22:18, Paul Moore wrote: > On Mon, Jan 6, 2020 at 1:55 PM Richard Guy Briggs wrote: > > Record the auditable parameters of any non-empty netfilter table > > configuration change. > > > > See: https://github.com/linux-audit/audit-kernel/issues/25 > > Signed-off-by: Richard Guy Briggs > > --- > > include/linux/audit.h | 11 +++++++++++ > > kernel/auditsc.c | 16 ++++++++++++++++ > > 2 files changed, 27 insertions(+) > > I can not see a good reason why this patch is separate from patches 5 > and 6, please squash them down into one patch. As it currently stands > the logging function introduced here has no caller so it is pointless > by itself. Strive to make an individual patch have some significance > on its own whenever possible. > > This will also help you write a better commit description, right now > the commit description tells me nothing, but if you bring in the other > patches you can talk about consolidating similar code into a common > function. Fair enough. I could see squashing some of these, but there are a number of issues being addressed and would like to see some granularity, but as you point out, each patch should stand on its own... > > diff --git a/include/linux/audit.h b/include/linux/audit.h > > index f9ceae57ca8d..96cabb095eed 100644 > > --- a/include/linux/audit.h > > +++ b/include/linux/audit.h > > @@ -379,6 +379,7 @@ extern int __audit_log_bprm_fcaps(struct linux_binprm *bprm, > > extern void __audit_fanotify(unsigned int response); > > extern void __audit_tk_injoffset(struct timespec64 offset); > > extern void __audit_ntp_log(const struct audit_ntp_data *ad); > > +extern void __audit_nf_cfg(const char *name, u8 af, int nentries); > > > > static inline void audit_ipc_obj(struct kern_ipc_perm *ipcp) > > { > > @@ -514,6 +515,12 @@ static inline void audit_ntp_log(const struct audit_ntp_data *ad) > > __audit_ntp_log(ad); > > } > > > > +static inline void audit_nf_cfg(const char *name, u8 af, int nentries) > > +{ > > + if (!audit_dummy_context()) > > + __audit_nf_cfg(name, af, nentries); > > See my comments below about audit_enabled. I've cleaned up audit_enabled and removed dummy due to ghak120. > > +} > > + > > extern int audit_n_rules; > > extern int audit_signals; > > #else /* CONFIG_AUDITSYSCALL */ > > @@ -646,6 +653,10 @@ static inline void audit_ntp_log(const struct audit_ntp_data *ad) > > > > static inline void audit_ptrace(struct task_struct *t) > > { } > > + > > +static inline void audit_nf_cfg(const char *name, u8 af, int nentries) > > +{ } > > + > > #define audit_n_rules 0 > > #define audit_signals 0 > > #endif /* CONFIG_AUDITSYSCALL */ > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > > index 4effe01ebbe2..4e1df4233cd3 100644 > > --- a/kernel/auditsc.c > > +++ b/kernel/auditsc.c > > @@ -2545,6 +2545,22 @@ void __audit_ntp_log(const struct audit_ntp_data *ad) > > audit_log_ntp_val(ad, "adjust", AUDIT_NTP_ADJUST); > > } > > > > +void __audit_nf_cfg(const char *name, u8 af, int nentries) > > Should nentries be an unsigned int? Yes, it should, thank you. > > +{ > > + struct audit_buffer *ab; > > + struct audit_context *context = audit_context(); > > This is a good example of why the context of a caller matters; taken > alone I would say that we need a check for audit_enabled here, but if > we look at the latter patches we can see that the caller already has > the audit_enabled check. > > Considering that the caller is already doing an audit_enabled check, > we might want to consider moving the audit_enabled check into > audit_nf_cfg() where we do the dummy context check. It's a static > inline so there shouldn't be a performance impact and it makes the > caller's code cleaner. > > > + if (!nentries) > > + return; > > + ab = audit_log_start(context, GFP_KERNEL, AUDIT_NETFILTER_CFG); > > Why do we need the context variable, why not just call audit_context() > here directly? Context has been cleaned up. > > + if (!ab) > > + return; /* audit_panic or being filtered */ > > We generally don't add comments when audit_log_start() fails > elsewhere, please don't do it here. Ok. > > + audit_log_format(ab, "table=%s family=%u entries=%u", > > + name, af, nentries); > > + audit_log_end(ab); > > +} > > +EXPORT_SYMBOL_GPL(__audit_nf_cfg); > > + > > static void audit_log_task(struct audit_buffer *ab) > > { > > kuid_t auid, uid; > > -- > > 1.8.3.1 > > -- > paul moore > www.paul-moore.com > - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635