linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.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 API <linux-api@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Daniel Mack <daniel@zonque.org>,
	Djalal Harouni <tixxdz@opendz.org>
Subject: Re: [PATCH v4 00/14] Add kdbus implementation
Date: Mon, 30 Mar 2015 18:56:44 +0200	[thread overview]
Message-ID: <CANq1E4TTt3qanQse30KOZsuo2tfNoj7YSueh3AZ7bY1nQQeZNA@mail.gmail.com> (raw)
In-Reply-To: <CALCETrUuWhtJ9w9vyCGgaJDMGithJad4A4wf-BuxWLb_af5eDg@mail.gmail.com>

Hi

On Wed, Mar 25, 2015 at 7:12 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> On Wed, Mar 25, 2015 at 10:29 AM, David Herrmann <dh.herrmann@gmail.com> wrote:
[...]
>>> I could be wrong about the lack of use cases.  If so, please enlighten me.
>>
>> We have several dbus APIs that allow clients to register as a special
>> handler/controller/etc. (eg., see systemd-logind TakeControl()). The
>> API provider checks the privileges of a client on registration and
>> then just tracks the client ID. This way, the client can be privileged
>> when asking for special access, then drop privileges and still use the
>> interface. You cannot re-connect in between, as the API provider
>> tracks your bus ID. Without message-metadata, all your (other) calls
>> on this bus would always be treated as privileged. We *really* want to
>> avoid this.
>
> Connect twice?

The remote peer might cache your connection ID to track you. You have
to use the same connection to talk to that peer, in this given
scenario. That's how D-Bus1 is used today, and we have to follow the
semantics.

> You *already* have to reconnect or connect twice because you have
> per-connection metadata.  That's part of my problem with this scheme
> -- you support *both styles*, which seems like it'll give you most of
> the downsides of both without the upsides.

Not necessarily. Connection metadata describes the state at the time
you connected to the bus. If someone ask for this information, they
will get exactly that. In this model, you cannot drop privileges, if
you need to be privileged during setup.
If someone asks for per-message metadata, they better ought not ask
for per-connection creds. It's not the information they're looking
for, so it will not match the data that at the time the message was
sent.

There is no immediate need to make both match. For security decisions,
we mandate per-message creds. Per-connection creds are for
backwards-compatibility to dbus1 and for passive introspection of bus
connections.

>>
>> Another example is logging, where we want exact data at the time a
>> message is logged. Otherwise, the data is useless.
>
> Why?
>
> No, really, why is exact data at the time of logging so important?  It
> sounds nice, but I really don't see it.

Example: If you don't have message-metadata, you don't know the thread
which sent a log-message. In a multi-threaded application, that's
incredibly useful information.

After all, logging is all about correct data. Logging creds that were
not effective at the time the message was sent is futile.

>>
>> kdbus is a _bus_, not a p2p channel. Thus, a peer may talk to multiple
>> destinations, and it may want to look different to each of them. DBus
>> method-calls allow 'syscall'-ish behavior when calling into other
>> processes. We *want* to be able to drop privileges after doing process
>> setup. We want further bus-calls to no longer be treated privileged.
>
> You could have an IOCTL that re-captures your connection metata.

I don't see how this makes the model easier, or more predictable. On
the contrary, per-connection metadata is no longer compatible to UDS /
dbus1, nor is a per-message metadata concept reliable.

>>
>> Furthermore, DBus was designed to allow peers to track other peers
>> (which is why it always had the NameOwnerChanged signal). This is an
>> essential feature, that simplifies access-management considerably, as
>> you can cache it together with the unique name of a peer. We only open
>> a single connection to a bus. glib, libdbus, efl, ell, qt, sd-bus, and
>> others use cached bus-connections that are shared by all code of a
>> single thread. Hence, the bus connection is kinda part of the process
>> itself, like stdin/stdout. Without message-metadata, it is impossible
>> to ever drop privileges on a bus, without losing all state.
>
> See above about an IOCTL that re-captures your connection metadata.
>
> Again, you seem to be arguing that per-connection metadata is bad, but
> you still have an implementation of per-connection metadata, so you
> still have all these problems.

I don't see why we get the problems of per-connection metadata. Just
because you _can_ use it, doesn't mean you should use it for all
imaginable use-cases. The same goes for reading information from
/proc. There are valid use-cases to do so, but also a lot of cases
where it will not provide the information you want.

> I'm actually okay with per-message metadata in principle, but I'd like
> to see evidence (with numbers, please) that a send+recv of per-message
> metadata is *not* significantly slower than a recv of already-captured
> per-connection metadata.  If this is in fact the case, then maybe you
> should trash per-connection metadata instead and the legacy
> compatibility code can figure out a way to deal with it.  IMO that
> would be a pretty nice outcome, since you would never have to worry
> whether your connection to the bus is inadvertantly privileged.

