Received: by 10.192.165.156 with SMTP id m28csp677511imm; Thu, 19 Apr 2018 05:53:17 -0700 (PDT) X-Google-Smtp-Source: AIpwx487bYy3dogO+v3vQym0pQ0loAOBV9b8x8urfFvCJJiKqGf7RQb33g1LRnaycRwVHCkAmfVm X-Received: by 10.98.159.129 with SMTP id v1mr5776964pfk.25.1524142397000; Thu, 19 Apr 2018 05:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524142396; cv=none; d=google.com; s=arc-20160816; b=Y68OHdV41d25mDMv23QNfO9pLPqb93J7SoET7xQds5TRDTpo0UosYyWW8YgKl5DAio nFCTFUcuDIo+BZ5ptpMG0nmB5UbmlsHuUMVQG5DudUOqraDNy26fbFvhp6BqIwsb7DTJ GM35vuwQMooe75o2T0gvOA/h4L122x+ml/UeR+WPH3DzEPKWYszBl1yl7PzhRLfiZ8Ff ZvWggISX2MAh7YFDISlKsfj5ul4JqrqClPgnXhDm4dn8q5K7rKy+zc2Wfbq7WCO8EbLr JuKvpwy35ZSIpsx/eW88O/kcqUkMchVYgqLlThisIFQIg/fTDHEPHz93A1jqt8C6zNJx TBew== 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:arc-authentication-results; bh=ZKHCAI/XGc1EEv5CMfhSi41ioFXjZgbNSdlF14AqajY=; b=B1quLVkvVigwiXZEHuybdw5SnAD7vxQZrLy1APlVRiwOYEGi1lYqirb+xG7sOlbcIS ON9EpMIrSTcWBOAWMRqcWpirYHQG9PqmwUZjzpBIPMFZZWRi1W/1TNuewrIx6PGtcTKX A83WkR6004QB3HCuXF4YqdlIbjoqc/YZ3O8lc42U0jsOGbuV7CwaepgOO+3C5EJA+MtX uQmVdfOeTRdgrrB/5zHK9vb+PUrW4KTplNTiYouA+mz5Dqf8nTIzHcHsxR+0hElgGIKt e3rsc7QZRm+LhdNIf0OO3WFU6H5E/HpWiTBRZXWorMYI7gvjGxuj8K/iOIPqND+IpZ3h 2dlw== 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 n3-v6si3514665pld.85.2018.04.19.05.53.03; Thu, 19 Apr 2018 05:53: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 S1753587AbeDSMwB (ORCPT + 99 others); Thu, 19 Apr 2018 08:52:01 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41646 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752623AbeDSMv5 (ORCPT ); Thu, 19 Apr 2018 08:51:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A143D4023150; Thu, 19 Apr 2018 12:51:56 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 696B384422; Thu, 19 Apr 2018 12:51:45 +0000 (UTC) Date: Thu, 19 Apr 2018 08:45:51 -0400 From: Richard Guy Briggs To: Paul Moore 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 Subject: Re: [RFC PATCH ghak32 V2 12/13] audit: NETFILTER_PKT: record each container ID associated with a netNS Message-ID: <20180419124550.7uknp4oebvwoo67s@madcap2.tricolour.ca> References: <66adde01c1dda792aff99a457eea576a0b08ca98.1521179281.git.rgb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20171027 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 19 Apr 2018 12:51:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 19 Apr 2018 12:51:56 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rgb@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-04-18 22:10, Paul Moore wrote: > On Fri, Mar 16, 2018 at 5:00 AM, Richard Guy Briggs wrote: > > Add container ID auxiliary record(s) to NETFILTER_PKT event standalone > > records. Iterate through all potential container IDs associated with a > > network namespace. > > > > Signed-off-by: Richard Guy Briggs > > --- > > kernel/audit.c | 1 + > > kernel/auditsc.c | 2 ++ > > net/netfilter/xt_AUDIT.c | 15 ++++++++++++++- > > 3 files changed, 17 insertions(+), 1 deletion(-) > > > > diff --git a/kernel/audit.c b/kernel/audit.c > > index 08662b4..3c77e47 100644 > > --- a/kernel/audit.c > > +++ b/kernel/audit.c > > @@ -2102,6 +2102,7 @@ int audit_log_container_info(struct audit_context *context, > > audit_log_end(ab); > > return 0; > > } > > +EXPORT_SYMBOL(audit_log_container_info); > > > > void audit_log_key(struct audit_buffer *ab, char *key) > > { > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > > index 208da962..af68d01 100644 > > --- a/kernel/auditsc.c > > +++ b/kernel/auditsc.c > > @@ -975,6 +975,7 @@ struct audit_context *audit_alloc_local(void) > > context->in_syscall = 1; > > return context; > > } > > +EXPORT_SYMBOL(audit_alloc_local); > > > > inline void audit_free_context(struct audit_context *context) > > { > > @@ -989,6 +990,7 @@ inline void audit_free_context(struct audit_context *context) > > audit_proctitle_free(context); > > kfree(context); > > } > > +EXPORT_SYMBOL(audit_free_context); > > > > static int audit_log_pid_context(struct audit_context *context, pid_t pid, > > kuid_t auid, kuid_t uid, unsigned int sessionid, > > diff --git a/net/netfilter/xt_AUDIT.c b/net/netfilter/xt_AUDIT.c > > index c502419..edaa456 100644 > > --- a/net/netfilter/xt_AUDIT.c > > +++ b/net/netfilter/xt_AUDIT.c > > @@ -71,10 +71,14 @@ static bool audit_ip6(struct audit_buffer *ab, struct sk_buff *skb) > > { > > struct audit_buffer *ab; > > int fam = -1; > > + struct audit_context *context = audit_alloc_local(); > > + struct audit_containerid *cont; > > + int i = 0; > > + struct net *net; > > > > if (audit_enabled == 0) > > goto errout; > > Do I need to say it? I probably should ... the allocation should > happen after the audit_enabled check. Already fixed in V3 in my tree a couple of weeks ago... More timely review please? > > - ab = audit_log_start(NULL, GFP_ATOMIC, AUDIT_NETFILTER_PKT); > > + ab = audit_log_start(context, GFP_ATOMIC, AUDIT_NETFILTER_PKT); > > if (ab == NULL) > > goto errout; > > > > @@ -104,7 +108,16 @@ static bool audit_ip6(struct audit_buffer *ab, struct sk_buff *skb) > > > > audit_log_end(ab); > > > > + net = sock_net(NETLINK_CB(skb).sk); > > + list_for_each_entry(cont, &net->audit_containerid, list) { > > + char buf[14]; > > + > > + sprintf(buf, "net%u", i++); > > + audit_log_container_info(context, buf, cont->id); > > + } > > It seems like this could (should?) be hidden inside an audit function, > e.g. audit_log_net_containers() or something like that. Perhaps... It was open-coded since at this point there are no other users. That'll make this tidier though. > > errout: > > + audit_free_context(context); > > return XT_CONTINUE; > > } > > -- > 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