Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp39896imm; Tue, 24 Jul 2018 13:36:01 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfBfsBXC74K61Omlu+isGctgW8iqYqlybSIACzmLJZdntoql5XbTZiH7iCxhBSGo+atWdDB X-Received: by 2002:a62:ea05:: with SMTP id t5-v6mr19159785pfh.228.1532464561028; Tue, 24 Jul 2018 13:36:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532464561; cv=none; d=google.com; s=arc-20160816; b=FiyJkgxaOxjYgnN1aotGAndcDc3j2uFkxCtdp/rzmXQJ+JY7etx8zuc1Ha96r+x36p rWPUloBprEb4vHfTbPBjkah37JskqcO5fimt7Ka0S6G4dOAi4WXRb5U3VtfqOXXEZX7v CBuchq3vP2PZqnXXNsgOYwiUGxxfGX7QJNGRC25NKgM+nFO+2avh3CHj0C8MeGR7QPkX VFxfOmh/l0CGCc7T4KQumaT36HnpyIo5EPfZ+yBBPjLkjWBvSlNkjf60Bt10WrPv2KZw YLgKTc7YtfKbGXw0xlNNoCxWXRAs6gqYpOrv4pNb8kIqDORBaj2CVcON5F7gJZJHnYZe Kvmg== 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=U5oesWHlMUEb4TtjNapPWjZXL1XsJL2Ptex9hElqQw4=; b=uUzL85c5e+WBLY78On0FLZAjP89/XhGUVHD95+bJ0wIVnJo/G96ZD4LDUa6wll2BN/ ojyGZJ4riF3FihEp17lvB/8hF6RKeLxfxHQa2UXU70LPzqc4eUGBVxXyUQWJHPwWWgPl 4zTADLPhPiTPiaVK1NLNrkZsgE8U/i9nZ2uwBGCB9Es63FuoL3R/yK11R6Kt0TvGJ0Vw 1wJBk9aXYqK2z1Sn8l/EjdSvHhpg4CzJqJUvOIqa/aI/drNNouLIxcamUMxhIc7ashUR VIpWWAP2Y6l9vGPoTJ73Dn9ggfeqd4/i6Y6C5mC2/SL/LapkK5sSxxiIZ46349ZDLXaf h6kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=b60gD1He; 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 f16-v6si12264059pff.13.2018.07.24.13.35.45; Tue, 24 Jul 2018 13:36:00 -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=b60gD1He; 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 S2388786AbeGXVmK (ORCPT + 99 others); Tue, 24 Jul 2018 17:42:10 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:41451 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388639AbeGXVmJ (ORCPT ); Tue, 24 Jul 2018 17:42:09 -0400 Received: by mail-lj1-f196.google.com with SMTP id y17-v6so4741686ljy.8 for ; Tue, 24 Jul 2018 13:33:57 -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=U5oesWHlMUEb4TtjNapPWjZXL1XsJL2Ptex9hElqQw4=; b=b60gD1He2SjEQ9TNqm5yTjX3I37153yd8MOsUEZlVX1qV/KFAV4UuLrzdcvBYkpWLx Mo1NBjg7bX0f33CCui88m3xCDL7AFRNCWtvNfRzcHCg/pybQGGKAEipA+L/lrRheFFAv S7uMMia4s86RtTjDEMq9hadTCM3TZDoqc/NZglrZCEtFxPD5+0EaouWo2fkmxa07iPxG IBQ1NCbqdvM7IaDpLlkje62E8tazK2EoRhI15NfsipT2lY7WPS6hElJlKB5LX20vrY+m qQwd8gUjHLI/E4n8mkO23bqGDwiZ0FyUcAyXNcCSaXiXQ9pRR9BCt/PUT10dWcXSNxmV LCuA== 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=U5oesWHlMUEb4TtjNapPWjZXL1XsJL2Ptex9hElqQw4=; b=dN2jAv8mHOaPv7/GUNMnePlJwx9ZSF+jVvzKv8MlCsiZou9g5my9GQGFu8fEkFSQyc IR9aDIm0ALvEjHPSI07Och1ybhESzC9JbRTYZB7RK6R/UobCK5F4EH8xn8Z0nP6DZN1r Azp5fy8a9WWIGqwBEVsc1OiQIEOk8bajB+fl+V2dL/we5ZhEY1Ccm9hKzLAMTBw+T1NF bXPZ9kdQwcLwspsNJcY/SFtXt65SuELrE7LSb2e0zaWWSFYPhOThCQdYDtHqprh1RV0a mb9y+gKaxASil2VqAuIPtj1Mv871d7kQ+ngoH3wa3oQ/cE3SWUhGBA2F0+8GIYNmZFAL HSeQ== X-Gm-Message-State: AOUpUlGDPNS+p0IV81FHreLPI43tDM8iDPqsRHMpN92xtfNhhys9Th/+ UBCKWBoxhtJOUwF657CNnO1VHN7N7l8+L7HUdte4 X-Received: by 2002:a2e:291c:: with SMTP id u28-v6mr12755784lje.70.1532464437079; Tue, 24 Jul 2018 13:33:57 -0700 (PDT) MIME-Version: 1.0 References: <562cfaf7629b64252aac7cf3cecdd70b471af5b5.1528304204.git.rgb@redhat.com> <20180724140309.i6o2yjdoif5krxtw@madcap2.tricolour.ca> In-Reply-To: <20180724140309.i6o2yjdoif5krxtw@madcap2.tricolour.ca> From: Paul Moore Date: Tue, 24 Jul 2018 16:33:45 -0400 Message-ID: Subject: Re: [RFC PATCH ghak90 (was ghak32) V3 07/10] audit: add support for containerid to network namespaces To: rgb@redhat.com Cc: 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 10:06 AM Richard Guy Briggs wrote: > On 2018-07-20 18:14, Paul Moore wrote: > > On Wed, Jun 6, 2018 at 1:03 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 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 > > > > > > See: https://github.com/linux-audit/audit-kernel/issues/92 > > > See: https://github.com/linux-audit/audit-testsuite/issues/64 > > > See: https://github.com/linux-audit/audit-kernel/wiki/RFE-Audit-Container-ID > > > Signed-off-by: Richard Guy Briggs > > > --- > > > include/linux/audit.h | 23 ++++++++++++++++ > > > kernel/audit.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ > > > kernel/auditsc.c | 5 ++++ > > > kernel/nsproxy.c | 4 +++ > > > 4 files changed, 104 insertions(+) ... > > > + } > > > + if (!found) > > > + return; > > > + list_del(&cont->list); > > > + if (refcount_dec_and_test(&cont->refcount)) > > > + kfree(cont); > > > > Don't you want to dec_and_test first and only remove it from the list > > if there are no other references? > > I don't think so. Let me try to describe it in prose to see if I > understood this properly and see if this makes more sense: I want to > remove this audit_contid list member from this net's audit_contid list > and decrement unconditionally this member's refcount so it knows there > is one less thing pointing at it and when there is no longer anything > pointing at it, free it. Yep, sorry, my mistake, I was thinking the other way around (netns going away) ... which actually, this patchset doesn't handle that does it (I don't see any new code in audit_net_exit())? Is is in a later patch? If so, it really should be in the same patch as this code to prevent bisect nasties. -- paul moore www.paul-moore.com