public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Daniel Mack <daniel@zonque.org>
To: Andy Lutomirski <luto@amacapital.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Arnd Bergmann <arnd@arndb.de>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>,
	Tom Gundersen <teg@jklm.no>, Jiri Kosina <jkosina@suse.cz>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	David Herrmann <dh.herrmann@gmail.com>,
	Djalal Harouni <tixxdz@opendz.org>
Subject: Re: Sending caps to userspace (Re: [GIT PULL] kdbus for 4.1-rc1)
Date: Thu, 16 Apr 2015 12:14:03 +0200	[thread overview]
Message-ID: <552F8B6B.2040902@zonque.org> (raw)
In-Reply-To: <CALCETrWXvXWVpdSRYDoYpHGsLWwc_+DGSpcEV2U1z_e8u9vzxw@mail.gmail.com>

On 04/15/2015 05:42 PM, Andy Lutomirski wrote:
> On Apr 15, 2015 5:00 AM, "Greg Kroah-Hartman"

> I looked.  AFAICT polkit doesn't use caps.  Systemd does (look for
> VTABLE_CAP and the associated code) for reasons that escape me.  I
> have yet to find a single cap-guarded method in the systemd code base
> that isn't also guarded by dbus policy and/or polkit.
>
> That latter part is important for two reasons.  Reason 1: the cap code
> doesn't seem to do anything, which makes it hard for me to break.
> (It's also spaghetti strung across lots of files, so I could be
> wrong.).

The sd-bus code in systemd uses the caps logic on the kdbus layer only.
On dbus1, caps aren't considered due to the obvious race gaps, hence the
code paths you looked are are ineffective in your setup.

> Reason 2: if the cap code isn't actually serving a security
> purpose, correctly or otherwise, why is it there?  Can't it just be
> deleted?

It is currently used for kdbus, and we've still not been given a
concrete reason why that's a bad idea.

The set of capabilities a task has set when it calls into the kernel is
authoritative, otherwise the kernel couldn't take it into account. If a
task or binary file is able to gain bits in the caps mask, that's a
problem of its own already, independent from kdbus.

The code in kdbus never adds any capabilities to anything, it doesn't
bump the receiver's caps or suchlike. All it does is taking the current
caps at the time of sending a message, and putting them into a metadata
item as passive information, so privileged userspace can take that as a
measure to make similar assumptions than a syscall handler would do.
Unlike cap_get_pid(), however, this transport doesn't suffer from the
described races.

We are aware of the issue user namespaces give a task more caps than its
parent has, but as explained, kdbus addresses that by dropping the
capability information from the metadata if the sender and the receiver
are in different user namespaces.

> Those other things are probably okay.  I actually tried setcap
> cap_sys_boot=eip dbus-send, and I still couldn't make systemctl reboot
> work in an ssh session.  In my book, that's a good thing.

Note that with kdbus, this will actually succeed, just as reboot(2)
called from a binary that has cap_sys_boot=eip succeeds.

We really don't insist in anything here, but we'd like to get a precise
technical reason of why you think this is an issue, with an example of
how current kdbus could be exploited.


Thanks,
Daniel


      reply	other threads:[~2015-04-16 10:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-15 15:42 Sending caps to userspace (Re: [GIT PULL] kdbus for 4.1-rc1) Andy Lutomirski
2015-04-16 10:14 ` Daniel Mack [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=552F8B6B.2040902@zonque.org \
    --to=daniel@zonque.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=dh.herrmann@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=teg@jklm.no \
    --cc=tixxdz@opendz.org \
    --cc=torvalds@linux-foundation.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