From: Kees Cook <keescook@chromium.org>
To: Jann Horn <jannh@google.com>
Cc: Micah Morton <mortonm@chromium.org>,
James Morris <jmorris@namei.org>,
Casey Schaufler <casey@schaufler-ca.com>,
linux-security-module <linux-security-module@vger.kernel.org>
Subject: Re: [PATCH 07/10] LSM: SafeSetID: rewrite userspace API to atomic updates
Date: Wed, 10 Apr 2019 11:20:17 -0700 [thread overview]
Message-ID: <CAGXu5jL8YYG-jTuQkfH1kBPSdY-FamO_YobcL_rCyNKqq3NHmw@mail.gmail.com> (raw)
In-Reply-To: <CAG48ez0a6iyw_TCF2aY4ADbiveaAy+tZeiKjT0j7+36qC6W_og@mail.gmail.com>
On Wed, Apr 10, 2019 at 10:47 AM Jann Horn <jannh@google.com> wrote:
>
> On Wed, Apr 10, 2019 at 7:24 PM Kees Cook <keescook@chromium.org> wrote:
> > On Wed, Apr 10, 2019 at 9:56 AM Micah Morton <mortonm@chromium.org> wrote:
> > > From: Jann Horn <jannh@google.com>
> > >
> > > The current API of the SafeSetID LSM uses one write() per rule, and applies
> > > each written rule instantly. This has several downsides:
> > >
> > > - While a policy is being loaded, once a single parent-child pair has been
> > > loaded, the parent is restricted to that specific child, even if
> > > subsequent rules would allow transitions to other child UIDs. This means
> > > that during policy loading, set*uid() can randomly fail.
> > > - To replace the policy without rebooting, it is necessary to first flush
> > > all old rules. This creates a time window in which no constraints are
> > > placed on the use of CAP_SETUID.
> > > - If we want to perform sanity checks on the final policy, this requires
> > > that the policy isn't constructed in a piecemeal fashion without telling
> > > the kernel when it's done.
> > >
> > > Other kernel APIs - including things like the userns code and netfilter -
> > > avoid this problem by performing updates atomically. Luckily, SafeSetID
> > > hasn't landed in a stable (upstream) release yet, so maybe it's not too
> > > late to completely change the API.
> > >
> > > The new API for SafeSetID is: If you want to change the policy, open
> > > "safesetid/whitelist_policy" and write the entire policy,
> > > newline-delimited, in there.
> >
> > So the entire policy is expected to be sent in a single write() call?
> >
> > open()
> > write(policy1)
> > write(policy2)
> > close()
> >
> > means only policy2 is active?
>
> No; if you do that, the first write() sets policy1, and the second
> write() fails with -EINVAL because of the "if (*ppos != 0) return
> -EINVAL;" in safesetid_file_write() (which already exists in the
> current version of the LSM).
Ah yes, thanks! I missed that check. Good!
>
> > I thought policy was meant to be built
> > over time? i.e. new policy could get appended to existing?
>
> That's what the current API does; as I've explained in the commit
> message, I think that that's a bad idea.
Okay, sounds fine. It wasn't clear to me from the commit message if
you meant "write the whole policy during a single open/close" or
"write whole policy with a single initial write".
--
Kees Cook
next prev parent reply other threads:[~2019-04-10 18:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-10 16:56 [PATCH 07/10] LSM: SafeSetID: rewrite userspace API to atomic updates Micah Morton
2019-04-10 17:24 ` Kees Cook
2019-04-10 17:47 ` Jann Horn
2019-04-10 18:20 ` Kees Cook [this message]
2019-05-07 15:02 ` Micah Morton
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=CAGXu5jL8YYG-jTuQkfH1kBPSdY-FamO_YobcL_rCyNKqq3NHmw@mail.gmail.com \
--to=keescook@chromium.org \
--cc=casey@schaufler-ca.com \
--cc=jannh@google.com \
--cc=jmorris@namei.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mortonm@chromium.org \
/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).