connection: document the quota limit of kernel notifications

Kernel is able to queue KDBUS_CONN_MAX_MSGS messages to a subscribed
connection. If the connection's queue is full, then no further message
delivery, notifications are lost.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
bus: document why in broadcast we do check for kernel notifications

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
endpoint: more documentation for kdbus_ep_policy_check_notification()

Document that if this is not a custom endpoint then no further check,
the message can be delivered.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: rewrite test logic so we can run all tests in each kdbusfs context

Rewrite the test logic, so we can embed the start_tests() in a new
kdbusfs and namespaces context.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test: show the error code of returned by KDBUS_CMD_BUS_MAKE ioctl

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
kdbus-test: rename run_test() functions to start_test() to avoid confusion

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

Signed-off-by: Daniel Mack <daniel@zonque.org>
domain: reference mount namespace

Record the mount namespace at the time of domain creation.
We don't take an active reference to it, because

a) there is no API to do so, and
b) we don't have to, as we're only using the pointer to compare
   mount namespaces, not do anything real with it.

In metadata, drop _EXE items if mount or PID namespaces are crossed.

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

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

Signed-off-by: Daniel Mack <daniel@zonque.org>
test: add more tests for custom endpoints

Test that unprivileged are not able to create custom endpoints

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
bus: document why we check conn_src owned names when doing broadcasts

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
endpoint: more documentation for kdbus_ep_policy_check_src_names()

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
endpoint: documentation code for kdbus_ep_policy_check_src_names()

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
endpoint: more fixes for kdbus_ep_policy_check_notification()

kdbus_ep_policy_check_notification() should return 0 if:
1) endpoint is not a custom endpoint
2) endpoint is a custom endpoint but the message is not a kernel
   notification
3) endpoint is a custom endpoint and the policy db allows the connection
   to see name changes notifications of the well-known name

It should fail if the policy db prevents receiving well-known name
notifications or if the message is a kernel notification of another
type, this prevents leaking other notifications to connections on custom
endpoint with a corresponding match.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
connection: monitor connections are disallowed on custom endpoints

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
test-endpoint: push the test case of monitors on custom endpoints

Monitors are disallowed on custom endpoints

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
kdbus.txt: KDBUS_HELLO_* flags are part of kdbus_cmd_hello struct so fix it

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
kdbus: if copy_from_user() do not return 0 fail with -EFAULT

Fix the following valid warnings for handle_ep_ioctl_connected()
and kdbus_meta_append_cmdline() reported by Dan Carpenter.

tree:
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git kdbus
head:   d064b29b452333d0e0ed6b9d2fc96b6e3917b1d7
commit: 0311aa1370e08cf0bf799a5f6e7ea29297cc3bdd [12/13] kdbus: add
Makefile, Kconfig and MAINTAINERS entry

ipc/kdbus/handle.c:736 handle_ep_ioctl_connected() warn: maybe return -EFAULT instead of the bytes remaining?
ipc/kdbus/metadata.c:376 kdbus_meta_append_cmdline() warn: maybe return -EFAULT instead of the bytes remaining?

git remote add char-misc git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
git remote update char-misc
git checkout 0311aa1370e08cf0bf799a5f6e7ea29297cc3bdd
vim +736 ipc/kdbus/handle.c

97149087 Daniel Mack 2014-09-11  720            ret = kdbus_negotiate_flags(&cmd_free, buf, typeof(cmd_free),
97149087 Daniel Mack 2014-09-11  721					    0);
97149087 Daniel Mack 2014-09-11  722            if (ret < 0)
97149087 Daniel Mack 2014-09-11  723                    break;
97149087 Daniel Mack 2014-09-11  724
97149087 Daniel Mack 2014-09-11  725            ret = kdbus_pool_release_offset(conn->pool, cmd_free.offset);
97149087 Daniel Mack 2014-09-11  726            break;
97149087 Daniel Mack 2014-09-11  727    }
97149087 Daniel Mack 2014-09-11  728
97149087 Daniel Mack 2014-09-11  729    default:
97149087 Daniel Mack 2014-09-11  730            ret = -ENOTTY;
97149087 Daniel Mack 2014-09-11  731            break;
97149087 Daniel Mack 2014-09-11  732    }
97149087 Daniel Mack 2014-09-11  733
97149087 Daniel Mack 2014-09-11  734    kdbus_conn_release(conn);
97149087 Daniel Mack 2014-09-11  735    kfree(free_ptr);
97149087 Daniel Mack 2014-09-11 @736    return ret;
97149087 Daniel Mack 2014-09-11  737  }
97149087 Daniel Mack 2014-09-11  738
97149087 Daniel Mack 2014-09-11  739  /* kdbus endpoint commands for endpoint owners */
97149087 Daniel Mack 2014-09-11  740  static long handle_ep_ioctl_owner(struct file *file, unsigned int cmd,
97149087 Daniel Mack 2014-09-11  741                              void __user *buf)
97149087 Daniel Mack 2014-09-11  742  {
97149087 Daniel Mack 2014-09-11  743    struct kdbus_handle_ep *handle = file->private_data;
97149087 Daniel Mack 2014-09-11  744    struct kdbus_ep *ep = handle->ep_owner;

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
Changelog: update

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