Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp29957imm; Tue, 24 Jul 2018 13:23:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeb/fGq6g49x4IqJcLmE5wwzuROdaJYVU4QK3PpRC1Ns70mRAZaGYleJ2h9rWpVAfZy1Jwj X-Received: by 2002:a65:41c6:: with SMTP id b6-v6mr17387648pgq.174.1532463804035; Tue, 24 Jul 2018 13:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532463804; cv=none; d=google.com; s=arc-20160816; b=oB4rOFoHBjUH9pcTjM6EusvDU3yRiW8QXCNxIksIiFtZkU4TRKWqEJYdD/DWTuALLj zWSrztufquRbpQJGo11LafAnEenUE8suOtOMR7Ch1ic3UGYJNUwKacNnju2xAvHm20iQ ytI39Gh1KYcEQybMmYDS+UPOBTGrSD+cyoEcYtdSWSHELQ0b2OIZ67aeDsxV6M8J/k+A 1e88vywlIHiPLKt9lsOmWuwgagpoi/3c7MS+kAa0RzD1U7TifXuqXzRU4dD9HkRkp6/9 ju8ixDB3zdCXOnKFL+s2SUrlv/d33IL/RWWZl5Owu6mGliIBeV9KTZ+SaxS7TKuZ2ps/ YhWw== 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 :arc-authentication-results; bh=ItUME5GIOBjyfwMZIV3URKIJHkcBt9LkCkj2lh8zsZc=; b=HHBF6xCPpYmE3TRAgcwBznKj7RcldzkeVgf79a/NiDaqbF55TEd2s3DgBlV96QGR7Q GhZ52pteUXbQOF1dVfjyw7+PxCeyX9TZYKg+GKsx6gAB9U4QVBynKAca9w8+CD1LNFQw IjVN2hDIO4d4ajjWZMfdwWt0H6Xn9aPn1wJm3Da8wV5c8aztAnsDWYjzisnQf5i1p95E cYBBqPM9c60UXwRpBNdlyS4BxYxuKHSo21/Lv0iB2WMpDn5Hry0ccFHLhhIn7R4wUBmD yxXs00q/grk2psd1ixkKWkoaLiWjcglDM14k+kH82d+BSXAecMaoesHjmDq+uunu5+G5 Nnhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=urQVxL9p; 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 j17-v6si12488037pfk.203.2018.07.24.13.23.09; Tue, 24 Jul 2018 13:23:24 -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=urQVxL9p; 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 S2388780AbeGXVaW (ORCPT + 99 others); Tue, 24 Jul 2018 17:30:22 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45684 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388614AbeGXVaW (ORCPT ); Tue, 24 Jul 2018 17:30:22 -0400 Received: by mail-lf1-f66.google.com with SMTP id j143-v6so3856520lfj.12 for ; Tue, 24 Jul 2018 13:22: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:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ItUME5GIOBjyfwMZIV3URKIJHkcBt9LkCkj2lh8zsZc=; b=urQVxL9pIGo8y04NmsE6ma5M2iZFCOBAVKtCN10VfP7bKHyeu3ZsKHg9hyJhDgKzXL JEBto2KJnTL3DZnMppXP0RaKj/GBEzhTE1l3ES4Oat/9v8mtqNyRsf0Zy9heviOcSCdO FK/TL7Vs2lunjlN9ffDPdM/yeQrguw8B9vsoFt81HLGYYYuETXY+KcQtnLJWTkwTSBmG gqQ+xdMoOUh19fgHGeaRR5pTvQpX9YkV9Q1L044LQi91B6/RlAoowueWloBa673g1NJf DppYMCb+pj4mLJrrvnPf6cc00OmfhKzbd3YOLFbi22v6YgymwTsXwF9RyfrbulRjMtCe 3cng== 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=ItUME5GIOBjyfwMZIV3URKIJHkcBt9LkCkj2lh8zsZc=; b=uJ9roJVal2OpU33MelDJtuksDMLlfLmEtaI8+2N6qRI3XHxt+q6JwyGDayQS1803iz hEVhhMDTwQSovgwtB4le/Sa9dFyU59QEIMBu4+E5sPLvUpZ6xKzSbg9+CWy4nQIJfs6g BdEVE6Z1BfGcVlM/Z3Lm4OI9IHgnJqR1fCE9KPbySonKI4q20UsjBFFq3P8U50VMD2sw zodASylwl3ztSzavaUEsYgLlFroAA37rqQ5fDY/3cPASoXXg10VA+86d0gDHXrcM2S8G bLkikR2AhYUj86WTvWrA9wFxGVPkbQW/RJ6M38WPJMLGwwLc3qc/3QHr42eMz+EMUnPA gI9w== X-Gm-Message-State: AOUpUlGeIBsSjvRUoYiRpMeCJnYBJG1IgaB38xgQ09OyXrKS+c3QsNQF y13CDf5SMEYPuk0wZ8BVvqJzuPels+L62oZlkVzC X-Received: by 2002:a19:de4e:: with SMTP id v75-v6mr10531212lfg.14.1532463731688; Tue, 24 Jul 2018 13:22:11 -0700 (PDT) MIME-Version: 1.0 References: <1748819.SHaROlQLoH@x2> In-Reply-To: <1748819.SHaROlQLoH@x2> From: Paul Moore Date: Tue, 24 Jul 2018 16:22:00 -0400 Message-ID: Subject: Re: [RFC PATCH ghak90 (was ghak32) V3 08/10] audit: NETFILTER_PKT: record each container ID associated with a netNS To: sgrubb@redhat.com Cc: rgb@redhat.com, cgroups@vger.kernel.org, containers@lists.linux-foundation.org, linux-api@vger.kernel.org, linux-audit@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, 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 Tue, Jul 24, 2018 at 3:48 PM Steve Grubb wrote: > On Friday, July 20, 2018 6:15:00 PM EDT Paul Moore wrote: > > On Wed, Jun 6, 2018 at 1:03 PM Richard Guy Briggs wrote: > > > Add audit container identifier auxiliary record(s) to NETFILTER_PKT > > > event standalone records. Iterate through all potential audit container > > > identifiers associated with a network namespace. > > > > > > Signed-off-by: Richard Guy Briggs > > > --- > > > include/linux/audit.h | 5 +++++ > > > kernel/audit.c | 20 +++++++++++++++++++- > > > kernel/auditsc.c | 2 ++ > > > net/netfilter/xt_AUDIT.c | 12 ++++++++++-- > > > 4 files changed, 36 insertions(+), 3 deletions(-) > > > > ... > > > > > diff --git a/include/linux/audit.h b/include/linux/audit.h > > > index 7e2e51c..4560a4e 100644 > > > --- a/include/linux/audit.h > > > +++ b/include/linux/audit.h > > > @@ -167,6 +167,8 @@ extern int audit_log_contid(struct audit_context > > > *context, extern void audit_contid_add(struct net *net, u64 contid); > > > extern void audit_contid_del(struct net *net, u64 contid); > > > extern void audit_switch_task_namespaces(struct nsproxy *ns, struct > > > task_struct *p); +extern void audit_log_contid_list(struct net *net, > > > + struct audit_context *context); > > > > See my comment in previous patches about changing the function name to > > better indicate it's dedicate use for network namespaces. > > > > > extern int audit_update_lsm_rules(void); > > > > > > @@ -231,6 +233,9 @@ static inline void audit_contid_del(struct net *net, > > > u64 contid) { } > > > static inline void audit_switch_task_namespaces(struct nsproxy *ns, > > > struct task_struct *p) { } > > > +static inline void audit_log_contid_list(struct net *net, > > > + struct audit_context *context) > > > +{ } > > > > > > #define audit_enabled 0 > > > #endif /* CONFIG_AUDIT */ > > > diff --git a/kernel/audit.c b/kernel/audit.c > > > index ecd2de4..8cca41a 100644 > > > --- a/kernel/audit.c > > > +++ b/kernel/audit.c > > > @@ -382,6 +382,20 @@ void audit_switch_task_namespaces(struct nsproxy > > > *ns, struct task_struct *p) audit_contid_add(new->net_ns, contid); > > > } > > > > > > +void audit_log_contid_list(struct net *net, struct audit_context > > > *context) +{ > > > + struct audit_contid *cont; > > > + int i = 0; > > > + > > > + list_for_each_entry(cont, audit_get_contid_list(net), list) { > > > + char buf[14]; > > > + > > > + sprintf(buf, "net%u", i++); > > > + audit_log_contid(context, buf, cont->id); > > > > Hmm. It looks like this will generate multiple audit container ID > > records with "op=netX contid=Y" (X=netns number, Y=audit container > > ID), is that what we want? I've mentioned my concern around the "op" > > values in these records earlier in the patchset, that still applies > > here, but now I'm also concerned about the multiple records. I'm > > thinking we might be better served with a single record with either > > multiple "contid" fields, or a single "contid" field with a set of > > comma separated values (or some other delimiter that Steve's tools > > will tolerate). > > > > Steve, thoughts? > > A single record is best. Maybe pattern this after the args listed in an > execve record. I'm concerned that an execve-like approach might not scale very well as would could potentially have a lot of containers sharing a single network namespace ("a%d=%d" vs ",%d"). Further, with execve we log the argument position in addition to the argument itself, that isn't something we need to worry about with the audit container IDs. -- paul moore www.paul-moore.com