Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp515414yba; Mon, 1 Apr 2019 10:51:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwfwgnZyOK1fEWPNHmGdtUqM/U0u4jIwcWK89G/iVBjTLGaIeDPP3appXN0Njo6jENj+3+ X-Received: by 2002:a62:6587:: with SMTP id z129mr24842703pfb.88.1554141076615; Mon, 01 Apr 2019 10:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554141076; cv=none; d=google.com; s=arc-20160816; b=JBkTMVVSH1pOeHGdG/XqPBRCKLiT5rMW3MOwkq4EXc5phB2Ilqt3vNL1bB3acuVijC aTnI571eKwrYRGxIjUpCXUORC0VYoAtKAwGTEDZBrHXWQKhsRDPNNEaHHh0nQRMcgJkj O4mS+f0YXpuC1iLamRobkwLB0Vb9YIOBE/YW6P4Oel2Zm2epnbOxInLCnUQLGtqOvHn3 BffYtGK614RL41ZavjRFWLQC0zwHmPtR73mlInoqSqKwY634JpAjbUFNei0T4dbcB20T 3SiCsacqSyhpJ5Q++N0vKUEPNl5/aJnfeq14ZG5Mm3JzRwENVgiVcq8Zg7dn5Plpfmom aWEA== 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; bh=/5hYDQ9Zxm1AYdx5kTNe8ZpRU7ehiMjFNn+h8KeAqGs=; b=T208DnsqVmIscCIT0MsGJ2uf60CQiJd1ck7R4LyiUjpb6qhqMOKnGLxKFlGNdzY4Zn YVBxAol+B0tQ2rNVml7x6rZKnFn0vfk1ARnwoYSm+1rPqndJau+LJq1HqruIGnPjFZkf LGHHB3F/Rcx41eTMdmdKgkymQiiCbuiVF4yFC9eZQlJa4b+JokeiMP5yMQfIBX+QzWh9 mUdiD8iMkDDUy+miN08HcTaKDWwTLD8/uYOQxVDBa3BdDj713tX2/MIJXKaYM+WXSenQ AhJHj8Ya8T5M1T3mSetkQsMIkVW7nwm+KJdiLCbVeNX5bKqRmMxRvH7jafcHBjnGUxBo 9eAg== 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 c24si1589980plo.220.2019.04.01.10.51.01; Mon, 01 Apr 2019 10:51:16 -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; 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 S1732970AbfDARu3 (ORCPT + 99 others); Mon, 1 Apr 2019 13:50:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42988 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732698AbfDARu1 (ORCPT ); Mon, 1 Apr 2019 13:50:27 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04D613087931; Mon, 1 Apr 2019 17:50:27 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-19.phx2.redhat.com [10.3.112.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71C2E5C206; Mon, 1 Apr 2019 17:50:16 +0000 (UTC) Date: Mon, 1 Apr 2019 13:50:13 -0400 From: Richard Guy Briggs To: Paul Moore 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, omosnace@redhat.com, dhowells@redhat.com, simo@redhat.com, Eric Paris , Serge Hallyn , ebiederm@xmission.com, nhorman@tuxdriver.com Subject: Re: [PATCH ghak90 V5 10/10] audit: NETFILTER_PKT: record each container ID associated with a netNS Message-ID: <20190401175013.it2xwndd62svycwl@madcap2.tricolour.ca> References: <56127b2a5b82f15cb0d0f040502c2e3bb6945f30.1552665316.git.rgb@redhat.com> 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 01 Apr 2019 17:50:27 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-04-01 10:50, Paul Moore wrote: > On Fri, Mar 15, 2019 at 2:35 PM Richard Guy Briggs wrote: > > Add audit container identifier auxiliary record(s) to NETFILTER_PKT > > event standalone records. Iterate through all potential audit container > > identifiers associated with a network namespace. > > > > Signed-off-by: Richard Guy Briggs > > --- > > include/linux/audit.h | 5 +++++ > > kernel/audit.c | 41 +++++++++++++++++++++++++++++++++++++++++ > > net/netfilter/nft_log.c | 11 +++++++++-- > > net/netfilter/xt_AUDIT.c | 11 +++++++++-- > > 4 files changed, 64 insertions(+), 4 deletions(-) > > ... > > > diff --git a/kernel/audit.c b/kernel/audit.c > > index 7fa3194f5342..80ed323feeb5 100644 > > --- a/kernel/audit.c > > +++ b/kernel/audit.c > > @@ -451,6 +451,47 @@ void audit_switch_task_namespaces(struct nsproxy *ns, struct task_struct *p) > > audit_netns_contid_add(new->net_ns, contid); > > } > > > > +/** > > + * audit_log_netns_contid_list - List contids for the given network namespace > > + * @net: the network namespace of interest > > + * @context: the audit context to use > > + * > > + * Description: > > + * Issues a CONTAINER_ID record with a CSV list of contids associated > > + * with a network namespace to accompany a NETFILTER_PKT record. > > + */ > > +void audit_log_netns_contid_list(struct net *net, struct audit_context *context) > > +{ > > + struct audit_buffer *ab = NULL; > > + struct audit_contid *cont; > > + bool first = true; > > + struct audit_net *aunet; > > + > > + /* Generate AUDIT_CONTAINER_ID record with container ID CSV list */ > > + rcu_read_lock(); > > + aunet = net_generic(net, audit_net_id); > > + if (!aunet) > > + goto out; > > + list_for_each_entry_rcu(cont, &aunet->contid_list, list) { > > + if (first) { > > This is borderline nit-picky, but it seems like we could get rid of > "first" and just check to see if "ab" is still NULL. Yes, this is a better way, thank you. > > + ab = audit_log_start(context, GFP_ATOMIC, > > + AUDIT_CONTAINER_ID); > > + if (!ab) { > > + audit_log_lost("out of memory in audit_log_netns_contid_list"); > > + goto out; > > + } > > + audit_log_format(ab, "contid="); > > + } else > > + audit_log_format(ab, ","); > > + audit_log_format(ab, "%llu", cont->id); > > + first = false; > > + } > > + audit_log_end(ab); > > +out: > > + rcu_read_unlock(); > > +} > > +EXPORT_SYMBOL(audit_log_netns_contid_list); > > paul moore - 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