From: Christian Brauner <christian.brauner@ubuntu.com>
To: Kees Cook <keescook@chromium.org>
Cc: linux-kernel@vger.kernel.org, Andy Lutomirski <luto@kernel.org>,
Tycho Andersen <tycho@tycho.ws>,
Matt Denton <mpdenton@google.com>,
Sargun Dhillon <sargun@sargun.me>, Jann Horn <jannh@google.com>,
Chris Palmer <palmer@google.com>,
Aleksa Sarai <cyphar@cyphar.com>,
Robert Sesek <rsesek@google.com>,
Jeffrey Vander Stoep <jeffv@google.com>,
Linux Containers <containers@lists.linux-foundation.org>
Subject: Re: [PATCH v2 1/2] seccomp: notify user trap about unused filter
Date: Fri, 29 May 2020 10:37:51 +0200 [thread overview]
Message-ID: <20200529083751.jykf2k7ajsymwldx@wittgenstein> (raw)
In-Reply-To: <202005290102.3BB21C875@keescook>
On Fri, May 29, 2020 at 01:06:59AM -0700, Kees Cook wrote:
> On Fri, May 29, 2020 at 09:56:41AM +0200, Christian Brauner wrote:
> > On Thu, May 28, 2020 at 04:11:00PM -0700, Kees Cook wrote:
> > > void seccomp_filter_release(const struct task_struct *tsk)
> > > {
> > > struct seccomp_filter *orig = READ_ONCE(tsk->seccomp.filter);
> > >
> > > smp_store_release(&tsk->seccomp.filter, NULL);
> >
> > I need to go through the memory ordering requirements before I can say
> > yay or nay confidently to this. :)
> >
> > > __seccomp_filter_release(orig);
> > > }
>
> The only caller will be release_task() after dethread, so honestly this
> was just me being paranoid. I don't think it actually needs the
> READ_ONCE() nor the store_release. I think I wrote all that before I'd
> convinced myself it was safe to remove a filter then. But I'm still
> suspicious given the various ways release_task() gets called... I just
> know that if mode 2 is set and filter == NULL, seccomp will fail closed,
> so I went the paranoid route. :)
release_task() should only be called once per thread otherwise we'd have
big problems. And every time we call release_task() we're already
EXIT_DEAD iirc. So there should be no way someone else can find us (in a
relevant way and especially not from userspace).
exit_notify() -> if we're autoreaping we're EXIT_DEAD anyway, if we're
not autoreaping we'll wait_task_zombie() eventually -> we're EXIT_DEAD
(parent has reaped us)
find_child_reaper() -> we couldn't find a child reaper for us, i.e. we
were (namespace) init -> unlink all tasks we were ptracing
(exit_ptrace()) and if they're EXIT_DEAD move them to the dead list ->
release_task()'s that are EXIT_DEAD that we ptraced.
and de_thread() relies on EXIT_DEAD too:
/*
* We are going to release_task()->ptrace_unlink() silently,
* the tracer can sleep in do_wait(). EXIT_DEAD guarantees
* the tracer wont't block again waiting for this thread.
*/
(This is a very _rough_ sketch.)
So I think that's safe.
Christian
prev parent reply other threads:[~2020-05-29 8:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-28 15:14 Christian Brauner
2020-05-28 15:14 ` [PATCH v2 2/2] tests: test seccomp filter notifications Christian Brauner
2020-05-29 5:41 ` Kees Cook
2020-05-29 8:00 ` Christian Brauner
2020-05-28 23:11 ` [PATCH v2 1/2] seccomp: notify user trap about unused filter Kees Cook
2020-05-28 23:32 ` Jann Horn
2020-05-29 5:36 ` Kees Cook
2020-05-29 7:51 ` Christian Brauner
2020-05-29 7:56 ` Kees Cook
2020-05-29 8:00 ` Christian Brauner
2020-05-29 8:50 ` Christian Brauner
2020-05-29 7:47 ` Christian Brauner
2020-05-29 8:02 ` Kees Cook
2020-05-29 7:56 ` Christian Brauner
2020-05-29 8:06 ` Kees Cook
2020-05-29 8:37 ` Christian Brauner [this message]
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=20200529083751.jykf2k7ajsymwldx@wittgenstein \
--to=christian.brauner@ubuntu.com \
--cc=containers@lists.linux-foundation.org \
--cc=cyphar@cyphar.com \
--cc=jannh@google.com \
--cc=jeffv@google.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mpdenton@google.com \
--cc=palmer@google.com \
--cc=rsesek@google.com \
--cc=sargun@sargun.me \
--cc=tycho@tycho.ws \
/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
Powered by JetHome