Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6900319ybi; Wed, 29 May 2019 15:18:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqytW9/cCd1+e13jIEk3tC59q3IxbLEDNZ5JpqxNGvQe+ByEfge8sDr68PYdMWG5F6utHYJ3 X-Received: by 2002:a17:902:63:: with SMTP id 90mr240499pla.342.1559168328631; Wed, 29 May 2019 15:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559168328; cv=none; d=google.com; s=arc-20160816; b=eaq1ronJdNhE5jzvaet1wAULxUMsJwKYO2d/w93ePL86z3NtpBMMEqWgp+Uy9AcCzH I9ACG1Jck3zJaModTYylocPxOuTqB1dHpDXTb27yKbK8CIm+8z4z/veXYAaUKWIu71Od yJRhZiDFyX0S5RS8ReyHWMKkAmzW052YQao/FCl2i+UITNj3lTCczVhTRlgTb0M+41f3 M4M3FZT2zZD2kxyt+iyoGcqrz41Ibc8236O2gu1lQXYE4wcQjk9NPRCMBsod1Zb317r5 MYE/bpuKHV1HUlY9XreB/LRe6KMmpeQQdgS521yPl7UsLJYH5qE/eOxxHsASfzkEQS21 5NKw== 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=fIvU+ha0PviU/sibSkvPHyTumVcfp/XuVnG8TGWl1tg=; b=n7sURK9LhAIZgmIE/AhWkX4PtFmUzZqt+M5g/wcaAB69cams+ieR67lV7QuwURKr1g dROpQOYQM+0EXbADRwfyH3Dejx1lXGhZvZnRoTHz27Tr1ai8CltjrwdcE4HaGRE0DqL1 IsUl3pQiRH6+/8bHJQ3oQ1aCjROxgxclYTpYDeJQMgjaSiy7zc5sbDefhBr6q4Jx3PH+ 30rNe0+2sDF/eICPham/UZSrzZsWO4mfqy9IK8dbU7ozVwLTkHa4VwyMFvnrl4cawiwq I5C1wtVkZmm3PwaaQuT0FVWswOKzCaiXU1/y2sS7B4BTKIb3AwH5iv+1RQELvaLsSTZE f/Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=IhDJTlpc; 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 b1si983408pls.93.2019.05.29.15.18.32; Wed, 29 May 2019 15:18:48 -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=IhDJTlpc; 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 S1726240AbfE2WRW (ORCPT + 99 others); Wed, 29 May 2019 18:17:22 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:40464 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbfE2WRV (ORCPT ); Wed, 29 May 2019 18:17:21 -0400 Received: by mail-lf1-f65.google.com with SMTP id a9so1949194lff.7 for ; Wed, 29 May 2019 15:17:20 -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=fIvU+ha0PviU/sibSkvPHyTumVcfp/XuVnG8TGWl1tg=; b=IhDJTlpcamR/KqtIXXIXgJdfXAsLI2C+ZEXAuUNYlKWGn6wHjE6fpIPNIeDhT7ycQ8 57igNJrmJ5BNTBnviUUG/OZd+IF7VgnoVis5ZCCvJxb17ZrBByYBXhXN+ZRYNnc3FRIy brSYU1jvKSGa+TNQ8WETswSfhGeqztSbfJ7L/bGXevP+zB/TZdI4CXbRsu2J41G+yDwo qMRxFM1D7xND12GCJwbw+whugNAe6MnXELtdl7/PWacMAbHfg0mkPJsrxG4ICI+/4Bgd Umpf4FN+xj/KrTwt5uEEEDaa00hFCmx8k3DNIvdAxi+WqGo7sS1kO5oJBoew7DOwAn5i 7ioA== 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=fIvU+ha0PviU/sibSkvPHyTumVcfp/XuVnG8TGWl1tg=; b=Jc9X/uJJT3ru1Vd9/cI0Xw3/qkFuq8AO9IZ7IKyNVlmLg21DEdk+qIRhBSYE62H8hx uR4AgAbpB7lQipIFvgJ8r2bGL251Rsrf1ctOxfvcoe1kI8GQB/gxbJEgq6SGcMHVjhxU kql8+RVWzQH8VmvbYpxMkqkw99vJ2ZSS8pFcTwkNsCprV8mwQKiKjR61QdVZLhN3sl17 0UXniTZvi/24s7sD5mH6YevfoTjZsmmK7KRBObp9LfYn2XFdBpz1IT7OlmYlmhrZbklx 2OCYsNUNPUN0JWS/uZlJT/1M0Vanqd/UpNbCgFyOmN7wRWxTGEAbRtOedJgPfCse8r/g l+fQ== X-Gm-Message-State: APjAAAV2sW8Inm8pFW2XfgkKHoUy1Vp5pglzLmSSna6QgpNJ0mOiTNzg z3EFXqHSuPNVkbug1k7zmsQhktOHPxrTLwNPOUy1 X-Received: by 2002:a19:c301:: with SMTP id t1mr140375lff.137.1559168239261; Wed, 29 May 2019 15:17:19 -0700 (PDT) MIME-Version: 1.0 References: <423ed5e5c5e4ed7c3e26ac7d2bd7c267aaae777c.1554732921.git.rgb@redhat.com> In-Reply-To: <423ed5e5c5e4ed7c3e26ac7d2bd7c267aaae777c.1554732921.git.rgb@redhat.com> From: Paul Moore Date: Wed, 29 May 2019 18:17:08 -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 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? > + 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