bus.h: add missing include to linux/kref.h

Symptoms:
> kdbus/bus.h:56:14: error: field ‘kref’ has incomplete type
>   struct kref kref;

Signed-off-by: Alban Crequy <alban.crequy@collabora.co.uk>
test: test-kdbus: fix monitor and byebye tests

Since commit 7015a1e6 ("prevent special-purpose connections from
owning names or exchanging messages"), ioctl() calls return
-EOPNOTSUPP they are issued to a handle of a inapproprate type.
Follow this change in the test as well.
names: flush policy TALK cache when a connection loses a name

When a connection loses a name, make sure cache entries that allow
TALK access to it are properly removed. Upon the next TALK query,
the connection's names will be iterated and checked again.
policy: rename send_access_hash to talk_access_hash

We've already renamed the SEND policy to TALK for more clarity,
so let's do the same with the access hash.
policy, connection: rename policy cache related functions

Just so they reflect a little better what they're doing.
metadata: add kdbus_meta_offset_of()

kdbus_meta_offset_of() will iterate over the given metadata and return
the offset of the item of type @type, if it exists.
connection, metadata: do namespace translation as late as possible

We have to do the namespace translation just before a message is
installed into the receiver's task, so we actually know about the
currently used pid and user namespaces.

To achive this, store the byte offset pointer in the message in
kdbus_conn_queue_alloc(), and patch the values over from
kdbus_conn_msg_install().

Thanks to Djalal Harouni for pointing this out.
metadata: allow NULL pointers in kdbus_meta_append_data()

Allow NULL pointers to be passed as data argument to
kdbus_meta_append_data(), so users can use the function to only make space
in the metadata without actually copying any payload.
connection, metadata: convert auxgrp information as late as possible

Same as with the cred block - do the from_kgid() conversion shortly before
installing the message in the receiver's task.
connection: fix error rewind exit path in kdbus_conn_msg_install()
handle: Return POLLOUT | POLLWRNORM mask when no messages are pending

To facility the feature of doing an asynchronous sending of messages
when the bus is idle, make sure to return POLLOUT | POLLWRNORM from
kdbus_handle_poll.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
metadata: rename kdbus_meta_offset_of() to kdbus_meta_find_item()

Return a pointer to the item itself, so we can as well use its size.
util: introduce KDBUS_ITEM_PAYLOAD_SIZE

Add a simple macro to determine an item's payload size, and use it in
message.c.
connection: address possible auxgrp count mismatch

The number of auxgrps could theoretically change between the preparation of
the the meta data item and the scan in kdbus_conn_queue_alloc().

Solve this by clamping the number of group elements we look at.
connection: drop unused paramenter to kdbus_conn_*_install

The connection parameter is not used, so drop it from the function's
parameters.
metadata: remove kdbus_meta_find_item()

Remove kdbus_meta_find_item(), and store offsets of items inside the
metadata in the metadata itself. This is nicer than walking the list again
in order to find a specific element.
metadata: set item->size in kdbus_meta_append_item()

This saves us some logic on the call sites.
metadata: follow 3.17 changes for current->start_time

As of Linux kernel commit 57e0be041d9e21a73 ("sched: Make
task->real_start_time nanoseconds based"), current->start_time is
stored in nanoseconds, so we don't need to do convert anymore.
switch to upstream kernel memfd implementation (ABI+API break)

Now that a generic memfd solution is merged upstream, drop our own
implementation and switch over.
test: adopt new memfd interface