linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Christoph Lameter <cl@linux.com>
Cc: Casey Schaufler <casey@schaufler-ca.com>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	Serge Hallyn <serge.hallyn@ubuntu.com>,
	Serge Hallyn <serge.hallyn@canonical.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Aaron Jones <aaronmdjones@gmail.com>, "Ted Ts'o" <tytso@mit.edu>,
	LSM List <linux-security-module@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linuxfoundation.org>
Subject: Re: [capabilities] Allow normal inheritance for a configurable set of capabilities
Date: Tue, 3 Feb 2015 15:17:44 -0800	[thread overview]
Message-ID: <CALCETrWvdf_Lf5H=wDW0ytKVaMzjZOBHpyQRW0q3bMk04yqvYg@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1502031708100.9261@gentwo.org>

On Tue, Feb 3, 2015 at 3:14 PM, Christoph Lameter <cl@linux.com> wrote:
> On Tue, 3 Feb 2015, Andy Lutomirski wrote:
>
>> >                  */
>> >                 new->cap_permitted.cap[i] =
>> >                         (new->cap_bset.cap[i] & permitted) |
>> > -                       (new->cap_inheritable.cap[i] & inheritable);
>> > +                       (new->cap_inheritable.cap[i] & inheritable) |
>> > +                       (ambient & inheritable);
>>
>> Is there a clear reason why no non-permitted bits can be inheritable?
>> If not, then I think this should be (ambient & inheritable &
>> permitted).
>
> Inherited caps via ambient are always be permitted. Otherwise the pass
> through is not working.

Sure, but what about inheritable caps before exec?  Suppose I drop
some cap from the permitted set but leave it in the inheritable set.
I shouldn't get it back by calling execve.

>
>> Do we need to think about the effective mask here?  What happens when
>> we exec a setuid program or a program with a non-empty fP set?  I
>> think that, in these cases, we should strongly consider clearing the
>> ambient set.  For a different approach, see below.
>>
>> >
>> >                 if (permitted & ~new->cap_permitted.cap[i])
>> >                         /* insufficient to execute correctly */
>> >                         ret = -EPERM;
>> > +
>> > +               if (capable(CAP_AMBIENT_MASK))
>> > +                       new->cap_ambient.cap[i] = inheritable;
>> > +               else
>> > +                       new->cap_ambient.cap[i] = ambient;
>>
>> IMO this is really weird.  I don't think that the presence of an
>> effective cap should change the cap equations.  (Also, that should be
>> nsown_capable.)
>
> Well how would the ambient mask to be set? The other options are adding a
> new syscall and having to go through an interation of the capabilities
> tools and/or kernel syscall API changes.

prctl?

>
>> Can we please make this an explicit opt-in?  For example, allow a
>> process to set an ambient cap bit if that bit is both permitted and
>> inheritable.  I'd prefer having it be a single control, though -- just
>> prctl(PR_SET_ALWAYS_INHERIT_CAPS, 1, 0, 0, 0) would set a single bit
>> that would cause all inheritable bits to be treated as ambient.
>
> Opt-in does not work since the caps need to be passed
> through binaries that do not use the capabilities.
>
>> Here's a slight variant that might be more clearly safe: add an
>> inherited per-process bit that causes all files to act as though fI is
>> the full set.  Only allow setting that bit if no_new_privs is set.
>
> CAP_INHERIT_ALL ?
>

