Received: by 10.192.165.156 with SMTP id m28csp149503imm; Wed, 18 Apr 2018 19:11:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx49BRaF2chmrH149QrlFpNzyvSTasI8jh8Ch/cJC8q6ycDmCs0QtpAfsyxjuqVRFS/tHT6/W X-Received: by 10.99.113.80 with SMTP id b16mr3578254pgn.326.1524103902556; Wed, 18 Apr 2018 19:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524103902; cv=none; d=google.com; s=arc-20160816; b=WeB8/2uWmu7GXIZeSbWD7GE80Kgm94hWth0pH8O0Lz+UheyKaZGsA/o8hKP3TrYWfh GFFjZFPk7sHAlvbQhZ5SN4XlVZs0A38JOb2iiOiD47iZST6Hm8ijwfjzsupZabmtzYR7 DLrsuY1CGgPo6BH56axLngi5Hu4Hj7OK3Mu7/2SwDi56DXrU8LNp2Yfeb9K04DhQOxLk 2l9xikREozqvGpEiEi/9Z8rzR/c210CBU+/ZUKXTFx16Maq9pltcfxaU8Z09D7M870eS FzV0FNrdof7QG/qliSPxLFGvu5Vct6hOntY4YXEdhlta/ECDHpl7B86tWiI3eDP1ZroY e2sg== 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=Gj8/thAg0wox2etqQGXomOatW3ZQsvbCa2rMkoTjKwI=; b=Snh03t3gjz5lD//58SculaidWITgzGLRlL3wW1qPp0zpnCwJlij6vYZ0DHXhnSzBB2 K/MZL77qD7Pq6aj7snIHti8uegjPL0iyP0Uf9XVoxK8DeoBqbOQZOY4xeaEDr6lJi0MY zsfTCw1IxvDeAcJPhS9594ZuyObZvuujin3Pz5nul/78CVvJgTGMDIY3s79EQG+DMjpI yHo4EViiFB+E9AN1GlzHe0G+fDYfmNSLt/bLMLTB4FhX5FU/McGKN8qlxvu8nmCboJMG qyZO+eOARKIJyz7ROyGyRIhcY05fID1yAgMS7cijNi3I/HqdRC9HyUQg9qIzVV38qP3A 1V4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=AS8WT8fw; 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 ay8-v6si2567859plb.244.2018.04.18.19.11.28; Wed, 18 Apr 2018 19:11:42 -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=AS8WT8fw; 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 S1753320AbeDSCKQ (ORCPT + 99 others); Wed, 18 Apr 2018 22:10:16 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:33375 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753186AbeDSCKN (ORCPT ); Wed, 18 Apr 2018 22:10:13 -0400 Received: by mail-lf0-f67.google.com with SMTP id d79-v6so5455657lfd.0 for ; Wed, 18 Apr 2018 19:10:12 -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=Gj8/thAg0wox2etqQGXomOatW3ZQsvbCa2rMkoTjKwI=; b=AS8WT8fw5ltkiYKMufH65CyECTKxbYfvKubWiLJyEKFNsZm29uwZoNBlDKY0HRVJC6 RNV8F97nXKS6S9+jMmqkHIIaDSrdk+8CHucqxGWUwLme/hv+OdzlktubhNmrQFJYSXmq ywcYHxwm1y8OwCgvJPbrMA24UNNSdWSdUAYectHI2xoMndRhvv3gqrur2ObxhQMeolsg 4jAzb6IYH072/JO1lDxNWa682ZUG9k0j0/W3GhULzXoIg6ktmZfhPk0XdvdY0axLbuqT DFqRONO0YF0eg2yxuX/k3AX+tGkVdDrW6+QrVkfwJ0WzROPzx+FuCAwoAN4j/OvnXit/ 2mPg== 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=Gj8/thAg0wox2etqQGXomOatW3ZQsvbCa2rMkoTjKwI=; b=oyYSpDKlyzBcmL8P8EdCR9mG6DujhtrB5NO/sltmwn3lhApf7N8lmwxzrj/pumsiGy q8TZvLfXn01Exv0kZhu95ALmE2RwCbv+fqR/y5fGfihTHVopWaENB44JxDKzAuaCForo KbSNAjr8IOdP3bOC8MVdwTeY/3ZY4W/OBVGl62lzraEYtyOoL/cAFqeSqjzofmfu6p5N M/H3RLcSuMSpAUNIIv2kmFwDILSArM/fVJazMqV/tO+CWX96fo/q7yXl2GaSTi9mi1GH P02AbVUYN/kAXrKwZRguYcBBtd3Ozmaob4rlRF5cD1gMdxs9APQnrr3vHSEvKYalzYFv NPCQ== X-Gm-Message-State: ALQs6tBvp4Pn3EuPwYucOUCfYGpglf6OYNOC1wlWaHeQ7dfP7oVSvuVs C76saVdLQFmiAwISFM/0SMrB1uwwe8Ph96DdEaYj X-Received: by 10.46.131.197 with SMTP id s5mr2799223ljh.72.1524103811717; Wed, 18 Apr 2018 19:10:11 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:a5c3:0:0:0:0:0 with HTTP; Wed, 18 Apr 2018 19:10:10 -0700 (PDT) X-Originating-IP: [108.20.156.165] In-Reply-To: <66adde01c1dda792aff99a457eea576a0b08ca98.1521179281.git.rgb@redhat.com> References: <66adde01c1dda792aff99a457eea576a0b08ca98.1521179281.git.rgb@redhat.com> From: Paul Moore Date: Wed, 18 Apr 2018 22:10:10 -0400 Message-ID: Subject: Re: [RFC PATCH ghak32 V2 12/13] audit: NETFILTER_PKT: record each container ID associated with a netNS 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 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. > - 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. > errout: > + audit_free_context(context); > return XT_CONTINUE; > } -- paul moore www.paul-moore.com