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>
test: add helpers for user namespace mapping

Will be used by other tests.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: move shared definitions to kdbus-util.h to use them in other tests

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: add conn_recv() that use poll() and msg_recv()

Will be used by tests.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: add the metadata tests inside new namespaces

Currently this only handles user namespace. Use it to inspect the
dumped metadata/credentials.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
Makefile: export KERNELDIR for tests

We include linux/memfd.h now, make sure it's searched for in $KERNELDIR.
Makefile: deal with realtive paths in test/

Invoke realpath to convert a possible relative path into an absolute one.
test/Makefile: only look at $(KERNELDIR)/usr/include for files with quotes

This is a hack to make cpp look at system include files first, and then
consult $(KERNELDIR)/usr/include. For this to work, include directives
referring to files in uapi have to be addressed with quotes.
Revert "test/Makefile: only look at $(KERNELDIR)/usr/include for files with quotes"

This reverts commit baeb2d8bbf2360524d4104ea851407a14085cef9.

Turns out this confuses cpp even more.

For now, people have to to 'make headers_install' in the kernel dir before
building kdbus.
metadata: add back code to fill creds data

It was overlooked that metadata is also used for connection info calls.
Until we find a nicer way, just do the creds assigment in this item twice:
once at metadata creation time, and again when we deliver the message.
kdbus: do the audit loginuid translation as late as possible

Do the namespace translation just before pushing into the receiver's
slice, so we map to the receiver's user namespace.

Patch tested.

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