connection: remove duplicate variable declaration
metadata: reflect change in task_cgroup_name

Change: e61734c55c24cdf11b07e52a74aec4dc4a7f4bd0.
Merged: dc5ed40686a4da95881c35d913b60f867755cbe2 in 3.15-rc1.

task_cgroup_name returns a pointer to the path or NULL if there is not
enough space in the buffer (used to return nonnegative or
-ENAMETOOLONG).

On systemd systems fixes a kernel panic about init dying while opening a
bus. Now it boots properly.
connection: return ESRCH for unknown names consistently

We use ESRCH for unknown names except in GET_CONN_INFO. That's misleading
and makes error forwarding error prone. Fix that and use ESRCH instead of
ENOENT.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection: dont modify msg in case of errors in kdbus_conn_get_conn_dst

We shouldn't modify the message before we decided whether to fail or not.
Keep the name-id local and write it only after we checked for all errors.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
names: fix kdbus_name_lookup() race condition

We cannot return pointers to the internal name registry from
kdbus_name_lookup(). No-one guarantees that these entries will stay valid.
Therefore, return the requested information directly with proper
references. This is protected by locks in kdbus_name_lookup() itself and
thus is safe.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
names: fix kdbus_name_lookup() to not ref NULL conns (ABI break)

The previous kdbus_name_lookup() fix assumed kdbus_conn_ref(NULL) is a
no-op. Turns out, it's a panic-op instead... Fix it.

Also add the ABI-break annotation as the previous error-code change
requires new systemd user-space (fixed by Kay).

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus: fix 'canceled' typo

'canceled' -> 'cancelled'

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection: simplify cmd_conn_info()

We only have one path setting 'name'. There's no reason to split
name-handling, so merge them back together.

Also fix a bug where we access the name _before_ checking for strlen.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
handle notify messages in a bus list to preserve bus-global ordering
names: turn registry lock into rwsem

Imagine a racing name-acquire and msg-send. The msg-send might lookup the
destination name, which might be an activator. But before it can queue the
message, the racing name-acquire installs and implementor and moves all
pending messages from the activator to the implementor. If the original
msg-send afterwards continues, it will still queue the in-flight message
on the activator instead of the implementor.

After 1 day of discussion, we decided on turning the registry into a
read-write lock. This way, any msg-send will be locked against
name-changes. A name-change requires a writer lock, but any in-flight
message will hold a regsitry read-lock from the name-lookup until it
queued the message.

This patch only converts the lock, following patches will close the races.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
connection: keep names locked while sending messages

If we send messages and we look up well-known names, we must keep them
locked until we're done. Otherwise, the name might move to another
connection before we queue it on the resolved name.

This fixes the sending path to lock names for the entire function call.
Name-movements already lock the name-registry for the entire move, so we
should be fine now.

We also inline the lookup-helper, as it is only used once and will get
messy if we return kdbus_name_entry objects.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Merge remote-tracking branch 'kdbus/master' into 3.14/kdbus