Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp843151ybi; Thu, 30 May 2019 07:35:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwLlbxVJz97xIEmmtjTOetqlyubxcuaiFTOCL2IJgh3tGG/O8+plqimcY1xR2uKHWiik49C X-Received: by 2002:a63:1316:: with SMTP id i22mr4150823pgl.274.1559226953627; Thu, 30 May 2019 07:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559226953; cv=none; d=google.com; s=arc-20160816; b=tgVO/4OYW9vSjwSN4jPZvpu7nkPLmMDdcWOIvgv8JfX3BNClQE2nHjBVoF35D6XWYA mfuwMGkCKJhr6oZwkVsntGYw1jml+Br/849fqHjJE6UTTEl0AMk9qDRZUAOxdSZEE0Qf 9CAu/xfzXOREFKtim6DvRYEyQfvPIaVIPKctyGOX58a1VVPim5BqtpGMSl0TrspVZhnh PE1SGArmfzoxPZhKSXgCv4Hb56TCpz3KByI3EtRF4YzzUBbXn6wTjTjrz5G1c/ZniLjg s8phNRim50H3PqgSl1bTQ1387HTFKBUCurkZiJDMD/wRSAncld46V1tJMUUE2w6ARhlX iXqQ== 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 :in-reply-to:references:mime-version:dkim-signature; bh=vPRuBME96qBkv2+pdKHmfYwrxMsHLYg2XjuDskufNdA=; b=0ynSUM8D7Ul1riWGB++HIBt5hIxBX3oqTwigOSQ7+vaSStImZcU68xesPZDK2+IUlU Bu06ma5OLfvtcTYqPvwOO/Eh8kOn9SnvIB4PA8D2H/rD4TSxshNuvBC3wraAtESwQQGm kbRRh7zlWMmVYxDIiGLJl9aCIXW5I3tUHiEZBPX4QX50HCoVeZwccfGOafI2k42NPXtZ 29QldKIDlexGUraS/czmIVefYxEiuAjasephVqYEMrJ4Ob3eBBPmkhagnvzLNY/fxo7B 1DvCGspf2V5uAPq+9ZaxPj8r61YsFTM7ZiUfoTBpdYUm2WUyH293edbEXe/hVMydjE8b tGkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=XTIIueYD; 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 r2si3606721pjb.0.2019.05.30.07.35.31; Thu, 30 May 2019 07:35:53 -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=XTIIueYD; 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 S1727058AbfE3Ocl (ORCPT + 99 others); Thu, 30 May 2019 10:32:41 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:33103 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726250AbfE3Oci (ORCPT ); Thu, 30 May 2019 10:32:38 -0400 Received: by mail-lf1-f65.google.com with SMTP id y17so5225965lfe.0 for ; Thu, 30 May 2019 07:32:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vPRuBME96qBkv2+pdKHmfYwrxMsHLYg2XjuDskufNdA=; b=XTIIueYDuIgusp3aH/O/Ki3sag5Wo0nfFBfQ5a1MquEch+jZpd5CxLU9S/Vcl1vcBP +e/cbimawwKO5T7z6axW+B8doqpZbxx+w4JqnZ1W4X0pNfaJsiS6UNFI9ppHs0yLg8jA MJZ1u1tJuNQZIt4PnlrR7EOBDumvSxEOcENCwrOeR4qPt82fOdeBPxdvUPRN3VzBm2zs 5jc3A6uBDJ0mhFfHdcm3oAtkX645YiV0lWSAfOFzGSySLJV6dm/2IM67xOOsUGKcQE4F uUDgJNZPQukOMWkZfVyK5chCylXVcH6Ovs78CXXT6oZrsvd2YVkdsa1SS8uvVOuJDPIW Q3Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vPRuBME96qBkv2+pdKHmfYwrxMsHLYg2XjuDskufNdA=; b=hx5gnnhTawbO8gL7CVcpYrBVpo2atqjhjNaU65EZSYApTPMsFMFtztKznPIuRg9sO1 LaSeU+GFJGao0yZyY/e5KsSvTkep8I6ExS7SPXEGeK0LrIONqpOefOm1eNVp0bsP0UpQ K0QX7vLVSIuieCMM68l1/Pw+RuAWqAFXQA6CROoiiG+jf6pBLRwQNAOao164Ak0migZB fec/V9Y7AqMorcjUWd7noGe846zIs6QQ5e2sjadGuxB5ehgr7G2QUEu00MBUDbnpRkYH 5VacTC3nC0oT3ElOOkOrolId1xb7mWWz4E9myl3akAiSR28Ct+xdusiFbKxzmlCMm1RW Rd/w== X-Gm-Message-State: APjAAAXoy4a3FyL4GGA7xOOqwcrVhHFzOo6OWKLYS5qmCdCFM/hjiKYG D7BGQXfPX+ji/BHVp7L2czrmVYPoRwG55RO5EbVj X-Received: by 2002:ac2:4358:: with SMTP id o24mr2301162lfl.13.1559226755674; Thu, 30 May 2019 07:32:35 -0700 (PDT) MIME-Version: 1.0 References: <423ed5e5c5e4ed7c3e26ac7d2bd7c267aaae777c.1554732921.git.rgb@redhat.com> <20190530141555.qqcbasvyp7eokwjz@madcap2.tricolour.ca> In-Reply-To: <20190530141555.qqcbasvyp7eokwjz@madcap2.tricolour.ca> From: Paul Moore Date: Thu, 30 May 2019 10:32:24 -0400 Message-ID: Subject: Re: [PATCH ghak90 V6 09/10] audit: add support for containerid to network namespaces To: Richard Guy Briggs 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 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 Thu, May 30, 2019 at 10:16 AM Richard Guy Briggs wrote: > > 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. Okay, I missed/forgot that, it seems like the right thing to do is to leave it as-is. -- paul moore www.paul-moore.com