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
Kconfig: depend on TMPFS
metadata: drop support for kernels < v3.15
handle: return POLLOUT | POLLWRNORM from kdbus_handle_poll()

Also return POLLOUT | POLLWRNORM from kdbus_handle_poll() when a message
arrived. IOW: in all non-error conditions.
metadata: document creds_item_off and auxgrps_item_off fields

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
connection: move the install creds into the slice to its own function

Move the install creds into the receiver's slice to its own function
kdbus_conn_creds_install().

Use from_kuid_munged(), so the uid mapping never fails.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>