Received: by 10.213.65.68 with SMTP id h4csp260302imn; Fri, 16 Mar 2018 02:08:58 -0700 (PDT) X-Google-Smtp-Source: AG47ELvHGsSzqceNGWzjGDHLct/yfq21jf+IQZ2qUrxMfMuH6ZhltxMlpilz+9ZUuld8Xe53hY5z X-Received: by 2002:a17:902:4481:: with SMTP id l1-v6mr1299791pld.43.1521191338870; Fri, 16 Mar 2018 02:08:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521191338; cv=none; d=google.com; s=arc-20160816; b=0CUgOZ7Fxt7tLJcB8995lDX1fIWZRR55RN/U0t3/DKHKZK3Gi5rAcNVU/xX+A2hJ7q 9DgYlhR3mNjJ6Kl2ySBH/3EMa1Kw6kw7hBOV8c8Pe8M9RnRPFGw5hRFVbIRbhPGKYM/+ LfrSOS1yopMF3gP1ZiI5/6lDM9o32K0WrW9DKzJubb/JgfrhP7OvAUFt5X7iZ0aidcj+ nFHelOz6VP0NsYn5ZhZ8+tPZpzXnCF8mYVw5NgDRle47NhYGeaUY4qqvJCGa9VLYgR2v t//hh7L+6CkviovP6YP8n2w3ZhSzuo6e3kQcxjYtJnH88OWeVLOfMlAOEfEiR6iGr1Ej 6NDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ddXz2+z8N/aN+DAe7sWp1bppgk+JsFOwPyHrjNk9fmA=; b=gnUqJRTKm7sEqHU1x5SgwkSf4vuq+6ZojOfq7Y7dMHsnY/cR0rj87uJk+n6j2EaVyZ mhZiQeCq6eyEfk9uJk7SqlM2ekLqw5MTbTtuRV8qFl1xQDYhrVbemTa6f/zztfKo+N0X Y94k/Yor4IrQsVo02q22Ce+36LanloSj2DT4CIPxfArhp4uvywZmmZOgBEmPK7xf4MZE SnYdvDr7O8DYuR56FBw5H5uHUyTw9IXSHbKtTa98ZdRPvX1z3y77p8Q0/fzBdVFDZ96/ nHPIA9GtK9NJWZreyJKt0PdXyvE3k/4SCatUsYk7I7jh5/c13TOHaX87Ijmx6lSK4jTZ VGLQ== 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 c12-v6si820820plm.478.2018.03.16.02.08.44; Fri, 16 Mar 2018 02:08:58 -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 S1753522AbeCPJH3 (ORCPT + 99 others); Fri, 16 Mar 2018 05:07:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49714 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753147AbeCPJH0 (ORCPT ); Fri, 16 Mar 2018 05:07:26 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5630120CC6; Fri, 16 Mar 2018 09:07:25 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0841510B009F; Fri, 16 Mar 2018 09:07:13 +0000 (UTC) From: Richard Guy Briggs To: 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 Cc: luto@kernel.org, jlayton@redhat.com, carlos@redhat.com, viro@zeniv.linux.org.uk, dhowells@redhat.com, simo@redhat.com, eparis@parisplace.org, serge@hallyn.com, ebiederm@xmission.com, madzcar@gmail.com, Richard Guy Briggs Subject: [RFC PATCH ghak32 V2 12/13] audit: NETFILTER_PKT: record each container ID associated with a netNS Date: Fri, 16 Mar 2018 05:00:39 -0400 Message-Id: <66adde01c1dda792aff99a457eea576a0b08ca98.1521179281.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Mar 2018 09:07:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 16 Mar 2018 09:07:25 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 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; - 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); + } + errout: + audit_free_context(context); return XT_CONTINUE; } -- 1.8.3.1