From: Richard Guy Briggs <rgb@redhat.com>
To: Paul Moore <paul@paul-moore.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 <eparis@parisplace.org>,
serge@hallyn.com
Subject: Re: [RFC PATCH ghak90 (was ghak32) V3 07/10] audit: add support for containerid to network namespaces
Date: Thu, 26 Jul 2018 09:33:08 -0400 [thread overview]
Message-ID: <20180726133308.cb7x7yvdxek23eb3@madcap2.tricolour.ca> (raw)
In-Reply-To: <CAHC9VhSuczaFi49-3SrVM9vND=vT=U1Aj0G6kOyJ3rAFnvi6VA@mail.gmail.com>
On 2018-07-24 16:33, Paul Moore wrote:
> On Tue, Jul 24, 2018 at 10:06 AM Richard Guy Briggs <rgb@redhat.com> wrote:
> > On 2018-07-20 18:14, Paul Moore wrote:
> > > On Wed, Jun 6, 2018 at 1:03 PM Richard Guy Briggs <rgb@redhat.com> 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 <rgb@redhat.com>
> > > > ---
> > > > 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.
I don't think any code is needed in audit_net_exit() other than a WARN()
that the contid list is empty, since if a netns is going away, all its
tasks would have exited (removing its contid from the list) or moved to
a new nstns (moving its contid from this list to another netns).
At worst, this is a memory leak and not a bad pointer dereference.
> paul moore
- RGB
--
Richard Guy Briggs <rgb@redhat.com>
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
next prev parent reply other threads:[~2018-07-26 13:36 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-06 16:58 [RFC PATCH ghak90 (was ghak32) V3 00/10] audit: implement container identifier Richard Guy Briggs
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 01/10] audit: add container id Richard Guy Briggs
2018-06-06 17:56 ` Steve Grubb
2018-06-06 20:26 ` Richard Guy Briggs
2018-07-20 22:13 ` Paul Moore
2018-07-24 19:06 ` Richard Guy Briggs
2018-07-24 21:54 ` Paul Moore
2018-07-30 18:47 ` Richard Guy Briggs
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 02/10] audit: log container info of syscalls Richard Guy Briggs
2018-06-06 17:58 ` Steve Grubb
2018-07-20 22:13 ` Paul Moore
2018-07-21 20:29 ` Richard Guy Briggs
2018-07-22 13:32 ` Steve Grubb
2018-07-22 20:55 ` Richard Guy Briggs
2018-07-22 21:03 ` Richard Guy Briggs
2018-07-23 13:19 ` Steve Grubb
2018-07-23 15:11 ` Richard Guy Briggs
2018-07-23 16:48 ` Steve Grubb
2018-07-23 18:31 ` Paul Moore
2018-07-26 0:51 ` Richard Guy Briggs
2018-07-31 20:07 ` Richard Guy Briggs
2018-07-23 13:16 ` Paul Moore
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 03/10] audit: add containerid support for ptrace and signals Richard Guy Briggs
2018-07-20 22:13 ` Paul Moore
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 04/10] audit: add support for non-syscall auxiliary records Richard Guy Briggs
2018-07-20 22:14 ` Paul Moore
2018-07-24 19:37 ` Richard Guy Briggs
2018-07-24 21:57 ` Paul Moore
2018-07-26 14:30 ` Richard Guy Briggs
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 05/10] audit: add containerid support for tty_audit Richard Guy Briggs
2018-07-20 22:14 ` Paul Moore
2018-07-24 14:07 ` Richard Guy Briggs
2018-07-24 20:36 ` Paul Moore
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 06/10] audit: add containerid filtering Richard Guy Briggs
2018-07-20 22:14 ` Paul Moore
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 07/10] audit: add support for containerid to network namespaces Richard Guy Briggs
2018-07-20 22:14 ` Paul Moore
2018-07-24 14:03 ` Richard Guy Briggs
2018-07-24 20:33 ` Paul Moore
2018-07-26 13:33 ` Richard Guy Briggs [this message]
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 08/10] audit: NETFILTER_PKT: record each container ID associated with a netNS Richard Guy Briggs
2018-07-20 22:15 ` Paul Moore
2018-07-24 19:48 ` Steve Grubb
2018-07-24 20:22 ` Paul Moore
2018-07-24 20:55 ` Richard Guy Briggs
2018-07-21 15:32 ` Laura Garcia
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 09/10] debug audit: read container ID of a process Richard Guy Briggs
2018-07-20 22:15 ` Paul Moore
2018-07-21 19:21 ` Richard Guy Briggs
2018-06-06 16:58 ` [RFC PATCH ghak90 (was ghak32) V3 10/10] rfkill: fix spelling mistake contidion to condition Richard Guy Briggs
2018-07-18 20:56 ` Paul Moore
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180726133308.cb7x7yvdxek23eb3@madcap2.tricolour.ca \
--to=rgb@redhat.com \
--cc=carlos@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=containers@lists.linux-foundation.org \
--cc=dhowells@redhat.com \
--cc=ebiederm@xmission.com \
--cc=eparis@parisplace.org \
--cc=jlayton@redhat.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-audit@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=simo@redhat.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).