Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp823984ybi; Thu, 30 May 2019 07:19:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxzipRQEJh/EFW9q+61rqU5dNnN8k2SmK3+6KM4hSTIynySbzVCOQTyUDpV9NlTf75VXh+V X-Received: by 2002:a63:490a:: with SMTP id w10mr3910782pga.6.1559225970126; Thu, 30 May 2019 07:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559225970; cv=none; d=google.com; s=arc-20160816; b=rIp+jYXE5ie20i3Y7tu5kf3MgD2jNsNxZmiHaJV2dB292ujEfr5XkCmbGPIRIBMMnk ajPci7mSBHndn5rJjreNh2gKUkqVEe4I3/95l/doFkC6JTtO83aTeZuPrtppA+T928Rk m/zB/tsKkjilgd5w9kLrq+yBfWPrNggGi37LrShgB05V3FtZP1kvq9ZE1LPC8mvtVdSa 6HaYf9HsLoOxMUEAM8kLLXPbm++BycSClQzofXTUbr+kVmJNTsHPf/886aa82PFff/Ek w1G37DknR5ybL5uPOpHCCzjLKgmpi67dZYH4d0CtAJYpfskr1LzQBJIUgXnIlbDk3YME 2THg== 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=MO4m5c8eI2rgEWCtIW1vureiRJue4LnSwFl8N5TrbFU=; b=gFyJ2D/3lIo7eqd7IiZU+CyJLiYKdoZAFscXJOpy0eQ4CQcVCNUE61qGS21upg+NOX DsCAHWhAdYur0K2rFRsuwHY5axkmZ6eQ5zTvvCPG+vFKEfhMdiQwMfW71+ZzY9GjtY5r FLz+gCClxrw2KPaOtbT64NYcMldKuSrJ9AwLbyHTypxGlMSsCTAKn9xv8f7qKjSetATA o3kPoXgHrEmEGlirQa+iPycT8JGRflXj6m+oeU2FaTjXtByDkJmuCedGqX4iS6Z/GMGf jXe9OdUn6azwV9Yn67uH8p2zeqX67aQBt7asAwC/Kih+sHB41dJ/c11kRzlv2ZbHxY77 f1Sw== 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 c13si3010169pfr.73.2019.05.30.07.19.13; Thu, 30 May 2019 07:19:30 -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 S1727427AbfE3OQV (ORCPT + 99 others); Thu, 30 May 2019 10:16:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58472 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727394AbfE3OQT (ORCPT ); Thu, 30 May 2019 10:16:19 -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 56DA73082A98; Thu, 30 May 2019 14:16:09 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-16.phx2.redhat.com [10.3.112.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DE937AB52; Thu, 30 May 2019 14:15:58 +0000 (UTC) Date: Thu, 30 May 2019 10:15:55 -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 V6 09/10] audit: add support for containerid to network namespaces Message-ID: <20190530141555.qqcbasvyp7eokwjz@madcap2.tricolour.ca> References: <423ed5e5c5e4ed7c3e26ac7d2bd7c267aaae777c.1554732921.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]); Thu, 30 May 2019 14:16:19 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-05-29 18:17, Paul Moore wrote: > On Mon, Apr 8, 2019 at 11:41 PM Richard Guy Briggs wrote: > > > > Audit events could happen in a network namespace outside of a task > > context due to packets received from the net that trigger an auditing > > rule prior to being associated with a running task. The network > > namespace could be in use by multiple containers by association to the > > tasks in that network namespace. We still want a way to attribute > > these events to any potential containers. Keep a list per network > > namespace to track these audit container identifiiers. > > > > Add/increment the audit container identifier on: > > - initial setting of the audit container identifier via /proc > > - clone/fork call that inherits an audit container identifier > > - unshare call that inherits an audit container identifier > > - setns call that inherits an audit container identifier > > Delete/decrement the audit container identifier on: > > - an inherited audit container identifier dropped when child set > > - process exit > > - unshare call that drops a net namespace > > - setns call that drops a net namespace > > > > Please see the github audit kernel issue for contid net support: > > https://github.com/linux-audit/audit-kernel/issues/92 > > Please see the github audit testsuiite issue for the test case: > > https://github.com/linux-audit/audit-testsuite/issues/64 > > Please see the github audit wiki for the feature overview: > > https://github.com/linux-audit/audit-kernel/wiki/RFE-Audit-Container-ID > > Signed-off-by: Richard Guy Briggs > > Acked-by: Neil Horman > > Reviewed-by: Ondrej Mosnacek > > --- > > include/linux/audit.h | 19 +++++++++++ > > kernel/audit.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++-- > > kernel/nsproxy.c | 4 +++ > > 3 files changed, 108 insertions(+), 3 deletions(-) > > ... > > > diff --git a/kernel/audit.c b/kernel/audit.c > > index 6c742da66b32..996213591617 100644 > > --- a/kernel/audit.c > > +++ b/kernel/audit.c > > @@ -376,6 +384,75 @@ static struct sock *audit_get_sk(const struct net *net) > > return aunet->sk; > > } > > > > +void audit_netns_contid_add(struct net *net, u64 contid) > > +{ > > + struct audit_net *aunet; > > + struct list_head *contid_list; > > + struct audit_contid *cont; > > + > > + if (!net) > > + return; > > + if (!audit_contid_valid(contid)) > > + return; > > + aunet = net_generic(net, audit_net_id); > > + if (!aunet) > > + return; > > + contid_list = &aunet->contid_list; > > + spin_lock(&aunet->contid_list_lock); > > + list_for_each_entry_rcu(cont, contid_list, list) > > + if (cont->id == contid) { > > + refcount_inc(&cont->refcount); > > + goto out; > > + } > > + cont = kmalloc(sizeof(struct audit_contid), GFP_ATOMIC); > > + if (cont) { > > + INIT_LIST_HEAD(&cont->list); > > I thought you were going to get rid of this INIT_LIST_HEAD() call? I was intending to, and then Neil weighed in with this opinion: https://www.redhat.com/archives/linux-audit/2019-April/msg00014.html If you feel that isn't important, please remove it. > > + cont->id = contid; > > + refcount_set(&cont->refcount, 1); > > + list_add_rcu(&cont->list, contid_list); > > + } > > +out: > > + spin_unlock(&aunet->contid_list_lock); > > +} > > -- > 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