kdbus.txt: fixes

Fix issues spotted by Greg.

Signed-off-by: Daniel Mack <daniel@zonque.org>
kdbus.txt: fix things spotted by Alban Crequy

Signed-off-by: Daniel Mack <daniel@zonque.org>
test-fd: ensure that broadcasting fds and memfds will fail with -ENOTUNIQ

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: test monitor connections for broadcast messages

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test-sync: ensure sync is interruptible and it ignors SA_RESTART flag

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
doc: KDBUS_MSG_FLAGS_SYNC_REPLY can be interrupted by a signal delivery

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
tests: strncpy() corrections

Use the correct maximum size with strncpy(), even though we're using
small static strings as sources.

Signed-off-by: Daniel Mack <daniel@zonque.org>
kdbus.h: add KDBUS_HELLO_ACCEPT_MEMFD (ABI break)

Add another flags to the connection's flags to denote whether it
want to receive memfds. Reject messages with -ECOMM if it contains
a memfd if the receiver can't cope with it.

Signed-off-by: Daniel Mack <daniel@zonque.org>
test-util: move RUN_UNPRIVILEGED definitions to kdbus-util.h

Will be used by other tests

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test-util: add test_is_capable() to check for capabilities and use it

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test-activator: add more tests for the activation logic

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
connection: use KDBUS_HELLO_ACCEPT_MEMFD to check for passed memfds

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
doc: document the new KDBUS_HELLO_ACCEPT_MEMFD flag

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
notify: set item->size

Fully initialize the API. We should also have strict checking for this
on userspace.

Signed-off-by: Daniel Mack <daniel@zonque.org>
bus.c: remove unneeded include

Signed-off-by: Daniel Mack <daniel@zonque.org>
domain: detroy IDRs

Signed-off-by: Daniel Mack <daniel@zonque.org>
metadata: update meta->attached once the attach succeeded

If we fail to append metadata items, but ignore the errors on purpose
for broadcast messages, we might end up with the same metadata multiple
times if we only update meta->attached wt the end of
kdbus_meta_append().

Hence, set each bit individually once the attachment succeeded.

Signed-off-by: Daniel Mack <daniel@zonque.org>
limits: lower KDBUS_MSG_MAX_FDS to 253

Lower the number of maximum file descriptors accepted as a message item
to 253. See commit bba14de98 (Linux) for the rationale behind that
number.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Revert KDBUS_HELLO_ACCEPT_MEMFD support (ABI break)

Memfds are a basic exchange mechanism not supposed to be
optional per connection. A per-bus flag, instead of a
per-connection one, would probably be acceptable,
but its usefulness is questionable at this point.

Broadcasts can contain memfds and we would silently messages
for such connections, which is not the expected behavior.

Receivers just need to make sure to be able to receive messages
with memfd payload, otherwise they are just not fully supporting
the common kdbus interface.

Contracts of not supporting memfds on private buses are fine,
but the general purpose communication will always require
memfds to be supported by all clients.
queue.c: move a stack variable before the variable array

This way the compiler doesn't have to calculate the location of the
pointer "on the fly".

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>