Sure.  Would this approach work for your use case?  It would work for
mine, and it avoids needing to think about how this new kind of
inheritance would interact with setuid, setgid, and file caps (i.e. it
wouldn't, because you have to turn on off to get the other).

Opt-in should work fine as long as the opt-in is inherited.

--Andy

-- 
Andy Lutomirski
AMA Capital Management, LLC

  reply	other threads:[~2015-02-03 23:18 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-02 16:21 [capabilities] Allow normal inheritance for a configurable set of capabilities Christoph Lameter
2015-02-02 17:12 ` Serge Hallyn
2015-02-02 17:18   ` Andy Lutomirski
2015-02-02 18:09     ` Serge Hallyn
2015-02-03 15:16     ` Christoph Lameter
2015-02-03 15:23   ` Christoph Lameter
2015-02-03 15:55     ` Serge E. Hallyn
2015-02-03 17:18       ` Christoph Lameter
2015-02-03 17:26         ` Serge E. Hallyn
2015-02-04 15:15           ` Andrew G. Morgan
2015-02-04 15:50             ` Christoph Lameter
2015-02-04 15:56               ` Serge E. Hallyn
2015-02-04 16:12                 ` Andrew G. Morgan
2015-02-04 16:34                   ` Andy Lutomirski
2015-02-04 16:54                     ` Andrew G. Morgan
2015-02-04 17:34                       ` Serge E. Hallyn
2015-02-04 18:12                         ` Christoph Lameter
2015-02-04 16:43                   ` Christoph Lameter
2015-02-04 16:27                 ` Andy Lutomirski
2015-02-05  0:34             ` Serge E. Hallyn
2015-02-05 15:23               ` Serge E. Hallyn
2015-02-25 21:50     ` Pavel Machek
2015-02-25 23:59       ` Christoph Lameter
2015-02-26 12:27         ` Pavel Machek
2015-02-27 20:15           ` Andy Lutomirski
2015-02-27 20:48             ` Pavel Machek
2015-02-27 20:56               ` Andy Lutomirski
2015-02-27 22:47                 ` Pavel Machek
2015-02-02 17:54 ` Casey Schaufler
2015-02-02 18:08   ` Serge Hallyn
2015-02-02 18:47     ` Mimi Zohar
2015-02-02 19:05       ` Austin S Hemmelgarn
2015-02-02 20:35         ` Casey Schaufler
2015-02-03 16:04       ` Serge E. Hallyn
2015-02-02 19:00     ` Casey Schaufler
2015-02-05  0:20       ` Serge E. Hallyn
2015-02-02 20:37     ` Andy Lutomirski
2015-02-02 20:54       ` Casey Schaufler
2015-02-03 15:51         ` Serge E. Hallyn
2015-02-03 16:37           ` Casey Schaufler
2015-02-03 17:28             ` Serge E. Hallyn
2015-02-03 17:50               ` Casey Schaufler
2015-02-03 19:45                 ` Christoph Lameter
2015-02-03 20:13                   ` Andy Lutomirski
2015-02-03 23:14                     ` Christoph Lameter
2015-02-03 23:17                       ` Andy Lutomirski [this message]
2015-02-04  2:27                         ` Christoph Lameter
2015-02-04  6:05                         ` Markku Savela
2015-02-04 13:17                           ` Christoph Lameter
2015-02-04 13:41                             ` Markku Savela
2015-02-04 14:56                               ` Jarkko Sakkinen
2015-02-03 15:17       ` Christoph Lameter
2015-02-03 15:40         ` Casey Schaufler
2015-02-03 15:46       ` Serge E. Hallyn
2015-02-03 17:19         ` Christoph Lameter
2015-02-03 17:29           ` Serge E. Hallyn
2015-02-25 21:50     ` Pavel Machek

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='CALCETrWvdf_Lf5H=wDW0ytKVaMzjZOBHpyQRW0q3bMk04yqvYg@mail.gmail.com' \
    --to=luto@amacapital.net \
    --cc=aaronmdjones@gmail.com \
    --cc=akpm@linuxfoundation.org \
    --cc=casey@schaufler-ca.com \
    --cc=cl@linux.com \
    --cc=corbet@lwn.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=serge.hallyn@canonical.com \
    --cc=serge.hallyn@ubuntu.com \
    --cc=serge@hallyn.com \
    --cc=tytso@mit.edu \
    /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).