Per-message metadata makes SEND about 25% slower, if you transmit the
full set of all possible information. Just 3% if you only use
PIDs+UIDs. The expensive metadata is cgroup-path and exe-path.
If a service needs that information, however, and if that information
is not guaranteed to be up-to-date, the service _will_ go and look it
up in /proc or somewhere else, which is certainly a whole lot more
expensive than the code in kdbus.

In general, there seems to be a number of misconception in this thread
about what kdbus is supposed to be. We're not inventing something new
here with a clean slate, but we're moving parts of an existing
implementation that has tons of users into the kernel, in order to fix
issues that cannot be fixed otherwise in userspace (most notably, the
race gaps that exist when retrieving per-message metadata). Therefore,
we have to keep existing semantics stable, otherwise the exercise is
somewhat pointless.

Thanks
David

  reply	other threads:[~2015-03-30 16:56 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-09 13:09 [PATCH v4 00/14] Add kdbus implementation Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 01/14] kdbus: add documentation Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 02/14] kdbus: add uapi header file Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 03/14] kdbus: add driver skeleton, ioctl entry points and utility functions Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 04/14] kdbus: add connection pool implementation Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 05/14] kdbus: add connection, queue handling and message validation code Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 06/14] kdbus: add node and filesystem implementation Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 07/14] kdbus: add code to gather metadata Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 08/14] kdbus: add code for notifications and matches Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 09/14] kdbus: add code for buses, domains and endpoints Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 10/14] kdbus: add name registry implementation Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 11/14] kdbus: add policy database implementation Greg Kroah-Hartman
2015-03-09 13:09 ` [PATCH 12/14] kdbus: add Makefile, Kconfig and MAINTAINERS entry Greg Kroah-Hartman
2015-03-24 15:15   ` Jiri Slaby
2015-03-24 18:51     ` [PATCH] kdbus: Fix CONFIG_KDBUS help text Daniel Mack
2015-03-25  1:05       ` David Herrmann
2015-03-25  9:51       ` Greg KH
2015-03-09 13:09 ` [PATCH 13/14] kdbus: add walk-through user space example Greg Kroah-Hartman
2015-03-12 14:52   ` Sasha Levin
2015-03-12 16:27     ` [PATCH] samples/kdbus: add -lrt David Herrmann
2015-03-12 21:40       ` [PATCH] kdbus: " Greg Kroah-Hartman
2015-03-12 16:34     ` [PATCH 13/14] kdbus: add walk-through user space example David Herrmann
2015-03-24 16:46   ` Jiri Slaby
2015-03-24 17:15     ` David Herrmann
2015-03-24 17:37       ` Jiri Slaby
2015-03-24 18:22         ` Michal Marek
2015-03-24 18:51           ` Daniel Mack
2015-03-31 13:11         ` [PATCH] samples: kdbus: build kdbus-workers conditionally Daniel Mack
2015-04-01 12:47           ` Greg KH
2015-04-01 21:41             ` Andrew Morton
2015-04-03 11:02               ` Daniel Mack
2015-03-09 13:09 ` [PATCH 14/14] kdbus: add selftests Greg Kroah-Hartman
2015-03-15  5:13 ` [PATCH] kdbus: fix minor typo in the walk-through example Nicolas Iooss
2015-03-15  9:32   ` Greg KH
2015-03-17 19:24 ` [PATCH v4 00/14] Add kdbus implementation Andy Lutomirski
2015-03-18 13:54   ` David Herrmann
2015-03-18 18:24     ` Andy Lutomirski
2015-03-19 11:26       ` David Herrmann
2015-03-19 15:48         ` Andy Lutomirski
2015-03-23 15:28           ` David Herrmann
2015-03-23 23:24             ` Andy Lutomirski
2015-03-24  0:20               ` Eric W. Biederman
2015-03-25 17:29               ` David Herrmann
2015-03-25 18:12                 ` Andy Lutomirski
2015-03-30 16:56                   ` David Herrmann [this message]
2015-03-31 13:58                     ` Andy Lutomirski
2015-03-31 15:10                       ` Tom Gundersen
2015-03-31 18:29                         ` Andy Lutomirski
2015-04-03 11:51                           ` David Herrmann
2015-04-05 12:09                             ` Eric W. Biederman
2015-04-05 13:46                               ` Greg Kroah-Hartman
2015-04-08 22:38                             ` Andy Lutomirski

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=CANq1E4TTt3qanQse30KOZsuo2tfNoj7YSueh3AZ7bY1nQQeZNA@mail.gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=arnd@arndb.de \
    --cc=daniel@zonque.org \
    --cc=ebiederm@xmission.com \
    --cc=gnomes@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkosina@suse.cz \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=teg@jklm.no \
    --cc=tixxdz@opendz.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).