kdbus.h: add return_flags to all struct kdbus_cmd_* (ABI break)

Add a return_flags field to all cmd structs, in which the kernel can
return certain flags later. This commit doesn't add any users of it.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: make monitors invisible on the bus

Signed-off-by: Daniel Mack <daniel@zonque.org>
test-monitor: remove 2nd message recv

Now that the monitor doesn't get its own 'ID_ADDED' signal anymore, the
previously necessary hack can go away.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: a reply must have a punched hole in the destination conn

When a reply is sent, make sure the destination is actually waiting for
one. If it isn't, don't fall back to normal policy checks, but reject
the message.

Signed-off-by: Daniel Mack <daniel@zonque.org>
test-sync: verify wrong reply cookie behavior

When a reply is sent with a wrong cookie, the message send must fail.

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

Add a field for the kernel to return flags upon receiving a message.

Signed-off-by: Daniel Mack <daniel@zonque.org>
kdbus.h: add enum kdbus_recv_return_flags

Add an enum for RECV and sync-SEND ioctls, and make the kernel reports
failures in installing file descriptors in a received message.

The message will be received by userspace nevertheless, with return
code 0, but the fds that failed to get installed will have the value -1,
and KDBUS_RECV_RETURN_INCOMPLETE_FDS is set in the reply's return_flags.

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: move comment block

The comment block feels a little misplaced. Move it around to make it
fit better into context.

Signed-off-by: Daniel Mack <daniel@zonque.org>
bus, connection, message: reject unhandled items

We ought reject items in structs that we don't make use of, so we can
add items later that change the behavior of the kernel part.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Changelog: add some more details

Signed-off-by: Daniel Mack <daniel@zonque.org>
connection: remove notification on monitor disconnect

since monitor should be invisible and do not send any notification on
connection, the same should be done in the disconnect.

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
test-monitor: test stealth mode of monitor

add check to make sure that we do not receive notification about a monitor
connecting or disconnect through the ITEM_ADD and ITEM_REMOVE.

Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
metadata: add support for PPID

Add PPID to kdbus_pids and test that they're properly converted.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus: re-order payload declarations

The diff looks scarier than it is: This moves kdbus_xyz items _before_
their kdbus_cmd_xyz user. We don't directly embed those in the cmd
structures, but we would, if we could. So lets keep the logical order and
move them before their user.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus: add comment about payload types

Clarify that any payload type is allowed. We will just add further
payloads once they are established in user-space and everyone agrees on
them.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus: KDBUS_MSG_FLAGS_* -> KDBUS_MSG_*

Drop the _FLAGS_ part of the message flags constants. We don't use it
anywhere else, so lets be consistent and drop it here, too.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus: be paranoid and avoid kernel stack information leaks

Lets initialize all our temporary variables to 0 so any memcpy() does not
leak kernel information. Furthermore, initialize allocated meta-buffers to
zero to not leak padding bytes.

Note that we still rely on all our external objects to _not_ have padding
bytes, otherwise, a simple initialization would leave them untouched and
we'd have to use memset().

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus: rename cmd_name_list.size to cmd_name_list.list_size

Avoid generic 'size' names in ioctl structs. Rename it to list_size so we
can add a 'size'+'items' combination in a followup.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
kdbus: add items to kdbus_cmd_name_list

Make kdbus_cmd_name_list future proof and add items. This way we can
extend the ioctl easily in the future.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
item: cosmetic alignment fix

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