Skip to contentSkip to conversation

Add kdbus implementation

PATCH Superseded Greg Kroah-Hartman 15 participants 86 messages Jan 16, 2015 – Feb 8, 2015 Page 2 of 2

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#64 lore raw

PATCH v3 10/13 kdbus: add name registry implementation

In reply to Greg Kroah-Hartman

From: Daniel Mack <[email protected]>

This patch adds the name registry implementation.

Each bus instantiates a name registry to resolve well-known names into unique connection IDs for message delivery. The registry will be queried when a message is sent with kdbus_msg.dst_id set to KDBUS_DST_ID_NAME, or when a registry dump is requested.

It's important to have this registry implemented in the kernel to implement lookups and take-overs in a race-free way.

---
 ipc/kdbus/names.c | 891 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 ipc/kdbus/names.h |  82 +++++
 2 files changed, 973 insertions(+)
 create mode 100644 ipc/kdbus/names.c
 create mode 100644 ipc/kdbus/names.h
ipc/kdbus/names.c new file +891 -0
new file mode 100644
index 000000000000..f8a69c249e17
@@ -0,0 +1,891 @@
+/*
+ * Copyright (C) 2013-2014 Kay Sievers
+ * Copyright (C) 2013-2014 Greg Kroah-Hartman <[email protected]>
+ * Copyright (C) 2013-2014 Daniel Mack <[email protected]>
+ * Copyright (C) 2013-2014 David Herrmann <[email protected]>
+ * Copyright (C) 2013-2014 Linux Foundation
+ * Copyright (C) 2014 Djalal Harouni <[email protected]>
+ *
+ * kdbus is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ */
+
+#include <linux/ctype.h>
+#include <linux/fs.h>
+#include <linux/hash.h>
+#include <linux/idr.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/rwsem.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+#include <linux/uio.h>
+
+#include "bus.h"
+#include "connection.h"
+#include "endpoint.h"
+#include "item.h"
+#include "names.h"
+#include "notify.h"
+#include "policy.h"
+
+/**
+ * struct kdbus_name_queue_item - a queue item for a name
+ * @conn:		The associated connection
+ * @entry:		Name entry queuing up for
+ * @entry_entry:	List element for the list in @entry
+ * @conn_entry:		List element for the list in @conn
+ * @flags:		The queuing flags
+ */
+struct kdbus_name_queue_item {
+	struct kdbus_conn *conn;
+	struct kdbus_name_entry *entry;
+	struct list_head entry_entry;
+	struct list_head conn_entry;
+	u64 flags;
+};
+
+static void kdbus_name_entry_free(struct kdbus_name_entry *e)
+{
+	hash_del(&e->hentry);
+	kfree(e->name);
+	kfree(e);
+}
+
+/**
+ * kdbus_name_registry_free() - drop a name reg's reference
+ * @reg:		The name registry, may be %NULL
+ *
+ * Cleanup the name registry's internal structures.
+ */
+void kdbus_name_registry_free(struct kdbus_name_registry *reg)
+{
+	struct kdbus_name_entry *e;
+	struct hlist_node *tmp;
+	unsigned int i;
+
+	if (!reg)
+		return;
+
+	hash_for_each_safe(reg->entries_hash, i, tmp, e, hentry)
+		kdbus_name_entry_free(e);
+
+	kfree(reg);
+}
+
+/**
+ * kdbus_name_registry_new() - create a new name registry
+ *
+ * Return: a new kdbus_name_registry on success, ERR_PTR on failure.
+ */
+struct kdbus_name_registry *kdbus_name_registry_new(void)
+{
+	struct kdbus_name_registry *r;
+
+	r = kzalloc(sizeof(*r), GFP_KERNEL);
+	if (!r)
+		return ERR_PTR(-ENOMEM);
+
+	hash_init(r->entries_hash);
+	init_rwsem(&r->rwlock);
+
+	return r;
+}
+
+static struct kdbus_name_entry *
+kdbus_name_lookup(struct kdbus_name_registry *reg, u32 hash, const char *name)
+{
+	struct kdbus_name_entry *e;
+
+	hash_for_each_possible(reg->entries_hash, e, hentry, hash)
+		if (strcmp(e->name, name) == 0)
+			return e;
+
+	return NULL;
+}
+
+static void kdbus_name_queue_item_free(struct kdbus_name_queue_item *q)
+{
+	list_del(&q->entry_entry);
+	list_del(&q->conn_entry);
+	kfree(q);
+}
+
+/*
+ * The caller must hold the lock so we decrement the counter and
+ * delete the entry.
+ *
+ * The caller needs to hold its own reference, so the connection does not go
+ * away while the entry's reference is dropped under lock.
+ */
+static void kdbus_name_entry_remove_owner(struct kdbus_name_entry *e)
+{
+	if (WARN_ON(!e->conn))
+		return;
+
+	if (WARN_ON(!mutex_is_locked(&e->conn->lock)))
+		return;
+
+	atomic_dec(&e->conn->name_count);
+	list_del(&e->conn_entry);
+	e->conn = kdbus_conn_unref(e->conn);
+}
+
+static void kdbus_name_entry_set_owner(struct kdbus_name_entry *e,
+				       struct kdbus_conn *conn)
+{
+	if (WARN_ON(e->conn))
+		return;
+
+	if (WARN_ON(!mutex_is_locked(&conn->lock)))
+		return;
+
+	e->conn = kdbus_conn_ref(conn);
+	atomic_inc(&conn->name_count);
+	list_add_tail(&e->conn_entry, &e->conn->names_list);
+}
+
+static int kdbus_name_replace_owner(struct kdbus_name_entry *e,
+				    struct kdbus_conn *conn, u64 flags)
+{
+	struct kdbus_conn *conn_old = kdbus_conn_ref(e->conn);
+	int ret = 0;
+
+	if (WARN_ON(conn == conn_old))
+		return -EALREADY;
+
+	if (WARN_ON(!conn_old))
+		return -EINVAL;
+
+	kdbus_conn_lock2(conn, conn_old);
+
+	if (!kdbus_conn_active(conn)) {
+		ret = -ECONNRESET;
+		goto exit_unlock;
+	}
+
+	kdbus_notify_name_change(conn->ep->bus, KDBUS_ITEM_NAME_CHANGE,
+				 e->conn->id, conn->id,
+				 e->flags, flags, e->name);
+
+	/* hand over name ownership */
+	kdbus_name_entry_remove_owner(e);
+	kdbus_name_entry_set_owner(e, conn);
+	e->flags = flags;
+
+exit_unlock:
+	kdbus_conn_unlock2(conn, conn_old);
+	kdbus_conn_unref(conn_old);
+	return ret;
+}
+
+static int kdbus_name_entry_release(struct kdbus_name_entry *e)
+{
+	struct kdbus_conn *conn;
+	int ret;
+
+	/* give it to first active waiter in the queue */
+	while (!list_empty(&e->queue_list)) {
+		struct kdbus_name_queue_item *q;
+
+		q = list_first_entry(&e->queue_list,
+				     struct kdbus_name_queue_item,
+				     entry_entry);
+
+		ret = kdbus_name_replace_owner(e, q->conn, q->flags);
+		if (ret < 0)
+			continue;
+
+		kdbus_name_queue_item_free(q);
+		return 0;
+	}
+
+	/* hand it back to an active activator connection */
+	if (e->activator && e->activator != e->conn) {
+		u64 flags = KDBUS_NAME_ACTIVATOR;
+
+		/*
+		 * Move messages still queued in the old connection
+		 * and addressed to that name to the new connection.
+		 * This allows a race and loss-free name and message
+		 * takeover and exit-on-idle services.
+		 */
+		ret = kdbus_conn_move_messages(e->activator, e->conn,
+					       e->name_id);
+		if (ret < 0)
+			return ret;
+
+		return kdbus_name_replace_owner(e, e->activator, flags);
+	}
+
+	/* release the name */
+	kdbus_notify_name_change(e->conn->ep->bus, KDBUS_ITEM_NAME_REMOVE,
+				 e->conn->id, 0, e->flags, 0, e->name);
+
+	conn = kdbus_conn_ref(e->conn);
+	mutex_lock(&conn->lock);
+	kdbus_name_entry_remove_owner(e);
+	mutex_unlock(&conn->lock);
+	kdbus_conn_unref(conn);
+
+	kdbus_name_entry_free(e);
+
+	return 0;
+}
+
+static int kdbus_name_release(struct kdbus_name_registry *reg,
+			      struct kdbus_conn *conn,
+			      const char *name)
+{
+	struct kdbus_name_queue_item *tmp, *q;
+	struct kdbus_name_entry *e = NULL;
+	int ret = -ESRCH;
+	u32 hash;
+
+	hash = kdbus_strhash(name);
+
+	/* lock order: domain -> bus -> ep -> names -> connection */
+	mutex_lock(&conn->ep->bus->lock);
+	down_write(&reg->rwlock);
+
+	e = kdbus_name_lookup(reg, hash, name);
+	if (!e)
+		goto exit_unlock;
+
+	/* Is the connection already the real owner of the name? */
+	if (e->conn == conn) {
+		ret = kdbus_name_entry_release(e);
+	} else {
+		/*
+		 * Otherwise, walk the list of queued entries and search
+		 * for items for connection.
+		 */
+
+		list_for_each_entry_safe(q, tmp, &e->queue_list, entry_entry) {
+			if (q->conn != conn)
+				continue;
+
+			kdbus_name_queue_item_free(q);
+			ret = 0;
+			break;
+		}
+	}
+
+exit_unlock:
+	up_write(&reg->rwlock);
+	mutex_unlock(&conn->ep->bus->lock);
+
+	return ret;
+}
+
+/**
+ * kdbus_name_remove_by_conn() - remove all name entries of a given connection
+ * @reg:		The name registry
+ * @conn:		The connection which entries to remove
+ *
+ * This function removes all name entry held by a given connection.
+ */
+void kdbus_name_remove_by_conn(struct kdbus_name_registry *reg,
+			       struct kdbus_conn *conn)
+{
+	struct kdbus_name_queue_item *q_tmp, *q;
+	struct kdbus_conn *activator = NULL;
+	struct kdbus_name_entry *e_tmp, *e;
+	LIST_HEAD(names_queue_list);
+	LIST_HEAD(names_list);
+
+	/* lock order: domain -> bus -> ep -> names -> conn */
+	mutex_lock(&conn->ep->bus->lock);
+	down_write(&reg->rwlock);
+
+	mutex_lock(&conn->lock);
+	list_splice_init(&conn->names_list, &names_list);
+	list_splice_init(&conn->names_queue_list, &names_queue_list);
+	mutex_unlock(&conn->lock);
+
+	if (kdbus_conn_is_activator(conn)) {
+		activator = conn->activator_of->activator;
+		conn->activator_of->activator = NULL;
+	}
+	list_for_each_entry_safe(q, q_tmp, &names_queue_list, conn_entry)
+		kdbus_name_queue_item_free(q);
+	list_for_each_entry_safe(e, e_tmp, &names_list, conn_entry)
+		kdbus_name_entry_release(e);
+
+	up_write(&reg->rwlock);
+	mutex_unlock(&conn->ep->bus->lock);
+
+	kdbus_conn_unref(activator);
+	kdbus_notify_flush(conn->ep->bus);
+}
+
+/**
+ * kdbus_name_lock() - look up a name in a name registry and lock it
+ * @reg:		The name registry
+ * @name:		The name to look up
+ *
+ * Search for a name in a given name registry and return it with the
+ * registry-lock held. If the object is not found, the lock is not acquired and
+ * NULL is returned. The caller is responsible of unlocking the name via
+ * kdbus_name_unlock() again. Note that kdbus_name_unlock() can be safely called
+ * with NULL as name. In this case, it's a no-op as nothing was locked.
+ *
+ * The *_lock() + *_unlock() logic is only required for callers that need to
+ * protect their code against concurrent activator/implementer name changes.
+ * Multiple readers can lock names concurrently. However, you may not change
+ * name-ownership while holding a name-lock.
+ *
+ * Return: NULL if name is unknown, otherwise return a pointer to the name
+ *         entry with the name-lock held (reader lock only).
+ */
+struct kdbus_name_entry *kdbus_name_lock(struct kdbus_name_registry *reg,
+					 const char *name)
+{
+	struct kdbus_name_entry *e = NULL;
+	u32 hash = kdbus_strhash(name);
+
+	down_read(&reg->rwlock);
+	e = kdbus_name_lookup(reg, hash, name);
+	if (e)
+		return e;
+	up_read(&reg->rwlock);
+
+	return NULL;
+}
+
+/**
+ * kdbus_name_unlock() - unlock one name in a name registry
+ * @reg:		The name registry
+ * @entry:		The locked name entry or NULL
+ *
+ * This is the unlock-counterpart of kdbus_name_lock(). It unlocks a name that
+ * was previously successfully locked. You can safely pass NULL as entry and
+ * this will become a no-op. Therefore, it's safe to always call this on the
+ * return-value of kdbus_name_lock().
+ *
+ * Return: This always returns NULL.
+ */
+struct kdbus_name_entry *kdbus_name_unlock(struct kdbus_name_registry *reg,
+					   struct kdbus_name_entry *entry)
+{
+	if (entry) {
+		BUG_ON(!rwsem_is_locked(&reg->rwlock));
+		up_read(&reg->rwlock);
+	}
+
+	return NULL;
+}
+
+static int kdbus_name_queue_conn(struct kdbus_conn *conn, u64 flags,
+				 struct kdbus_name_entry *e)
+{
+	struct kdbus_name_queue_item *q;
+
+	q = kzalloc(sizeof(*q), GFP_KERNEL);
+	if (!q)
+		return -ENOMEM;
+
+	q->conn = conn;
+	q->flags = flags;
+	q->entry = e;
+
+	list_add_tail(&q->entry_entry, &e->queue_list);
+	list_add_tail(&q->conn_entry, &conn->names_queue_list);
+
+	return 0;
+}
+
+/**
+ * kdbus_name_is_valid() - check if a name is valid
+ * @p:			The name to check
+ * @allow_wildcard:	Whether or not to allow a wildcard name
+ *
+ * A name is valid if all of the following criterias are met:
+ *
+ *  - The name has two or more elements separated by a period ('.') character.
+ *  - All elements must contain at least one character.
+ *  - Each element must only contain the ASCII characters "[A-Z][a-z][0-9]_-"
+ *    and must not begin with a digit.
+ *  - The name must not exceed KDBUS_NAME_MAX_LEN.
+ *  - If @allow_wildcard is true, the name may end on '.*'
+ */
+bool kdbus_name_is_valid(const char *p, bool allow_wildcard)
+{
+	bool dot, found_dot = false;
+	const char *q;
+
+	for (dot = true, q = p; *q; q++) {
+		if (*q == '.') {
+			if (dot)
+				return false;
+
+			found_dot = true;
+			dot = true;
+		} else {
+			bool good;
+
+			good = isalpha(*q) || (!dot && isdigit(*q)) ||
+				*q == '_' || *q == '-' ||
+				(allow_wildcard && dot &&
+					*q == '*' && *(q + 1) == '\0');
+
+			if (!good)
+				return false;
+
+			dot = false;
+		}
+	}
+
+	if (q - p > KDBUS_NAME_MAX_LEN)
+		return false;
+
+	if (dot)
+		return false;
+
+	if (!found_dot)
+		return false;
+
+	return true;
+}
+
+/**
+ * kdbus_name_acquire() - acquire a name
+ * @reg:		The name registry
+ * @conn:		The connection to pin this entry to
+ * @name:		The name to acquire
+ * @flags:		Acquisition flags (KDBUS_NAME_*)
+ *
+ * Callers must ensure that @conn is either a privileged bus user or has
+ * sufficient privileges in the policy-db to own the well-known name @name.
+ *
+ * Return: 0 success, negative error number on failure.
+ */
+int kdbus_name_acquire(struct kdbus_name_registry *reg,
+		       struct kdbus_conn *conn,
+		       const char *name, u64 *flags)
+{
+	struct kdbus_name_entry *e = NULL;
+	int ret = 0;
+	u32 hash;
+
+	/* lock order: domain -> bus -> ep -> names -> conn */
+	mutex_lock(&conn->ep->bus->lock);
+	down_write(&reg->rwlock);
+
+	hash = kdbus_strhash(name);
+	e = kdbus_name_lookup(reg, hash, name);
+	if (e) {
+		/* connection already owns that name */
+		if (e->conn == conn) {
+			ret = -EALREADY;
+			goto exit_unlock;
+		}
+
+		if (kdbus_conn_is_activator(conn)) {
+			/* An activator can only own a single name */
+			if (conn->activator_of) {
+				if (conn->activator_of == e)
+					ret = -EALREADY;
+				else
+					ret = -EINVAL;
+			} else if (!e->activator && !conn->activator_of) {
+				/*
+				 * Activator registers for name that is
+				 * already owned
+				 */
+				e->activator = kdbus_conn_ref(conn);
+				conn->activator_of = e;
+			}
+
+			goto exit_unlock;
+		}
+
+		/* take over the name of an activator connection */
+		if (e->flags & KDBUS_NAME_ACTIVATOR) {
+			/*
+			 * Take over the messages queued in the activator
+			 * connection, the activator itself never reads them.
+			 */
+			ret = kdbus_conn_move_messages(conn, e->activator, 0);
+			if (ret < 0)
+				goto exit_unlock;
+
+			ret = kdbus_name_replace_owner(e, conn, *flags);
+			goto exit_unlock;
+		}
+
+		/* take over the name if both parties agree */
+		if ((*flags & KDBUS_NAME_REPLACE_EXISTING) &&
+		    (e->flags & KDBUS_NAME_ALLOW_REPLACEMENT)) {
+			/*
+			 * Move name back to the queue, in case we take it away
+			 * from a connection which asked for queuing.
+			 */
+			if (e->flags & KDBUS_NAME_QUEUE) {
+				ret = kdbus_name_queue_conn(e->conn,
+							    e->flags, e);
+				if (ret < 0)
+					goto exit_unlock;
+			}
+
+			ret = kdbus_name_replace_owner(e, conn, *flags);
+			goto exit_unlock;
+		}
+
+		/* add it to the queue waiting for the name */
+		if (*flags & KDBUS_NAME_QUEUE) {
+			ret = kdbus_name_queue_conn(conn, *flags, e);
+			if (ret < 0)
+				goto exit_unlock;
+
+			/* tell the caller that we queued it */
+			*flags |= KDBUS_NAME_IN_QUEUE;
+
+			goto exit_unlock;
+		}
+
+		/* the name is busy, return a failure */
+		ret = -EEXIST;
+		goto exit_unlock;
+	} else {
+		/* An activator can only own a single name */
+		if (kdbus_conn_is_activator(conn) &&
+		    conn->activator_of) {
+			ret = -EINVAL;
+			goto exit_unlock;
+		}
+	}
+
+	/* new name entry */
+	e = kzalloc(sizeof(*e), GFP_KERNEL);
+	if (!e) {
+		ret = -ENOMEM;
+		goto exit_unlock;
+	}
+
+	e->name = kstrdup(name, GFP_KERNEL);
+	if (!e->name) {
+		kfree(e);
+		ret = -ENOMEM;
+		goto exit_unlock;
+	}
+
+	if (kdbus_conn_is_activator(conn)) {
+		e->activator = kdbus_conn_ref(conn);
+		conn->activator_of = e;
+	}
+
+	e->flags = *flags;
+	INIT_LIST_HEAD(&e->queue_list);
+	e->name_id = ++reg->name_seq_last;
+
+	mutex_lock(&conn->lock);
+	if (!kdbus_conn_active(conn)) {
+		mutex_unlock(&conn->lock);
+		kfree(e->name);
+		kfree(e);
+		ret = -ECONNRESET;
+		goto exit_unlock;
+	}
+	hash_add(reg->entries_hash, &e->hentry, hash);
+	kdbus_name_entry_set_owner(e, conn);
+	mutex_unlock(&conn->lock);
+
+	kdbus_notify_name_change(e->conn->ep->bus, KDBUS_ITEM_NAME_ADD,
+				 0, e->conn->id,
+				 0, e->flags, e->name);
+
+exit_unlock:
+	up_write(&reg->rwlock);
+	mutex_unlock(&conn->ep->bus->lock);
+	kdbus_notify_flush(conn->ep->bus);
+	return ret;
+}
+
+/**
+ * kdbus_cmd_name_acquire() - acquire a name from a ioctl command buffer
+ * @reg:		The name registry
+ * @conn:		The connection to pin this entry to
+ * @cmd:		The command as passed in by the ioctl
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int kdbus_cmd_name_acquire(struct kdbus_name_registry *reg,
+			   struct kdbus_conn *conn,
+			   struct kdbus_cmd_name *cmd)
+{
+	const char *name;
+	int ret;
+
+	name = kdbus_items_get_str(cmd->items, KDBUS_ITEMS_SIZE(cmd, items),
+				   KDBUS_ITEM_NAME);
+	if (IS_ERR(name))
+		return -EINVAL;
+
+	if (!kdbus_name_is_valid(name, false))
+		return -EINVAL;
+
+	/*
+	 * Do atomic_inc_return here to reserve our slot, then decrement
+	 * it before returning.
+	 */
+	if (atomic_inc_return(&conn->name_count) > KDBUS_CONN_MAX_NAMES) {
+		ret = -E2BIG;
+		goto out_dec;
+	}
+
+	if (!kdbus_conn_policy_own_name(conn, current_cred(), name)) {
+		ret = -EPERM;
+		goto out_dec;
+	}
+
+	ret = kdbus_name_acquire(reg, conn, name, &cmd->flags);
+
+out_dec:
+	/* Decrement the previous allocated slot */
+	atomic_dec(&conn->name_count);
+	return ret;
+}
+
+/**
+ * kdbus_cmd_name_release() - release a name entry from a ioctl command buffer
+ * @reg:		The name registry
+ * @conn:		The connection that holds the name
+ * @cmd:		The command as passed in by the ioctl
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int kdbus_cmd_name_release(struct kdbus_name_registry *reg,
+			   struct kdbus_conn *conn,
+			   const struct kdbus_cmd_name *cmd)
+{
+	int ret;
+	const char *name;
+
+	name = kdbus_items_get_str(cmd->items, KDBUS_ITEMS_SIZE(cmd, items),
+				   KDBUS_ITEM_NAME);
+	if (IS_ERR(name))
+		return -EINVAL;
+
+	if (!kdbus_name_is_valid(name, false))
+		return -EINVAL;
+
+	ret = kdbus_name_release(reg, conn, name);
+
+	kdbus_notify_flush(conn->ep->bus);
+	return ret;
+}
+
+static int kdbus_name_list_write(struct kdbus_conn *conn,
+				 struct kdbus_conn *c,
+				 struct kdbus_pool_slice *slice,
+				 size_t *pos,
+				 struct kdbus_name_entry *e,
+				 bool write)
+{
+	struct kvec kvec[4];
+	size_t cnt = 0;
+	int ret;
+
+	/* info header */
+	struct kdbus_name_info info = {
+		.size = 0,
+		.owner_id = c->id,
+		.conn_flags = c->flags,
+	};
+
+	/* fake the header of a kdbus_name item */
+	struct {
+		u64 size;
+		u64 type;
+		u64 flags;
+	} h = {};
+
+	if (e && !kdbus_conn_policy_see_name_unlocked(conn, current_cred(),
+						      e->name))
+		return 0;
+
+	kdbus_kvec_set(&kvec[cnt++], &info, sizeof(info), &info.size);
+
+	/* append name */
+	if (e) {
+		size_t slen = strlen(e->name) + 1;
+
+		h.size = offsetof(struct kdbus_item, name.name) + slen;
+		h.type = KDBUS_ITEM_OWNED_NAME;
+		h.flags = e->flags;
+
+		kdbus_kvec_set(&kvec[cnt++], &h, sizeof(h), &info.size);
+		kdbus_kvec_set(&kvec[cnt++], e->name, slen, &info.size);
+		cnt += !!kdbus_kvec_pad(&kvec[cnt], &info.size);
+	}
+
+	if (write) {
+		ret = kdbus_pool_slice_copy_kvec(slice, *pos, kvec,
+						 cnt, info.size);
+		if (ret < 0)
+			return ret;
+	}
+
+	*pos += info.size;
+	return 0;
+}
+
+static int kdbus_name_list_all(struct kdbus_conn *conn, u64 flags,
+			       struct kdbus_pool_slice *slice,
+			       size_t *pos, bool write)
+{
+	struct kdbus_conn *c;
+	size_t p = *pos;
+	int ret, i;
+
+	hash_for_each(conn->ep->bus->conn_hash, i, c, hentry) {
+		bool added = false;
+
+		/* skip activators */
+		if (!(flags & KDBUS_NAME_LIST_ACTIVATORS) &&
+		    kdbus_conn_is_activator(c))
+			continue;
+
+		/* all names the connection owns */
+		if (flags & (KDBUS_NAME_LIST_NAMES |
+			     KDBUS_NAME_LIST_ACTIVATORS)) {
+			struct kdbus_name_entry *e;
+
+			mutex_lock(&c->lock);
+			list_for_each_entry(e, &c->names_list, conn_entry) {
+				struct kdbus_conn *a = e->activator;
+
+				if ((flags & KDBUS_NAME_LIST_ACTIVATORS) &&
+				    a && a != c) {
+					ret = kdbus_name_list_write(conn, a,
+							slice, &p, e, write);
+					if (ret < 0) {
+						mutex_unlock(&c->lock);
+						return ret;
+					}
+
+					added = true;
+				}
+
+				if (flags & KDBUS_NAME_LIST_NAMES ||
+				    kdbus_conn_is_activator(c)) {
+					ret = kdbus_name_list_write(conn, c,
+							slice, &p, e, write);
+					if (ret < 0) {
+						mutex_unlock(&c->lock);
+						return ret;
+					}
+
+					added = true;
+				}
+			}
+			mutex_unlock(&c->lock);
+		}
+
+		/* queue of names the connection is currently waiting for */
+		if (flags & KDBUS_NAME_LIST_QUEUED) {
+			struct kdbus_name_queue_item *q;
+
+			mutex_lock(&c->lock);
+			list_for_each_entry(q, &c->names_queue_list,
+					    conn_entry) {
+				ret = kdbus_name_list_write(conn, c,
+						slice, &p, q->entry, write);
+				if (ret < 0) {
+					mutex_unlock(&c->lock);
+					return ret;
+				}
+
+				added = true;
+			}
+			mutex_unlock(&c->lock);
+		}
+
+		/* nothing added so far, just add the unique ID */
+		if (!added && flags & KDBUS_NAME_LIST_UNIQUE) {
+			ret = kdbus_name_list_write(conn, c,
+					slice, &p, NULL, write);
+			if (ret < 0)
+				return ret;
+		}
+	}
+
+	*pos = p;
+	return 0;
+}
+
+/**
+ * kdbus_cmd_name_list() - list names of a connection
+ * @reg:		The name registry
+ * @conn:		The connection holding the name entries
+ * @cmd:		The command as passed in by the ioctl
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int kdbus_cmd_name_list(struct kdbus_name_registry *reg,
+			struct kdbus_conn *conn,
+			struct kdbus_cmd_name_list *cmd)
+{
+	struct kdbus_pool_slice *slice = NULL;
+	struct kdbus_name_list list = {};
+	const struct kdbus_item *item;
+	struct kvec kvec;
+	size_t pos;
+	int ret;
+
+	KDBUS_ITEMS_FOREACH(item, cmd->items, KDBUS_ITEMS_SIZE(cmd, items)) {
+		/* no items supported so far */
+		switch (item->type) {
+		default:
+			return -EINVAL;
+		}
+	}
+
+	/* lock order: domain -> bus -> ep -> names -> conn */
+	down_read(&reg->rwlock);
+	down_read(&conn->ep->bus->conn_rwlock);
+	down_read(&conn->ep->policy_db.entries_rwlock);
+
+	/* size of header + records */
+	pos = sizeof(struct kdbus_name_list);
+	ret = kdbus_name_list_all(conn, cmd->flags, NULL, &pos, false);
+	if (ret < 0)
+		goto exit_unlock;
+
+	/* copy the header, specifying the overall size */
+	list.size = pos;
+	kvec.iov_base = &list;
+	kvec.iov_len = sizeof(list);
+
+	slice = kdbus_pool_slice_alloc(conn->pool, list.size, NULL, NULL, 0);
+	if (IS_ERR(slice)) {
+		ret = PTR_ERR(slice);
+		slice = NULL;
+		goto exit_unlock;
+	}
+
+	ret = kdbus_pool_slice_copy_kvec(slice, 0, &kvec, 1, kvec.iov_len);
+	if (ret < 0)
+		goto exit_unlock;
+
+	/* copy the records */
+	pos = sizeof(struct kdbus_name_list);
+	ret = kdbus_name_list_all(conn, cmd->flags, slice, &pos, true);
+	if (ret < 0)
+		goto exit_unlock;
+
+	kdbus_pool_slice_publish(slice, &cmd->offset, &cmd->list_size);
+	ret = 0;
+
+exit_unlock:
+	kdbus_pool_slice_release(slice);
+	up_read(&conn->ep->policy_db.entries_rwlock);
+	up_read(&conn->ep->bus->conn_rwlock);
+	up_read(&reg->rwlock);
+	return ret;
+}
ipc/kdbus/names.h new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
2.2.1
#65 lore raw

PATCH v3 11/13 kdbus: add policy database implementation

In reply to Greg Kroah-Hartman

From: Daniel Mack <[email protected]>

This patch adds the policy database implementation.

A policy databases restrict the possibilities of connections to own, see and talk to well-known names. It can be associated with a bus (through a policy holder connection) or a custom endpoint.

By default, buses have an empty policy database that is augmented on demand when a policy holder connection is instantiated.

Policies are set through KDBUS_CMD_HELLO (when creating a policy holder connection), KDBUS_CMD_CONN_UPDATE (when updating a policy holder connection), KDBUS_CMD_EP_MAKE (creating a custom endpoint) or KDBUS_CMD_EP_UPDATE (updating a custom endpoint). In all cases, the name and policy access information is stored in items of type KDBUS_ITEM_NAME and KDBUS_ITEM_POLICY_ACCESS.

See Documentation/kdbus.txt for more details.

---
 ipc/kdbus/policy.c | 481 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 ipc/kdbus/policy.h |  51 ++++++
 2 files changed, 532 insertions(+)
 create mode 100644 ipc/kdbus/policy.c
 create mode 100644 ipc/kdbus/policy.h
ipc/kdbus/policy.c new file +481 -0
new file mode 100644
index 000000000000..0b60f5f381bf
@@ -0,0 +1,481 @@
+/*
+ * Copyright (C) 2013-2014 Kay Sievers
+ * Copyright (C) 2013-2014 Greg Kroah-Hartman <[email protected]>
+ * Copyright (C) 2013-2014 Daniel Mack <[email protected]>
+ * Copyright (C) 2013-2014 David Herrmann <[email protected]>
+ * Copyright (C) 2013-2014 Linux Foundation
+ * Copyright (C) 2014 Djalal Harouni
+ *
+ * kdbus is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ */
+
+#include <linux/fs.h>
+#include <linux/init.h>
+#include <linux/mutex.h>
+#include <linux/sched.h>
+#include <linux/sizes.h>
+#include <linux/slab.h>
+#include <linux/uaccess.h>
+
+#include "bus.h"
+#include "connection.h"
+#include "domain.h"
+#include "item.h"
+#include "names.h"
+#include "policy.h"
+
+#define KDBUS_POLICY_HASH_SIZE	64
+
+/**
+ * struct kdbus_policy_db_entry_access - a database entry access item
+ * @type:		One of KDBUS_POLICY_ACCESS_* types
+ * @access:		Access to grant. One of KDBUS_POLICY_*
+ * @uid:		For KDBUS_POLICY_ACCESS_USER, the global uid
+ * @gid:		For KDBUS_POLICY_ACCESS_GROUP, the global gid
+ * @list:		List entry item for the entry's list
+ *
+ * This is the internal version of struct kdbus_policy_db_access.
+ */
+struct kdbus_policy_db_entry_access {
+	u8 type;		/* USER, GROUP, WORLD */
+	u8 access;		/* OWN, TALK, SEE */
+	union {
+		kuid_t uid;	/* global uid */
+		kgid_t gid;	/* global gid */
+	};
+	struct list_head list;
+};
+
+/**
+ * struct kdbus_policy_db_entry - a policy database entry
+ * @name:		The name to match the policy entry against
+ * @hentry:		The hash entry for the database's entries_hash
+ * @access_list:	List head for keeping tracks of the entry's
+ *			access items.
+ * @owner:		The owner of this entry. Can be a kdbus_conn or
+ *			a kdbus_ep object.
+ * @wildcard:		The name is a wildcard, such as ending on '.*'
+ */
+struct kdbus_policy_db_entry {
+	char *name;
+	struct hlist_node hentry;
+	struct list_head access_list;
+	const void *owner;
+	bool wildcard:1;
+};
+
+static void kdbus_policy_entry_free(struct kdbus_policy_db_entry *e)
+{
+	struct kdbus_policy_db_entry_access *a, *tmp;
+
+	list_for_each_entry_safe(a, tmp, &e->access_list, list) {
+		list_del(&a->list);
+		kfree(a);
+	}
+
+	kfree(e->name);
+	kfree(e);
+}
+
+static const struct kdbus_policy_db_entry *
+kdbus_policy_lookup(struct kdbus_policy_db *db, const char *name, u32 hash)
+{
+	struct kdbus_policy_db_entry *e;
+	const char *dot;
+	size_t len;
+
+	/* find exact match */
+	hash_for_each_possible(db->entries_hash, e, hentry, hash)
+		if (strcmp(e->name, name) == 0 && !e->wildcard)
+			return e;
+
+	/* find wildcard match */
+
+	dot = strrchr(name, '.');
+	if (!dot)
+		return NULL;
+
+	len = dot - name;
+	hash = kdbus_strnhash(name, len);
+
+	hash_for_each_possible(db->entries_hash, e, hentry, hash)
+		if (e->wildcard && !strncmp(e->name, name, len) &&
+		    !e->name[len])
+			return e;
+
+	return NULL;
+}
+
+/**
+ * kdbus_policy_db_clear - release all memory from a policy db
+ * @db:		The policy database
+ */
+void kdbus_policy_db_clear(struct kdbus_policy_db *db)
+{
+	struct kdbus_policy_db_entry *e;
+	struct hlist_node *tmp;
+	unsigned int i;
+
+	/* purge entries */
+	down_write(&db->entries_rwlock);
+	hash_for_each_safe(db->entries_hash, i, tmp, e, hentry) {
+		hash_del(&e->hentry);
+		kdbus_policy_entry_free(e);
+	}
+	up_write(&db->entries_rwlock);
+}
+
+/**
+ * kdbus_policy_db_init() - initialize a new policy database
+ * @db:		The location of the database
+ *
+ * This initializes a new policy-db. The underlying memory must have been
+ * cleared to zero by the caller.
+ */
+void kdbus_policy_db_init(struct kdbus_policy_db *db)
+{
+	hash_init(db->entries_hash);
+	init_rwsem(&db->entries_rwlock);
+}
+
+/**
+ * kdbus_policy_query_unlocked() - Query the policy database
+ * @db:		Policy database
+ * @cred:	Credentials to test against
+ * @name:	Name to query
+ * @hash:	Hash value of @name
+ *
+ * Same as kdbus_policy_query() but requires the caller to lock the policy
+ * database against concurrent writes.
+ *
+ * Return: The highest KDBUS_POLICY_* access type found, or -EPERM if none.
+ */
+int kdbus_policy_query_unlocked(struct kdbus_policy_db *db,
+				const struct cred *cred, const char *name,
+				unsigned int hash)
+{
+	struct kdbus_policy_db_entry_access *a;
+	const struct kdbus_policy_db_entry *e;
+	int i, highest = -EPERM;
+
+	e = kdbus_policy_lookup(db, name, hash);
+	if (!e)
+		return -EPERM;
+
+	list_for_each_entry(a, &e->access_list, list) {
+		if ((int)a->access <= highest)
+			continue;
+
+		switch (a->type) {
+		case KDBUS_POLICY_ACCESS_USER:
+			if (uid_eq(cred->euid, a->uid))
+				highest = a->access;
+			break;
+		case KDBUS_POLICY_ACCESS_GROUP:
+			if (gid_eq(cred->egid, a->gid)) {
+				highest = a->access;
+				break;
+			}
+
+			for (i = 0; i < cred->group_info->ngroups; i++) {
+				kgid_t gid = GROUP_AT(cred->group_info, i);
+
+				if (gid_eq(gid, a->gid)) {
+					highest = a->access;
+					break;
+				}
+			}
+
+			break;
+		case KDBUS_POLICY_ACCESS_WORLD:
+			highest = a->access;
+			break;
+		}
+
+		/* OWN is the highest possible policy */
+		if (highest >= KDBUS_POLICY_OWN)
+			break;
+	}
+
+	return highest;
+}
+
+/**
+ * kdbus_policy_query() - Query the policy database
+ * @db:		Policy database
+ * @cred:	Credentials to test against
+ * @name:	Name to query
+ * @hash:	Hash value of @name
+ *
+ * Query the policy database @db for the access rights of @cred to the name
+ * @name. The access rights of @cred are returned, or -EPERM if no access is
+ * granted.
+ *
+ * This call effectively searches for the highest access-right granted to
+ * @cred. The caller should really cache those as policy lookups are rather
+ * expensive.
+ *
+ * Return: The highest KDBUS_POLICY_* access type found, or -EPERM if none.
+ */
+int kdbus_policy_query(struct kdbus_policy_db *db, const struct cred *cred,
+		       const char *name, unsigned int hash)
+{
+	int ret;
+
+	down_read(&db->entries_rwlock);
+	ret = kdbus_policy_query_unlocked(db, cred, name, hash);
+	up_read(&db->entries_rwlock);
+
+	return ret;
+}
+
+static void __kdbus_policy_remove_owner(struct kdbus_policy_db *db,
+					const void *owner)
+{
+	struct kdbus_policy_db_entry *e;
+	struct hlist_node *tmp;
+	int i;
+
+	hash_for_each_safe(db->entries_hash, i, tmp, e, hentry)
+		if (e->owner == owner) {
+			hash_del(&e->hentry);
+			kdbus_policy_entry_free(e);
+		}
+}
+
+/**
+ * kdbus_policy_remove_owner() - remove all entries related to a connection
+ * @db:		The policy database
+ * @owner:	The connection which items to remove
+ */
+void kdbus_policy_remove_owner(struct kdbus_policy_db *db,
+			       const void *owner)
+{
+	down_write(&db->entries_rwlock);
+	__kdbus_policy_remove_owner(db, owner);
+	up_write(&db->entries_rwlock);
+}
+
+/*
+ * Convert user provided policy access to internal kdbus policy
+ * access
+ */
+static struct kdbus_policy_db_entry_access *
+kdbus_policy_make_access(const struct kdbus_policy_access *uaccess)
+{
+	int ret;
+	struct kdbus_policy_db_entry_access *a;
+
+	a = kzalloc(sizeof(*a), GFP_KERNEL);
+	if (!a)
+		return ERR_PTR(-ENOMEM);
+
+	ret = -EINVAL;
+	switch (uaccess->access) {
+	case KDBUS_POLICY_SEE:
+	case KDBUS_POLICY_TALK:
+	case KDBUS_POLICY_OWN:
+		a->access = uaccess->access;
+		break;
+	default:
+		goto err;
+	}
+
+	switch (uaccess->type) {
+	case KDBUS_POLICY_ACCESS_USER:
+		a->uid = make_kuid(current_user_ns(), uaccess->id);
+		if (!uid_valid(a->uid))
+			goto err;
+
+		break;
+	case KDBUS_POLICY_ACCESS_GROUP:
+		a->gid = make_kgid(current_user_ns(), uaccess->id);
+		if (!gid_valid(a->gid))
+			goto err;
+
+		break;
+	case KDBUS_POLICY_ACCESS_WORLD:
+		break;
+	default:
+		goto err;
+	}
+
+	a->type = uaccess->type;
+
+	return a;
+
+err:
+	kfree(a);
+	return ERR_PTR(ret);
+}
+
+/**
+ * kdbus_policy_set() - set a connection's policy rules
+ * @db:				The policy database
+ * @items:			A list of kdbus_item elements that contain both
+ *				names and access rules to set.
+ * @items_size:			The total size of the items.
+ * @max_policies:		The maximum number of policy entries to allow.
+ *				Pass 0 for no limit.
+ * @allow_wildcards:		Boolean value whether wildcard entries (such
+ *				ending on '.*') should be allowed.
+ * @owner:			The owner of the new policy items.
+ *
+ * This function sets a new set of policies for a given owner. The names and
+ * access rules are gathered by walking the list of items passed in as
+ * argument. An item of type KDBUS_ITEM_NAME is expected before any number of
+ * KDBUS_ITEM_POLICY_ACCESS items. If there are more repetitions of this
+ * pattern than denoted in @max_policies, -EINVAL is returned.
+ *
+ * In order to allow atomic replacement of rules, the function first removes
+ * all entries that have been created for the given owner previously.
+ *
+ * Callers to this function must make sur that the owner is a custom
+ * endpoint, or if the endpoint is a default endpoint, then it must be
+ * either a policy holder or an activator.
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int kdbus_policy_set(struct kdbus_policy_db *db,
+		     const struct kdbus_item *items,
+		     size_t items_size,
+		     size_t max_policies,
+		     bool allow_wildcards,
+		     const void *owner)
+{
+	struct kdbus_policy_db_entry_access *a;
+	struct kdbus_policy_db_entry *e, *p;
+	const struct kdbus_item *item;
+	struct hlist_node *tmp;
+	HLIST_HEAD(entries);
+	HLIST_HEAD(restore);
+	size_t count = 0;
+	int i, ret = 0;
+	u32 hash;
+
+	if (items_size > KDBUS_POLICY_MAX_SIZE)
+		return -E2BIG;
+
+	/* Walk the list of items and look for new policies */
+	e = NULL;
+	KDBUS_ITEMS_FOREACH(item, items, items_size) {
+		switch (item->type) {
+		case KDBUS_ITEM_NAME: {
+			size_t len;
+
+			if (max_policies && ++count > max_policies) {
+				ret = -E2BIG;
+				goto exit;
+			}
+
+			if (!kdbus_name_is_valid(item->str, true)) {
+				ret = -EINVAL;
+				goto exit;
+			}
+
+			e = kzalloc(sizeof(*e), GFP_KERNEL);
+			if (!e) {
+				ret = -ENOMEM;
+				goto exit;
+			}
+
+			INIT_LIST_HEAD(&e->access_list);
+			e->owner = owner;
+			hlist_add_head(&e->hentry, &entries);
+
+			e->name = kstrdup(item->str, GFP_KERNEL);
+			if (!e->name) {
+				ret = -ENOMEM;
+				goto exit;
+			}
+
+			/*
+			 * If a supplied name ends with an '.*', cut off that
+			 * part, only store anything before it, and mark the
+			 * entry as wildcard.
+			 */
+			len = strlen(e->name);
+			if (len > 2 &&
+			    e->name[len - 3] == '.' &&
+			    e->name[len - 2] == '*') {
+				if (!allow_wildcards) {
+					ret = -EINVAL;
+					goto exit;
+				}
+
+				e->name[len - 3] = '\0';
+				e->wildcard = true;
+			}
+
+			break;
+		}
+
+		case KDBUS_ITEM_POLICY_ACCESS:
+			if (!e) {
+				ret = -EINVAL;
+				goto exit;
+			}
+
+			a = kdbus_policy_make_access(&item->policy_access);
+			if (IS_ERR(a)) {
+				ret = PTR_ERR(a);
+				goto exit;
+			}
+
+			list_add_tail(&a->list, &e->access_list);
+			break;
+		}
+	}
+
+	down_write(&db->entries_rwlock);
+
+	/* remember previous entries to restore in case of failure */
+	hash_for_each_safe(db->entries_hash, i, tmp, e, hentry)
+		if (e->owner == owner) {
+			hash_del(&e->hentry);
+			hlist_add_head(&e->hentry, &restore);
+		}
+
+	hlist_for_each_entry_safe(e, tmp, &entries, hentry) {
+		/* prevent duplicates */
+		hash = kdbus_strhash(e->name);
+		hash_for_each_possible(db->entries_hash, p, hentry, hash)
+			if (strcmp(e->name, p->name) == 0 &&
+			    e->wildcard == p->wildcard) {
+				ret = -EEXIST;
+				goto restore;
+			}
+
+		hlist_del(&e->hentry);
+		hash_add(db->entries_hash, &e->hentry, hash);
+	}
+
+restore:
+	/* if we failed, flush all entries we added so far */
+	if (ret < 0)
+		__kdbus_policy_remove_owner(db, owner);
+
+	/* if we failed, restore entries, otherwise release them */
+	hlist_for_each_entry_safe(e, tmp, &restore, hentry) {
+		hlist_del(&e->hentry);
+		if (ret < 0) {
+			hash = kdbus_strhash(e->name);
+			hash_add(db->entries_hash, &e->hentry, hash);
+		} else {
+			kdbus_policy_entry_free(e);
+		}
+	}
+
+	up_write(&db->entries_rwlock);
+
+exit:
+	hlist_for_each_entry_safe(e, tmp, &entries, hentry) {
+		hlist_del(&e->hentry);
+		kdbus_policy_entry_free(e);
+	}
+
+	return ret;
+}
ipc/kdbus/policy.h new file +51 -0

51 lines not on this page · raw message

Signature · 1 line
2.2.1
#66 lore raw

PATCH v3 12/13 kdbus: add Makefile, Kconfig and MAINTAINERS entry

In reply to Greg Kroah-Hartman

From: Daniel Mack <[email protected]>

This patch hooks up the build system to actually compile the files added by previous patches. It also adds an entry to MAINTAINERS to direct people to Greg KH, David Herrmann, Djalal Harouni and me for questions and patches.

---
 MAINTAINERS        | 12 ++++++++++++
 init/Kconfig       | 12 ++++++++++++
 ipc/Makefile       |  2 +-
 ipc/kdbus/Makefile | 22 ++++++++++++++++++++++
 4 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 ipc/kdbus/Makefile
MAINTAINERS +12 -0
index 3589d67437f8..638f78ea6fb6 100644
@@ -5410,6 +5410,18 @@ S:	Maintained
 F:	Documentation/kbuild/kconfig-language.txt
 F:	scripts/kconfig/
 
+KDBUS
+M:	Greg Kroah-Hartman <[email protected]>
+M:	Daniel Mack <[email protected]>
+M:	David Herrmann <dh.herrmann-gM/[email protected]>
+M:	Djalal Harouni <tixxdz-Umm1ozX2/[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	ipc/kdbus/*
+F:	Documentation/kdbus.txt
+F:	include/uapi/linux/kdbus.h
+F:	tools/testing/selftests/kdbus/
+
 KDUMP
 M:	Vivek Goyal <[email protected]>
 M:	Haren Myneni <hbabu-r/[email protected]>
init/Kconfig +12 -0
index 9afb971497f4..4263ef30dbcc 100644
@@ -261,6 +261,18 @@ config POSIX_MQUEUE_SYSCTL
 	depends on SYSCTL
 	default y
 
+config KDBUS
+	tristate "kdbus interprocess communication"
+	depends on TMPFS
+	help
+	  D-Bus is a system for low-latency, low-overhead, easy to use
+	  interprocess communication (IPC).
+
+	  See Documentation/kdbus.txt
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called kdbus.
+
 config CROSS_MEMORY_ATTACH
 	bool "Enable process_vm_readv/writev syscalls"
 	depends on MMU
ipc/Makefile +1 -1
index 86c7300ecdf5..68ec4167d11b 100644
@@ -9,4 +9,4 @@ obj_mq-$(CONFIG_COMPAT) += compat_mq.o
 obj-$(CONFIG_POSIX_MQUEUE) += mqueue.o msgutil.o $(obj_mq-y)
 obj-$(CONFIG_IPC_NS) += namespace.o
 obj-$(CONFIG_POSIX_MQUEUE_SYSCTL) += mq_sysctl.o
-
+obj-$(CONFIG_KDBUS) += kdbus/
ipc/kdbus/Makefile new file +22 -0
new file mode 100644
index 000000000000..7ee9271e1449
@@ -0,0 +1,22 @@
+kdbus-y := \
+	bus.o \
+	connection.o \
+	endpoint.o \
+	fs.o \
+	handle.o \
+	item.o \
+	main.o \
+	match.o \
+	message.o \
+	metadata.o \
+	names.o \
+	node.o \
+	notify.o \
+	domain.o \
+	policy.o \
+	pool.o \
+	reply.o \
+	queue.o \
+	util.o
+
+obj-$(CONFIG_KDBUS) += kdbus.o
Signature · 1 line
2.2.1
#67 lore raw

PATCH v3 13/13 kdbus: add selftests

In reply to Greg Kroah-Hartman

From: Daniel Mack <[email protected]>

This patch adds a quite extensive test suite for kdbus that checks the most important code pathes in the driver. The idea is to extend the test suite over time.

Also, this code can serve as an example implementation to show how to use the kernel API from userspace.

---
 tools/testing/selftests/Makefile                  |    1 +
 tools/testing/selftests/kdbus/.gitignore          |   11 +
 tools/testing/selftests/kdbus/Makefile            |   46 +
 tools/testing/selftests/kdbus/kdbus-enum.c        |   95 ++
 tools/testing/selftests/kdbus/kdbus-enum.h        |   14 +
 tools/testing/selftests/kdbus/kdbus-test.c        |  920 ++++++++++++
 tools/testing/selftests/kdbus/kdbus-test.h        |   85 ++
 tools/testing/selftests/kdbus/kdbus-util.c        | 1646 +++++++++++++++++++++
 tools/testing/selftests/kdbus/kdbus-util.h        |  216 +++
 tools/testing/selftests/kdbus/test-activator.c    |  319 ++++
 tools/testing/selftests/kdbus/test-attach-flags.c |  751 ++++++++++
 tools/testing/selftests/kdbus/test-benchmark.c    |  427 ++++++
 tools/testing/selftests/kdbus/test-bus.c          |  174 +++
 tools/testing/selftests/kdbus/test-chat.c         |  123 ++
 tools/testing/selftests/kdbus/test-connection.c   |  611 ++++++++
 tools/testing/selftests/kdbus/test-daemon.c       |   66 +
 tools/testing/selftests/kdbus/test-endpoint.c     |  344 +++++
 tools/testing/selftests/kdbus/test-fd.c           |  710 +++++++++
 tools/testing/selftests/kdbus/test-free.c         |   36 +
 tools/testing/selftests/kdbus/test-match.c        |  442 ++++++
 tools/testing/selftests/kdbus/test-message.c      |  658 ++++++++
 tools/testing/selftests/kdbus/test-metadata-ns.c  |  507 +++++++
 tools/testing/selftests/kdbus/test-monitor.c      |  158 ++
 tools/testing/selftests/kdbus/test-names.c        |  184 +++
 tools/testing/selftests/kdbus/test-policy-ns.c    |  633 ++++++++
 tools/testing/selftests/kdbus/test-policy-priv.c  | 1270 ++++++++++++++++
 tools/testing/selftests/kdbus/test-policy.c       |   81 +
 tools/testing/selftests/kdbus/test-race.c         |  313 ++++
 tools/testing/selftests/kdbus/test-sync.c         |  368 +++++
 tools/testing/selftests/kdbus/test-timeout.c      |   99 ++
 30 files changed, 11308 insertions(+)
 create mode 100644 tools/testing/selftests/kdbus/.gitignore
 create mode 100644 tools/testing/selftests/kdbus/Makefile
 create mode 100644 tools/testing/selftests/kdbus/kdbus-enum.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-enum.h
 create mode 100644 tools/testing/selftests/kdbus/kdbus-test.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-test.h
 create mode 100644 tools/testing/selftests/kdbus/kdbus-util.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-util.h
 create mode 100644 tools/testing/selftests/kdbus/test-activator.c
 create mode 100644 tools/testing/selftests/kdbus/test-attach-flags.c
 create mode 100644 tools/testing/selftests/kdbus/test-benchmark.c
 create mode 100644 tools/testing/selftests/kdbus/test-bus.c
 create mode 100644 tools/testing/selftests/kdbus/test-chat.c
 create mode 100644 tools/testing/selftests/kdbus/test-connection.c
 create mode 100644 tools/testing/selftests/kdbus/test-daemon.c
 create mode 100644 tools/testing/selftests/kdbus/test-endpoint.c
 create mode 100644 tools/testing/selftests/kdbus/test-fd.c
 create mode 100644 tools/testing/selftests/kdbus/test-free.c
 create mode 100644 tools/testing/selftests/kdbus/test-match.c
 create mode 100644 tools/testing/selftests/kdbus/test-message.c
 create mode 100644 tools/testing/selftests/kdbus/test-metadata-ns.c
 create mode 100644 tools/testing/selftests/kdbus/test-monitor.c
 create mode 100644 tools/testing/selftests/kdbus/test-names.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy-ns.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy-priv.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy.c
 create mode 100644 tools/testing/selftests/kdbus/test-race.c
 create mode 100644 tools/testing/selftests/kdbus/test-sync.c
 create mode 100644 tools/testing/selftests/kdbus/test-timeout.c
tools/testing/selftests/Makefile +1 -0
index 4e511221a0c1..7b51cceae9dd 100644
@@ -5,6 +5,7 @@ TARGETS += exec
 TARGETS += firmware
 TARGETS += ftrace
 TARGETS += kcmp
+TARGETS += kdbus
 TARGETS += memfd
 TARGETS += memory-hotplug
 TARGETS += mount
tools/testing/selftests/kdbus/.gitignore new file +11 -0
new file mode 100644
index 000000000000..4b97beee5f80
@@ -0,0 +1,11 @@
+*.cmd
+*.ko
+*.mod.c
+modules.order
+Module.symvers
+*.o
+*.swp
+.tmp_versions
+tags
+tools/kdbus-monitor
+test/kdbus-test
tools/testing/selftests/kdbus/Makefile new file +46 -0

46 lines not on this page · raw message

tools/testing/selftests/kdbus/kdbus-enum.c new file +95 -0

95 lines not on this page · raw message

tools/testing/selftests/kdbus/kdbus-enum.h new file +14 -0
new file mode 100644
index 000000000000..110bfd332859
@@ -0,0 +1,14 @@
+/*
+ * Copyright (C) 2013-2014 Kay Sievers
+ *
+ * kdbus is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at
+ * your option) any later version.
+ */
+#pragma once
+
+const char *enum_CMD(long long id);
+const char *enum_MSG(long long id);
+const char *enum_MATCH(long long id);
+const char *enum_PAYLOAD(long long id);
tools/testing/selftests/kdbus/kdbus-test.c new file +920 -0

920 lines not on this page · raw message

tools/testing/selftests/kdbus/kdbus-test.h new file +85 -0

85 lines not on this page · raw message

tools/testing/selftests/kdbus/kdbus-util.c new file +1646 -0

1,646 lines not on this page · raw message

tools/testing/selftests/kdbus/kdbus-util.h new file +216 -0

176 lines not on this page · raw message

tools/testing/selftests/kdbus/test-activator.c new file +319 -0

319 lines not on this page · raw message

tools/testing/selftests/kdbus/test-attach-flags.c new file +751 -0

751 lines not on this page · raw message

tools/testing/selftests/kdbus/test-benchmark.c new file +427 -0

427 lines not on this page · raw message

tools/testing/selftests/kdbus/test-bus.c new file +174 -0

174 lines not on this page · raw message

tools/testing/selftests/kdbus/test-chat.c new file +123 -0

123 lines not on this page · raw message

tools/testing/selftests/kdbus/test-connection.c new file +611 -0

611 lines not on this page · raw message

tools/testing/selftests/kdbus/test-daemon.c new file +66 -0

66 lines not on this page · raw message

tools/testing/selftests/kdbus/test-endpoint.c new file +344 -0

344 lines not on this page · raw message

tools/testing/selftests/kdbus/test-fd.c new file +710 -0

710 lines not on this page · raw message

tools/testing/selftests/kdbus/test-free.c new file +36 -0
new file mode 100644
index 000000000000..e3a280a6daf2

Lines of this file are not shown. View the raw message.

tools/testing/selftests/kdbus/test-match.c new file +442 -0

442 lines not on this page · raw message

tools/testing/selftests/kdbus/test-message.c new file +658 -0

658 lines not on this page · raw message

tools/testing/selftests/kdbus/test-metadata-ns.c new file +507 -0

507 lines not on this page · raw message

tools/testing/selftests/kdbus/test-monitor.c new file +158 -0

158 lines not on this page · raw message

tools/testing/selftests/kdbus/test-names.c new file +184 -0

184 lines not on this page · raw message

tools/testing/selftests/kdbus/test-policy-ns.c new file +633 -0

633 lines not on this page · raw message

tools/testing/selftests/kdbus/test-policy-priv.c new file +1270 -0

1,270 lines not on this page · raw message

tools/testing/selftests/kdbus/test-policy.c new file +81 -0

81 lines not on this page · raw message

tools/testing/selftests/kdbus/test-race.c new file +313 -0

313 lines not on this page · raw message

tools/testing/selftests/kdbus/test-sync.c new file +368 -0

368 lines not on this page · raw message

tools/testing/selftests/kdbus/test-timeout.c new file +99 -0

99 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.2.1

Part of the diff is not shown here. View the raw message.

#68 lore raw
In reply to Greg Kroah-Hartman
Quoted 2 lines · Greg Kroah-Hartman

This can also be found in a git tree, the kdbus branch of char-misc.git at:
https://git.kernel.org/cgit/linux/kernel/git/gregkh/char-misc.git/

Is this now the canonical tree? I ask because the github tree hasn't been updated in quite some time. The code.google.com tree has commits from 2 days ago, but it still calls d_materialise_unique in fs.c whereas the patchset you've posted uses the correct d_splice_alias. So the code.google.com tree doesn't actually compile against 3.19-rcX.

I'm confused where we're supposed to track things now.

josh

#69 lore raw
Quoted 7 lines · Josh Boyer
Quoted 2 lines · Greg Kroah-Hartman

This can also be found in a git tree, the kdbus branch of char-misc.git at:
https://git.kernel.org/cgit/linux/kernel/git/gregkh/char-misc.git/

Is this now the canonical tree? I ask because the github tree hasn't been updated in quite some time.

That's my fault, it's just a mirror of the code.google.com tree for people who like to use github. It's now updated.

Quoted 6 lines

The code.google.com tree has commits
from 2 days ago, but it still calls d_materialise_unique in fs.c whereas the patchset you've posted uses the correct d_splice_alias. So the code.google.com tree doesn't actually compile against 3.19-rcX.

I'm confused where we're supposed to track things now.

I think the google tree is the "correct" one, but when generating patches, apis are tweaked to work properly with the latest -rc kernel for submission.

Daniel knows more though, he's the one generating the patchsets, I don't know how he's doing it exactly.

thanks,

greg k-h

#70 lore raw

Hi Josh,

Quoted 7 lines · Greg Kroah-Hartman
Quoted 6 lines · Josh Boyer

The code.google.com tree has commits
from 2 days ago, but it still calls d_materialise_unique in fs.c whereas the patchset you've posted uses the correct d_splice_alias. So the code.google.com tree doesn't actually compile against 3.19-rcX.

I'm confused where we're supposed to track things now.

The code.google.com repository is where we do all the development, and the code is made to build external kernel modules for 3.18. The patches sent in this series are meant for 3.19 and 3.20 kernels, and while they are based on the exact same sources, the patches differ in the following minor details:

* Code is moved to appropriate locations, such as ipc/kdbus, include/uapi, tools/testing/selftests/kdbus/, Documentation/ etc.

* Include file location amendments, "kdbus.h" vs. <uapi/linux/kdbus.h>

* Added iov_iter_kvec() usage, as that's a new API in v3.19

* The file system magic number is moved to include/uapi/linux/magic.h

* d_materialise_unique() is renamed to d_splice_alias() to catch up with changes in 3.19

The commit this patch set is based on is tagged as "lkml-v3" in the upstream repository now.

Thanks,
Daniel

#71 lore raw
Quoted 24 lines · Daniel Mack

Hi Josh,

Quoted 7 lines · Greg Kroah-Hartman
Quoted 6 lines · Josh Boyer

The code.google.com tree has commits
from 2 days ago, but it still calls d_materialise_unique in fs.c whereas the patchset you've posted uses the correct d_splice_alias. So the code.google.com tree doesn't actually compile against 3.19-rcX.

I'm confused where we're supposed to track things now.

The code.google.com repository is where we do all the development, and the code is made to build external kernel modules for 3.18. The patches sent in this series are meant for 3.19 and 3.20 kernels, and while they are based on the exact same sources, the patches differ in the following minor details:

* Code is moved to appropriate locations, such as ipc/kdbus, include/uapi, tools/testing/selftests/kdbus/, Documentation/ etc.

* Include file location amendments, "kdbus.h" vs. <uapi/linux/kdbus.h>

* Added iov_iter_kvec() usage, as that's a new API in v3.19

Quoted 8 lines

* The file system magic number is moved to include/uapi/linux/magic.h

* d_materialise_unique() is renamed to d_splice_alias() to catch up with changes in 3.19

The commit this patch set is based on is tagged as "lkml-v3" in the upstream repository now.

OK, thanks for the explanation.

I wonder if it would be possible to have branches for each kernel version in the code.google.com repo? I build kdbus against a number of kernels and trying to chase down different repos and patch sets to match might get to be a chore. I mean, I'm all for doing closet development to get stuff ready for upstream but it's hard for others to keep up when the closet keeps moving :)

josh

#72 lore raw
In reply to Greg Kroah-Hartman

Hi Greg and Daniel,

I don't have a clue so I need to ask some stupid questions...

Quoted 6 lines · Greg Kroah-Hartman

kdbus is a kernel-level IPC implementation that aims for resemblance to the the protocol layer with the existing userspace D-Bus daemon while enabling some features that couldn't be implemented before in userspace.

The documentation in the first patch in this series explains the protocol and the API details.

How about the big picture?

Quoted 2 lines

Reasons why this should be done in the kernel, instead of userspace as it is currently done today include the following:

[abbreviated]

Quoted 3 lines

- performance
- security
- semantics for apps with heavy data payloads

First of all I wonder about the relationship with D-Bus.
http://dbus.freedesktop.org/doc/dbus-specification.html says:

D-Bus is designed for two specific use cases:

A "system bus" for notifications from the system to user sessions, and to allow the system to request input from user sessions.

A "session bus" used to implement desktop environments such as GNOME and KDE.

D-Bus is not intended to be a generic IPC system for any possible application, and intentionally omits many features found in other IPC systems for this reason.

Does this also apply to kdbus? If not, what are the suggested uses of kdbus beyond those where D-Bus is currently used?

Another related quote by Havoc Pennington:
http://lists.freedesktop.org/archives/dbus/2012-March/015024.html

In general, reading this, I think in some cases there are problems that make sense to fix in dbus, and in other cases there are problems that are best solved by not using dbus.
...
there are about 10000 IPC solutions already, from ICE (both of them) to ZeroMQ to AMQP to CORBA to X11 to HTTP to SOAP to WebSockets to SUN-RPC to whatever-the-heck. To me, trying to make dbus configurable so that it can substitute for any of these is a Bad Idea (tm).

Do you think it also applies to kdbus?

Wrt the performance improvement achieved by kdbus, my impression about D-Bus is that the number of messages on my system is about a dozen per minute. Are there actually any existing applications using D-Bus that have a performance issue? Or is this only about future possible uses?

Linked from http://kroah.com/log/blog/2014/01/15/kdbus-details/,
http://lwn.net/Articles/580194/ "The unveiling of kdbus" says:

Unlike most other kernels, Linux has never had a well-designed IPC mechanism. Windows and Mac OS have this feature; even Android, based on Linux, has one in the form of the "binder" subsystem. Linux, instead, has only had the primitives — sockets, FIFOs, and shared memory — but those have never been knitted together into a reasonable application-level API. Kdbus is an attempt to do that knitting and create something that is at least as good as the mechanisms found on other systems.

These are bold words. I'm not sure what Windows and Mac OS have in terms of IPC, but the above suggests that kdbus is *the* new Linux IPC that everyone will use for everything, rather than a special purpose facility.
True?

Thanks,
Johannes

#73 lore raw
Quoted 1 line · Johannes Stezenbach

Hi Greg and Daniel,

[Fixing Daniel's email, which I messed up originally...]

Quoted 30 lines · Greg Kroah-Hartman
Quoted 6 lines

kdbus is a kernel-level IPC implementation that aims for resemblance to the the protocol layer with the existing userspace D-Bus daemon while enabling some features that couldn't be implemented before in userspace.

The documentation in the first patch in this series explains the protocol and the API details.

How about the big picture?

Quoted 2 lines

Reasons why this should be done in the kernel, instead of userspace as it is currently done today include the following:

[abbreviated]

Quoted 3 lines

- performance
- security
- semantics for apps with heavy data payloads

First of all I wonder about the relationship with D-Bus.
http://dbus.freedesktop.org/doc/dbus-specification.html says:

D-Bus is designed for two specific use cases:

A "system bus" for notifications from the system to user sessions, and to allow the system to request input from user sessions.

A "session bus" used to implement desktop environments such as GNOME and KDE.

Quoted 7 lines

D-Bus is not intended to be a generic IPC system for any possible application, and intentionally omits many features found in other IPC systems for this reason.

Does this also apply to kdbus? If not, what are the suggested uses of kdbus beyond those where D-Bus is currently used?

I don't really know. I have heard from lots of random people who are starting to look into kdbus as to if it will work for their use cases, which seem quite varied. I'll leave it to them to pop up and say if it will work for them outside of the above specific ways. But even then, the above two things are something almost all Linux boxes rely on today, so it's not like this is a solution searching for a problem to solve :)

Quoted 13 lines

Another related quote by Havoc Pennington:
http://lists.freedesktop.org/archives/dbus/2012-March/015024.html

In general, reading this, I think in some cases there are problems that make sense to fix in dbus, and in other cases there are problems that are best solved by not using dbus.
...
there are about 10000 IPC solutions already, from ICE (both of them) to ZeroMQ to AMQP to CORBA to X11 to HTTP to SOAP to WebSockets to SUN-RPC to whatever-the-heck. To me, trying to make dbus configurable so that it can substitute for any of these is a Bad Idea (tm).

Quoted 1 line

Do you think it also applies to kdbus?

Yes, I do agree, there are lots of existing ipc solutions today that kdbus is not designed for, nor would it be good to use it for. The majority of them being IPC that crosses the network layer, as there are lots of good solutions today for that problem. That being said, I do know one research group that has kdbus working cross-network, just "to try it out", but I don't know what ever came of it.

Quoted 5 lines

Wrt the performance improvement achieved by kdbus, my impression about D-Bus is that the number of messages on my system is about a dozen per minute. Are there actually any existing applications using D-Bus that have a performance issue? Or is this only about future possible uses?

There are a number of existing applications that have this performance issue today. The majority of them have been ported from other operating systems that have a fast message bus, so their process model is all about messages. They use a library layer on Linux to turn that message bus into D-Bus messages, and have suffered a huge hit in performance from their previous operating system. Using kdbus has brought it back in line to make it reasonable to use.

These applications can be usually found in the Automotive sector, which has been playing with light-weight dbus library implementations for a while now, and have done some initial kdbus testing to verify this will work for them.

Quoted 12 lines

Linked from http://kroah.com/log/blog/2014/01/15/kdbus-details/,
http://lwn.net/Articles/580194/ "The unveiling of kdbus" says:

Unlike most other kernels, Linux has never had a well-designed IPC mechanism. Windows and Mac OS have this feature; even Android, based on Linux, has one in the form of the "binder" subsystem. Linux, instead, has only had the primitives — sockets, FIFOs, and shared memory — but those have never been knitted together into a reasonable application-level API. Kdbus is an attempt to do that knitting and create something that is at least as good as the mechanisms found on other systems.

Quoted 4 lines

These are bold words. I'm not sure what Windows and Mac OS have in terms of IPC, but the above suggests that kdbus is *the* new Linux IPC that everyone will use for everything, rather than a special purpose facility.

Everyone uses D-Bus today for everything on their system, so by replacing the underlying library with kdbus, they will continue to use it for everything without having to change any application or library code at all.

Hope this helps,

greg k-h

#74 lore raw
Quoted 6 lines · Greg Kroah-Hartman

Yes, I do agree, there are lots of existing ipc solutions today that kdbus is not designed for, nor would it be good to use it for. The majority of them being IPC that crosses the network layer, as there are lots of good solutions today for that problem. That being said, I do know one research group that has kdbus working cross-network, just "to try it out", but I don't know what ever came of it.

...

Quoted 4 lines

Everyone uses D-Bus today for everything on their system, so by replacing the underlying library with kdbus, they will continue to use it for everything without having to change any application or library code at all.

These two statements somehow contradict. From my admittedly very limited experience, I never used D-Bus because it did not fit my usage scenarios: I never needed a bus, only point-to-point links like pipes or sockets.

Let me rephrase my previous, lengthy mail: Will kdbus only support the same IPC model as D-Bus (just with higher performance and some bells and whistles), or will it be useful for other scenarios? Like, can two programs use it to communicate directly without the need of any daemon? (And if so, would there be any advantage compared to traditional UNIX IPC methods?)

You were comparing kdbus and Binder. Why?
So far my impression is that D-Bus and Binder are completely seperate things, not just because of
the thread vs. event-loop programming model but
also because Binder is not a bus (i.e. no multicast messaging).

Quoted 1 line

Hope this helps,

Well, it made your intentions a bit clearer, but it does not help to sell kdbus to me, sorry ;-/

Thanks,
Johannes

#75 lore raw
Quoted 13 lines · Johannes Stezenbach
Quoted 6 lines · Greg Kroah-Hartman

Yes, I do agree, there are lots of existing ipc solutions today that kdbus is not designed for, nor would it be good to use it for. The majority of them being IPC that crosses the network layer, as there are lots of good solutions today for that problem. That being said, I do know one research group that has kdbus working cross-network, just "to try it out", but I don't know what ever came of it.

...

Quoted 4 lines

Everyone uses D-Bus today for everything on their system, so by replacing the underlying library with kdbus, they will continue to use it for everything without having to change any application or library code at all.

Quoted 4 lines

These two statements somehow contradict. From my admittedly very limited experience, I never used D-Bus because it did not fit my usage scenarios: I never needed a bus, only point-to-point links like pipes or sockets.

Great, then you don't need this, no need to worry about it at all, why are we having this conversation? :)

Quoted 7 lines

Let me rephrase my previous, lengthy mail: Will kdbus only support the same IPC model as D-Bus (just with higher performance and some bells and whistles), or will it be useful for other scenarios? Like, can two programs use it to communicate directly without the need of any daemon? (And if so, would there be any advantage compared to traditional UNIX IPC methods?)

It's a totally different model, as you point out from what you are thinking of "traditional" IPC methods (side note, which of the 15+ current IPC methods do you consider "traditional", we have a lot of them these days...)

Quoted 1 line

You were comparing kdbus and Binder. Why?

Why not? :)

Seriously, they are related in a way, see my long blog post for all of the details about it if you are curious.

Quoted 4 lines

So far my impression is that D-Bus and Binder are completely seperate things, not just because of
the thread vs. event-loop programming model but
also because Binder is not a bus (i.e. no multicast messaging).

People compare them a lot, which is why I brought it up, it's a discussion that needed to be made.

Quoted 4 lines
Quoted 1 line

Hope this helps,

Well, it made your intentions a bit clearer, but it does not help to sell kdbus to me, sorry ;-/

It's not my "goal" to sell kdbus to you, if you don't want it, great, don't worry about it, don't build it on your kernels, and the world will be fine. Consider it like any other "driver" or filesystem, if you don't need it, there's nothing to even discuss.

But odds are, you are using a system with D-Bus today, if not, then you are using Linux in a very specific and limited manner, which is wonderful, in that case this whole thread isn't really pertinent.

Lots of people do use D-Bus, and for those users, that is what this patchset is for.

Hope that helps clear things up,

greg k-h

#76 lore raw
Quoted 8 lines · Greg Kroah-Hartman
Quoted 4 lines · Johannes Stezenbach

These two statements somehow contradict. From my admittedly very limited experience, I never used D-Bus because it did not fit my usage scenarios: I never needed a bus, only point-to-point links like pipes or sockets.

Great, then you don't need this, no need to worry about it at all, why are we having this conversation? :)

Well, for one because that's what I wanted to find out...

Quoted 4 lines
Quoted 2 lines

Well, it made your intentions a bit clearer, but it does not help to sell kdbus to me, sorry ;-/

It's not my "goal" to sell kdbus to you, if you don't want it, great,

I used this language because I think you're not providing the facts that would allow me to judge for myself whether kdbus is a good idea. Those automotive applications you were talking about, what was the OS they were ported from and what was the messaging API they used?

Quoted 6 lines

But odds are, you are using a system with D-Bus today, if not, then you are using Linux in a very specific and limited manner, which is wonderful, in that case this whole thread isn't really pertinent.

Lots of people do use D-Bus, and for those users, that is what this patchset is for.

As I said before, I'm seeing about a dozen D-Bus messages per minute, nothing that would justify adding kdbus to the kernel for performance reasons. Wrt security I'm also not aware of any open issues with D-Bus. Thus I doubt normal users of D-Bus would see any benefit from kdbus. I also think none of the applications I can install from my distribution has any performance issue with D-Bus.

And this is the point where I ask myself if I missed something.

Thanks,
Johannes

#77 lore raw
Quoted 15 lines · Johannes Stezenbach
Quoted 8 lines · Greg Kroah-Hartman
Quoted 4 lines · Johannes Stezenbach

These two statements somehow contradict. From my admittedly very limited experience, I never used D-Bus because it did not fit my usage scenarios: I never needed a bus, only point-to-point links like pipes or sockets.

Great, then you don't need this, no need to worry about it at all, why are we having this conversation? :)

Well, for one because that's what I wanted to find out...

Quoted 3 lines
Quoted 2 lines

Well, it made your intentions a bit clearer, but it does not help to sell kdbus to me, sorry ;-/

Quoted 7 lines
Quoted 1 line

It's not my "goal" to sell kdbus to you, if you don't want it, great,

I used this language because I think you're not providing the facts that would allow me to judge for myself whether kdbus is a good idea. Those automotive applications you were talking about, what was the OS they were ported from and what was the messaging API they used?

They were ported from QNX and I don't know the exact api, it is wrapped up in a library layer for them to use. And typically, they run about 40 thousand messages in the first few seconds of startup time. Or was it 400 thousand? Something huge and crazy to be doing on tiny ARM chips, but that's the IVI industry for you :(

Quoted 7 lines
Quoted 6 lines

But odds are, you are using a system with D-Bus today, if not, then you are using Linux in a very specific and limited manner, which is wonderful, in that case this whole thread isn't really pertinent.

Lots of people do use D-Bus, and for those users, that is what this patchset is for.

Quoted 7 lines

As I said before, I'm seeing about a dozen D-Bus messages per minute, nothing that would justify adding kdbus to the kernel for performance reasons. Wrt security I'm also not aware of any open issues with D-Bus. Thus I doubt normal users of D-Bus would see any benefit from kdbus. I also think none of the applications I can install from my distribution has any performance issue with D-Bus.

That's because people have not done anything really needing performance on the desktop over D-Bus in the past due to how slow the current implementation is. Now that this is being resolved, that can change, and there are demos out there of even streaming audio over kdbus with no problems.

But performance is not just the only reason we want this in the kernel, I listed a whole long range of them. Sure, it's great to now be faster, cutting down the number of context switches and copies by a huge amount, but the other things are equally important for future development (namespaces, containers, security, early-boot, etc.)

Quoted 1 line

And this is the point where I ask myself if I missed something.

Don't focus purely on performance for your existing desktop system, that's not the only use case here. There are lots of others, as I document, that can benefit and want this.

One "fun" thing I've been talking to someone about is the ability to even port binder to be on top of kdbus. But that's just a research project, and requires some API changes on the userspace binder side, but it shows real promise, and would then mean that we could deprecate the old binder code and a few hundred million devices could then use kdbus instead. But that's long-term goals, not really all that relevant here, but it shows that having a solid bus IPC mechanism is a powerful thing that we have been missing in the past from Linux.

thanks,

greg k-h

#78 lore raw
Quoted 10 lines · Greg Kroah-Hartman
Quoted 3 lines · Johannes Stezenbach

Those automotive applications you
were talking about, what was the OS they were ported from and what was the messaging API they used?

They were ported from QNX and I don't know the exact api, it is wrapped up in a library layer for them to use. And typically, they run about 40 thousand messages in the first few seconds of startup time. Or was it 400 thousand? Something huge and crazy to be doing on tiny ARM chips, but that's the IVI industry for you :(

So I did some googling and found in QNX servers create a channel to receive messages, and clients connect to this channel. Multiple clients can connect to the channel.
But it is not a bus -- no multicast/broadcast, and no name service or policy rules like D-Bus has. To me it looks to be similar in functionality to UNIX domain sockets.

My guess is that the people porting from QNX were just confused and their use of D-Bus was in error. Maybe they should've used plain sockets, capnproto, ZeroMQ or whatever.

Quoted 26 lines
Quoted 7 lines

As I said before, I'm seeing about a dozen D-Bus messages per minute, nothing that would justify adding kdbus to the kernel for performance reasons. Wrt security I'm also not aware of any open issues with D-Bus. Thus I doubt normal users of D-Bus would see any benefit from kdbus. I also think none of the applications I can install from my distribution has any performance issue with D-Bus.

That's because people have not done anything really needing performance on the desktop over D-Bus in the past due to how slow the current implementation is. Now that this is being resolved, that can change, and there are demos out there of even streaming audio over kdbus with no problems.

But performance is not just the only reason we want this in the kernel, I listed a whole long range of them. Sure, it's great to now be faster, cutting down the number of context switches and copies by a huge amount, but the other things are equally important for future development (namespaces, containers, security, early-boot, etc.)

Quoted 1 line

And this is the point where I ask myself if I missed something.

Don't focus purely on performance for your existing desktop system, that's not the only use case here. There are lots of others, as I document, that can benefit and want this.

Quoted 8 lines

One "fun" thing I've been talking to someone about is the ability to even port binder to be on top of kdbus. But that's just a research project, and requires some API changes on the userspace binder side, but it shows real promise, and would then mean that we could deprecate the old binder code and a few hundred million devices could then use kdbus instead. But that's long-term goals, not really all that relevant here, but it shows that having a solid bus IPC mechanism is a powerful thing that we have been missing in the past from Linux.

Well, IMHO you got it backwards. Before adding a complex new IPC API to the kernel you should do the homework and gather some evidence that there will be enough users to justify the addition.

But maybe I misunderstood the purpose of this thread and you're just advertising it to find possible users instead of already suggesting to merge it? If someone has some convincing story to share why kdbus would solve their IPC needs, I'm all ears.

(I'm sorry this implies your responses so far were not convincing:
not verifiable facts, no numbers, no testimonials etc.)

FWIW, my gut feeling was that the earlier attempts to add a new IPC primitve like multicast UNIX domain sockets
http://thread.gmane.org/gmane.linux.kernel/1255575/focus=1257999
were a much saner approach. But now I think the comments from this old thread have not been addressed, instead the new approach just made the thing more complex and
put in ipc/ instead of net/ to bypass the guards.

Thanks,
Johannes

#79 lore raw
Quoted 12 lines · Johannes Stezenbach
Quoted 10 lines · Greg Kroah-Hartman
Quoted 3 lines · Johannes Stezenbach

Those automotive applications you
were talking about, what was the OS they were ported from and what was the messaging API they used?

They were ported from QNX and I don't know the exact api, it is wrapped up in a library layer for them to use. And typically, they run about 40 thousand messages in the first few seconds of startup time. Or was it 400 thousand? Something huge and crazy to be doing on tiny ARM chips, but that's the IVI industry for you :(

Quoted 3 lines

So I did some googling and found in QNX servers create a channel to receive messages, and clients connect to this channel. Multiple clients can connect to the channel.

Hence, a bus :)

Quoted 3 lines

But it is not a bus -- no multicast/broadcast, and no name service or policy rules like D-Bus has. To me it looks to be similar in functionality to UNIX domain sockets.

It's not as complex as D-Bus, but it's still subscribing to things and getting messages.

Quoted 3 lines

My guess is that the people porting from QNX were just confused and their use of D-Bus was in error. Maybe they should've used plain sockets, capnproto, ZeroMQ or whatever.

I tend to trust that they knew what they were doing, they wouldn't have picked D-Bus for no good reason.

Quoted 3 lines

Well, IMHO you got it backwards. Before adding a complex new IPC API to the kernel you should do the homework and gather some evidence that there will be enough users to justify the addition.

systemd wants this today for early boot. It will remove lots of code and enable a lot of good things to happen. The first email in this thread describes this quite well, is that not sufficient?

Quoted 7 lines

FWIW, my gut feeling was that the earlier attempts to add a new IPC primitve like multicast UNIX domain sockets
http://thread.gmane.org/gmane.linux.kernel/1255575/focus=1257999
were a much saner approach. But now I think the comments from this old thread have not been addressed, instead the new approach just made the thing more complex and
put in ipc/ instead of net/ to bypass the guards.

Not at all, the networking maintainers said that that proposal was not acceptable to them at all and it should not be done in the networking stack at all. So this was solution was created instead, which provides a lot more things than the old networking patches did, which shows that the networking developers were right to reject it.

thanks,

greg k-h

#80 lore raw
Quoted 6 lines · Greg Kroah-Hartman
Quoted 4 lines · Johannes Stezenbach

So I did some googling and found in QNX servers create a channel to receive messages, and clients connect to this channel. Multiple clients can connect to the channel.

Quoted 8 lines

Hence, a bus :)

Quoted 3 lines

But it is not a bus -- no multicast/broadcast, and no name service or policy rules like D-Bus has. To me it looks to be similar in functionality to UNIX domain sockets.

It's not as complex as D-Bus, but it's still subscribing to things and getting messages.

Apparently you don't read what I write, probably you're not interested in this discussion anymore...
QNX uses the term "channel" but it does not refer to a bus or subscription facility, it is more like a socket in listening state.

Quoted 6 lines
Quoted 3 lines

My guess is that the people porting from QNX were just confused and their use of D-Bus was in error. Maybe they should've used plain sockets, capnproto, ZeroMQ or whatever.

I tend to trust that they knew what they were doing, they wouldn't have picked D-Bus for no good reason.

The automotive developers I had the pleasure to work with would use anything which is available via a mouse click in the commercial Embedded Linux SDK IDE of their choice :) Let's face it: QNX has a single IPC solution while Linux has a confusing multitude of possibilities.

Quoted 7 lines
Quoted 3 lines

Well, IMHO you got it backwards. Before adding a complex new IPC API to the kernel you should do the homework and gather some evidence that there will be enough users to justify the addition.

systemd wants this today for early boot. It will remove lots of code and enable a lot of good things to happen. The first email in this thread describes this quite well, is that not sufficient?

The first mail in this thread doesn't even mention systemd, instead it has a lot of "marketing" buzzwords.
Of course it is no secret that systemd is the driving force behind kdbus, but no public record exists to explain why kdbus was chosen and designed the way it is, what alternatives were considered and rejected etc. (or if there is, please send a link)

Quoted 8 lines
Quoted 7 lines

FWIW, my gut feeling was that the earlier attempts to add a new IPC primitve like multicast UNIX domain sockets
http://thread.gmane.org/gmane.linux.kernel/1255575/focus=1257999
were a much saner approach. But now I think the comments from this old thread have not been addressed, instead the new approach just made the thing more complex and
put in ipc/ instead of net/ to bypass the guards.

Quoted 5 lines

Not at all, the networking maintainers said that that proposal was not acceptable to them at all and it should not be done in the networking stack at all. So this was solution was created instead, which provides a lot more things than the old networking patches did, which shows that the networking developers were right to reject it.

Please read the gmane thread to the end. It seems there were several indications that D-Bus can be improved in userspace using existing kernel facilities. Havoc Pennington's mail I quoted in my first response also contains some hints about it. I have no idea if any of this has ever been pursued. While adding complexity to critical net/ code paths is probematic and a good reason to reject it, this was not the only reason, the major one being "not neccessary".

Thanks,
Johannes

#81 lore raw
Quoted 7 lines · Johannes Stezenbach
Quoted 6 lines · Greg Kroah-Hartman
Quoted 3 lines · Johannes Stezenbach

My guess is that the people porting from QNX were just confused and their use of D-Bus was in error. Maybe they should've used plain sockets, capnproto, ZeroMQ or whatever.

Quoted 8 lines
Quoted 2 lines

I tend to trust that they knew what they were doing, they wouldn't have picked D-Bus for no good reason.

The automotive developers I had the pleasure to work with would use anything which is available via a mouse click in the commercial Embedded Linux SDK IDE of their choice :) Let's face it: QNX has a single IPC solution while Linux has a confusing multitude of possibilities.

Greg, from my spell in IVI, I too have to say your faith in the wisdom of IVI developers' choices is touching. I think D-Bus was in the main picked because it had some nice features, but then people realized it had no bandwidth, and the solution has been "make D-Bus faster", rather than "maybe we should explore other (mixed model) solutions". This isn't to say that I'm against adding kdbus, but I don't think there's much strength to the argument you make above.

Cheers,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#82 lore raw
In reply to Greg Kroah-Hartman

On Tue, 20 Jan 2015 09:13:59 +0800

Quoted 3 lines

That's because people have not done anything really needing performance on the desktop over D-Bus in the past due to how slow the current implementation is.

The desktop is a performance critical environment, even though certain desktop developers think 2GB is a bit small to run an application and 5000 dbus transactions to start something is "ok"

Alan

#83 lore raw
In reply to Greg Kroah-Hartman

(resend, fix Daniel's email address)

Hi Greg and Daniel,

I don't have a clue so I need to ask some stupid questions...

Quoted 6 lines · Greg Kroah-Hartman

kdbus is a kernel-level IPC implementation that aims for resemblance to the the protocol layer with the existing userspace D-Bus daemon while enabling some features that couldn't be implemented before in userspace.

The documentation in the first patch in this series explains the protocol and the API details.

How about the big picture?

Quoted 2 lines

Reasons why this should be done in the kernel, instead of userspace as it is currently done today include the following:

[abbreviated]

Quoted 3 lines

- performance
- security
- semantics for apps with heavy data payloads

First of all I wonder about the relationship with D-Bus.
http://dbus.freedesktop.org/doc/dbus-specification.html says:

D-Bus is designed for two specific use cases:

A "system bus" for notifications from the system to user sessions, and to allow the system to request input from user sessions.

A "session bus" used to implement desktop environments such as GNOME and KDE.

D-Bus is not intended to be a generic IPC system for any possible application, and intentionally omits many features found in other IPC systems for this reason.

Does this also apply to kdbus? If not, what are the suggested uses of kdbus beyond those where D-Bus is currently used?

Another related quote by Havoc Pennington:
http://lists.freedesktop.org/archives/dbus/2012-March/015024.html

In general, reading this, I think in some cases there are problems that make sense to fix in dbus, and in other cases there are problems that are best solved by not using dbus.
...
there are about 10000 IPC solutions already, from ICE (both of them) to ZeroMQ to AMQP to CORBA to X11 to HTTP to SOAP to WebSockets to SUN-RPC to whatever-the-heck. To me, trying to make dbus configurable so that it can substitute for any of these is a Bad Idea (tm).

Do you think it also applies to kdbus?

Wrt the performance improvement achieved by kdbus, my impression about D-Bus is that the number of messages on my system is about a dozen per minute. Are there actually any existing applications using D-Bus that have a performance issue? Or is this only about future possible uses?

Linked from http://kroah.com/log/blog/2014/01/15/kdbus-details/,
http://lwn.net/Articles/580194/ "The unveiling of kdbus" says:

Unlike most other kernels, Linux has never had a well-designed IPC mechanism. Windows and Mac OS have this feature; even Android, based on Linux, has one in the form of the "binder" subsystem. Linux, instead, has only had the primitives — sockets, FIFOs, and shared memory — but those have never been knitted together into a reasonable application-level API. Kdbus is an attempt to do that knitting and create something that is at least as good as the mechanisms found on other systems.

These are bold words. I'm not sure what Windows and Mac OS have in terms of IPC, but the above suggests that kdbus is *the* new Linux IPC that everyone will use for everything, rather than a special purpose facility.
True?

Thanks,
Johannes

#84 lore raw
In reply to Greg Kroah-Hartman
Quoted 55 lines · Greg Kroah-Hartman

kdbus is a kernel-level IPC implementation that aims for resemblance to the the protocol layer with the existing userspace D-Bus daemon while enabling some features that couldn't be implemented before in userspace.

The documentation in the first patch in this series explains the protocol and the API details.

Full details on what has changed from the v2 submission are at the bottom of this email.

Reasons why this should be done in the kernel, instead of userspace as it is currently done today include the following:

- performance: fewer process context switches, fewer copies, fewer syscalls, larger memory chunks via memfd. This is really important for a whole class of userspace programs that are ported from other operating systems that are run on tiny ARM systems that rely on hundreds of thousands of messages passed at boot time, and at "critical" times in their user interaction loops.
- security: the peers which communicate do not have to trust each other, as the only trustworthy compoenent in the game is the kernel which adds metadata and ensures that all data passed as payload is either copied or sealed, so that the receiver can parse the data without having to protect against changing memory while parsing buffers. Also, all the data transfer is controlled by the kernel, so that LSMs can track and control what is going on, without involving userspace. Because of the LSM issue, security people are much happier with this model than the current scheme of having to hook into dbus to mediate things.
- more metadata can be attached to messages than in userspace
- semantics for apps with heavy data payloads (media apps, for instance) with optinal priority message dequeuing, and global message ordering. Some "crazy" people are playing with using kdbus for audio data in the system. I'm not saying that this is the best model for this, but until now, there wasn't any other way to do this without having to create custom "busses", one for each application library.
- being in the kernle closes a lot of races which can't be fixed with the current userspace solutions. For example, with kdbus, there is a way a client can disconnect from a bus, but do so only if no further messages present in its queue, which is crucial for implementing race-free "exit-on-idle" services
- eavesdropping on the kernel level, so privileged users can hook into the message stream without hacking support for that into their userspace processes
- a number of smaller benefits: for example kdbus learned a way to peek full messages without dequeing them, which is really useful for logging metadata when handling bus-activation requests.

Of course, some of the bits above could be implemented in userspace alone, for example with more sophisticated memory management APIs, but this is usually done by losing out on the other details. For example, for many of the memory management APIs, it's hard to not require the communicating peers to fully trust each other. And we _really_ don't want peers to have to trust each other.

Quoted 9 lines

Another benefit of having this in the kernel, rather than as a userspace daemon, is that you can now easily use the bus from the initrd, or up to the very end when the system shuts down. On current userspace D-Bus, this is not really possible, as this requires passing the bus instance around between initrd and the "real" system. Such a transition of all fds also requires keeping full state of what has already been read from the connection fds. kdbus makes this much simpler, as we can change the ownership of the bus, just by passing one fd over from one part to the other.

I tend to think that much of the above should also be part of the documentation file (patch 01/13).

Cheers,

Michael

Quoted 289 lines

Regarding binder: binder and kdbus follow very different design concepts. Binder implies the use of thread-pools to dispatch incoming method calls. This is a very efficient scheme, and completely natural in programming languages like Java. On most Linux programs, however, there's a much stronger focus on central poll() loops that dispatch all sources a program cares about. kdbus is much more usable in such environments, as it doesn't enforce a threading model, and it is happy with serialized dispatching. In fact, this major difference had an effect on much of the design decisions: binder does not guarantee global message ordering due to the parallel dispatching in the thread-pools, but kdbus does. Moreover, there's also a difference in the way message handling. In kdbus, every message is basically taken and dispatched as one blob, while in binder, continious connections to other peers are created, which are then used to send messages on. Hence, the models are quite different, and they serve different needs. I believe that the D-Bus/kdbus model is more compatible and friendly with how Linux programs are usually implemented.

This can also be found in a git tree, the kdbus branch of char-misc.git at:
https://git.kernel.org/cgit/linux/kernel/git/gregkh/char-misc.git/

Changes since v2:

* Add FS_USERNS_MOUNT to the file system flags, so users can mount their own kdbusfs instances without being root in the parent user-ns. Spotted by Andy Lutomirski.

* Rewrite major parts of the metadata implementation to allow for per-recipient namespace translations. For this, namespaces are now not pinned by domains anymore. Instead, metadata is recorded in kernel scope, and exported into the currently active namespaces at the time of message installing.

* Split PID and TID from KDBUS_ITEM_CREDS into KDBUS_ITEM_PIDS. The starttime is there to detect re-used PIDs, so move it to that new item type as well. Consequently, introduce struct kdbus_pids to accommodate the information. Requested by Andy Lutomirski.

* Add {e,s,fs}{u,g}id to KDBUS_ITEM_CREDS, so users have a way to get more fine-grained credential information.

* Removed KDBUS_CMD_CANCEL. The interface was not usable from threaded userspace implementation due to inherent races. Instead, add an item type CANCEL_FD which can be used to pass a file descriptor to the CMD_SEND ioctl. When the SEND is done synchronously, it will get cancelled as soon as the passed FD signals POLLIN.

* Dropped startttime from KDBUS_ITEM_PIDS

* Restrict names of custom endpoints to names with a "<uid>-" prefix, just like we do for buses.

* Provide module-parameter "kdbus.attach_flags_mask" to specify the a mask of metadata items that is applied on all exported items.

* Monitors are now entirely invisible (IOW, there won't be any notification when they are created) and they don't need to install filters for broadcast messages anymore.

* All information exposed via a connection's pool now also reports the length in addition to the offset. That way, userspace applications can mmap() only parts of the pool on demand.

* Due to the metadata rework, KDBUS_ITEM_PAYLOAD_OFF items now describe the offset relative to the pool, where they used to be relative to the message header.

* Added return_flags bitmask to all kdbus_cmd_* structs, so the kernel can report details of the command processing. This is mostly reserved for future extensions.

* Some fixes in kdbus.txt and tests, spotted by Harald Hoyer, Andy Lutomirski, Michele Curti, Sergei Zviagintsev, Sheng Yong, Torstein Husebø and Hristo Venev.

* Fixed compiler warnings in test-message by Michele Curti

* Unexpected items are now rejected with -EINVAL

* Split signal and broadcast handling. Unicast signals are now supported, and messages have a new KDBUS_MSG_SIGNAL flag.

* KDBUS_CMD_MSG_SEND was renamed to KDBUS_CMD_SEND, and now takes a struct kdbus_cmd_send instead of a kdbus_msg.

* KDBUS_CMD_MSG_RECV was renamed to KDBUS_CMD_RECV.

* Test case memory leak plugged, and various other cleanups and fixes, by Rui Miguel Silva.

* Build fix for s390

* Test case fix for 32bit archs

* The test framework now supports mount, pid and user namespaces.

* The test framework learned a --tap command line parameter to format its output in the "Test Anything Protocol". This format is chosen by default when "make kselftest" is invoked.

* Fixed buses and custom endpoints name validation, reported by Andy Lutomirski.

* copy_from_user() return code issue fixed, reported by Dan Carpenter.

* Avoid signed int overflow on archs without atomic_sub

* Avoid variable size stack items. Fixes a sparse warning in queue.c.

* New test case for kernel notification quota

* Switched back to enums for the list of ioctls. This has advantages for userspace code as gdb, for instance, is able to resolve the numbers into names. Added features can easily be detected with autotools, and new iotcls can get #defines as well. Having #defines for the initial set of ioctls is uncecessary.

Daniel Mack (13):
kdbus: add documentation
kdbus: add header file
kdbus: add driver skeleton, ioctl entry points and utility functions
kdbus: add connection pool implementation
kdbus: add connection, queue handling and message validation code
kdbus: add node and filesystem implementation
kdbus: add code to gather metadata
kdbus: add code for notifications and matches
kdbus: add code for buses, domains and endpoints
kdbus: add name registry implementation
kdbus: add policy database implementation
kdbus: add Makefile, Kconfig and MAINTAINERS entry
kdbus: add selftests

 Documentation/ioctl/ioctl-number.txt              |    1 +
 Documentation/kdbus.txt                           | 2107 +++++++++++++++++++++
 MAINTAINERS                                       |   12 +
 include/uapi/linux/Kbuild                         |    1 +
 include/uapi/linux/kdbus.h                        | 1049 ++++++++++
 include/uapi/linux/magic.h                        |    2 +
 init/Kconfig                                      |   12 +
 ipc/Makefile                                      |    2 +-
 ipc/kdbus/Makefile                                |   22 +
 ipc/kdbus/bus.c                                   |  553 ++++++
 ipc/kdbus/bus.h                                   |  103 +
 ipc/kdbus/connection.c                            | 2004 ++++++++++++++++++++
 ipc/kdbus/connection.h                            |  262 +++
 ipc/kdbus/domain.c                                |  350 ++++
 ipc/kdbus/domain.h                                |   84 +
 ipc/kdbus/endpoint.c                              |  232 +++
 ipc/kdbus/endpoint.h                              |   68 +
 ipc/kdbus/fs.c                                    |  519 +++++
 ipc/kdbus/fs.h                                    |   25 +
 ipc/kdbus/handle.c                                | 1134 +++++++++++
 ipc/kdbus/handle.h                                |   20 +
 ipc/kdbus/item.c                                  |  309 +++
 ipc/kdbus/item.h                                  |   57 +
 ipc/kdbus/limits.h                                |   95 +
 ipc/kdbus/main.c                                  |   72 +
 ipc/kdbus/match.c                                 |  535 ++++++
 ipc/kdbus/match.h                                 |   32 +
 ipc/kdbus/message.c                               |  598 ++++++
 ipc/kdbus/message.h                               |  133 ++
 ipc/kdbus/metadata.c                              | 1066 +++++++++++
 ipc/kdbus/metadata.h                              |   52 +
 ipc/kdbus/names.c                                 |  891 +++++++++
 ipc/kdbus/names.h                                 |   82 +
 ipc/kdbus/node.c                                  |  910 +++++++++
 ipc/kdbus/node.h                                  |   87 +
 ipc/kdbus/notify.c                                |  244 +++
 ipc/kdbus/notify.h                                |   30 +
 ipc/kdbus/policy.c                                |  481 +++++
 ipc/kdbus/policy.h                                |   51 +
 ipc/kdbus/pool.c                                  |  784 ++++++++
 ipc/kdbus/pool.h                                  |   47 +
 ipc/kdbus/queue.c                                 |  505 +++++
 ipc/kdbus/queue.h                                 |  108 ++
 ipc/kdbus/reply.c                                 |  262 +++
 ipc/kdbus/reply.h                                 |   68 +
 ipc/kdbus/util.c                                  |  317 ++++
 ipc/kdbus/util.h                                  |  133 ++
 tools/testing/selftests/Makefile                  |    1 +
 tools/testing/selftests/kdbus/.gitignore          |   11 +
 tools/testing/selftests/kdbus/Makefile            |   46 +
 tools/testing/selftests/kdbus/kdbus-enum.c        |   95 +
 tools/testing/selftests/kdbus/kdbus-enum.h        |   14 +
 tools/testing/selftests/kdbus/kdbus-test.c        |  920 +++++++++
 tools/testing/selftests/kdbus/kdbus-test.h        |   85 +
 tools/testing/selftests/kdbus/kdbus-util.c        | 1646 ++++++++++++++++
 tools/testing/selftests/kdbus/kdbus-util.h        |  216 +++
 tools/testing/selftests/kdbus/test-activator.c    |  319 ++++
 tools/testing/selftests/kdbus/test-attach-flags.c |  751 ++++++++
 tools/testing/selftests/kdbus/test-benchmark.c    |  427 +++++
 tools/testing/selftests/kdbus/test-bus.c          |  174 ++
 tools/testing/selftests/kdbus/test-chat.c         |  123 ++
 tools/testing/selftests/kdbus/test-connection.c   |  611 ++++++
 tools/testing/selftests/kdbus/test-daemon.c       |   66 +
 tools/testing/selftests/kdbus/test-endpoint.c     |  344 ++++
 tools/testing/selftests/kdbus/test-fd.c           |  710 +++++++
 tools/testing/selftests/kdbus/test-free.c         |   36 +
 tools/testing/selftests/kdbus/test-match.c        |  442 +++++
 tools/testing/selftests/kdbus/test-message.c      |  658 +++++++
 tools/testing/selftests/kdbus/test-metadata-ns.c  |  507 +++++
 tools/testing/selftests/kdbus/test-monitor.c      |  158 ++
 tools/testing/selftests/kdbus/test-names.c        |  184 ++
 tools/testing/selftests/kdbus/test-policy-ns.c    |  633 +++++++
 tools/testing/selftests/kdbus/test-policy-priv.c  | 1270 +++++++++++++
 tools/testing/selftests/kdbus/test-policy.c       |   81 +
 tools/testing/selftests/kdbus/test-race.c         |  313 +++
 tools/testing/selftests/kdbus/test-sync.c         |  368 ++++
 tools/testing/selftests/kdbus/test-timeout.c      |   99 +
 77 files changed, 27818 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/kdbus.txt
 create mode 100644 include/uapi/linux/kdbus.h
 create mode 100644 ipc/kdbus/Makefile
 create mode 100644 ipc/kdbus/bus.c
 create mode 100644 ipc/kdbus/bus.h
 create mode 100644 ipc/kdbus/connection.c
 create mode 100644 ipc/kdbus/connection.h
 create mode 100644 ipc/kdbus/domain.c
 create mode 100644 ipc/kdbus/domain.h
 create mode 100644 ipc/kdbus/endpoint.c
 create mode 100644 ipc/kdbus/endpoint.h
 create mode 100644 ipc/kdbus/fs.c
 create mode 100644 ipc/kdbus/fs.h
 create mode 100644 ipc/kdbus/handle.c
 create mode 100644 ipc/kdbus/handle.h
 create mode 100644 ipc/kdbus/item.c
 create mode 100644 ipc/kdbus/item.h
 create mode 100644 ipc/kdbus/limits.h
 create mode 100644 ipc/kdbus/main.c
 create mode 100644 ipc/kdbus/match.c
 create mode 100644 ipc/kdbus/match.h
 create mode 100644 ipc/kdbus/message.c
 create mode 100644 ipc/kdbus/message.h
 create mode 100644 ipc/kdbus/metadata.c
 create mode 100644 ipc/kdbus/metadata.h
 create mode 100644 ipc/kdbus/names.c
 create mode 100644 ipc/kdbus/names.h
 create mode 100644 ipc/kdbus/node.c
 create mode 100644 ipc/kdbus/node.h
 create mode 100644 ipc/kdbus/notify.c
 create mode 100644 ipc/kdbus/notify.h
 create mode 100644 ipc/kdbus/policy.c
 create mode 100644 ipc/kdbus/policy.h
 create mode 100644 ipc/kdbus/pool.c
 create mode 100644 ipc/kdbus/pool.h
 create mode 100644 ipc/kdbus/queue.c
 create mode 100644 ipc/kdbus/queue.h
 create mode 100644 ipc/kdbus/reply.c
 create mode 100644 ipc/kdbus/reply.h
 create mode 100644 ipc/kdbus/util.c
 create mode 100644 ipc/kdbus/util.h
 create mode 100644 tools/testing/selftests/kdbus/.gitignore
 create mode 100644 tools/testing/selftests/kdbus/Makefile
 create mode 100644 tools/testing/selftests/kdbus/kdbus-enum.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-enum.h
 create mode 100644 tools/testing/selftests/kdbus/kdbus-test.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-test.h
 create mode 100644 tools/testing/selftests/kdbus/kdbus-util.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-util.h
 create mode 100644 tools/testing/selftests/kdbus/test-activator.c
 create mode 100644 tools/testing/selftests/kdbus/test-attach-flags.c
 create mode 100644 tools/testing/selftests/kdbus/test-benchmark.c
 create mode 100644 tools/testing/selftests/kdbus/test-bus.c
 create mode 100644 tools/testing/selftests/kdbus/test-chat.c
 create mode 100644 tools/testing/selftests/kdbus/test-connection.c
 create mode 100644 tools/testing/selftests/kdbus/test-daemon.c
 create mode 100644 tools/testing/selftests/kdbus/test-endpoint.c
 create mode 100644 tools/testing/selftests/kdbus/test-fd.c
 create mode 100644 tools/testing/selftests/kdbus/test-free.c
 create mode 100644 tools/testing/selftests/kdbus/test-match.c
 create mode 100644 tools/testing/selftests/kdbus/test-message.c
 create mode 100644 tools/testing/selftests/kdbus/test-metadata-ns.c
 create mode 100644 tools/testing/selftests/kdbus/test-monitor.c
 create mode 100644 tools/testing/selftests/kdbus/test-names.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy-ns.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy-priv.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy.c
 create mode 100644 tools/testing/selftests/kdbus/test-race.c
 create mode 100644 tools/testing/selftests/kdbus/test-sync.c
 create mode 100644 tools/testing/selftests/kdbus/test-timeout.c

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#85 lore raw
In reply to Greg Kroah-Hartman

[Bother. Futzed Daniel Mack's email address. Resending]

Quoted 55 lines · Greg Kroah-Hartman

kdbus is a kernel-level IPC implementation that aims for resemblance to the the protocol layer with the existing userspace D-Bus daemon while enabling some features that couldn't be implemented before in userspace.

The documentation in the first patch in this series explains the protocol and the API details.

Full details on what has changed from the v2 submission are at the bottom of this email.

Reasons why this should be done in the kernel, instead of userspace as it is currently done today include the following:

- performance: fewer process context switches, fewer copies, fewer syscalls, larger memory chunks via memfd. This is really important for a whole class of userspace programs that are ported from other operating systems that are run on tiny ARM systems that rely on hundreds of thousands of messages passed at boot time, and at "critical" times in their user interaction loops.
- security: the peers which communicate do not have to trust each other, as the only trustworthy compoenent in the game is the kernel which adds metadata and ensures that all data passed as payload is either copied or sealed, so that the receiver can parse the data without having to protect against changing memory while parsing buffers. Also, all the data transfer is controlled by the kernel, so that LSMs can track and control what is going on, without involving userspace. Because of the LSM issue, security people are much happier with this model than the current scheme of having to hook into dbus to mediate things.
- more metadata can be attached to messages than in userspace
- semantics for apps with heavy data payloads (media apps, for instance) with optinal priority message dequeuing, and global message ordering. Some "crazy" people are playing with using kdbus for audio data in the system. I'm not saying that this is the best model for this, but until now, there wasn't any other way to do this without having to create custom "busses", one for each application library.
- being in the kernle closes a lot of races which can't be fixed with the current userspace solutions. For example, with kdbus, there is a way a client can disconnect from a bus, but do so only if no further messages present in its queue, which is crucial for implementing race-free "exit-on-idle" services
- eavesdropping on the kernel level, so privileged users can hook into the message stream without hacking support for that into their userspace processes
- a number of smaller benefits: for example kdbus learned a way to peek full messages without dequeing them, which is really useful for logging metadata when handling bus-activation requests.

Of course, some of the bits above could be implemented in userspace alone, for example with more sophisticated memory management APIs, but this is usually done by losing out on the other details. For example, for many of the memory management APIs, it's hard to not require the communicating peers to fully trust each other. And we _really_ don't want peers to have to trust each other.

Quoted 9 lines

Another benefit of having this in the kernel, rather than as a userspace daemon, is that you can now easily use the bus from the initrd, or up to the very end when the system shuts down. On current userspace D-Bus, this is not really possible, as this requires passing the bus instance around between initrd and the "real" system. Such a transition of all fds also requires keeping full state of what has already been read from the connection fds. kdbus makes this much simpler, as we can change the ownership of the bus, just by passing one fd over from one part to the other.

I tend to think that much of the above should also be part of the documentation file (patch 01/13).

Cheers,

Michael

Quoted 289 lines

Regarding binder: binder and kdbus follow very different design concepts. Binder implies the use of thread-pools to dispatch incoming method calls. This is a very efficient scheme, and completely natural in programming languages like Java. On most Linux programs, however, there's a much stronger focus on central poll() loops that dispatch all sources a program cares about. kdbus is much more usable in such environments, as it doesn't enforce a threading model, and it is happy with serialized dispatching. In fact, this major difference had an effect on much of the design decisions: binder does not guarantee global message ordering due to the parallel dispatching in the thread-pools, but kdbus does. Moreover, there's also a difference in the way message handling. In kdbus, every message is basically taken and dispatched as one blob, while in binder, continious connections to other peers are created, which are then used to send messages on. Hence, the models are quite different, and they serve different needs. I believe that the D-Bus/kdbus model is more compatible and friendly with how Linux programs are usually implemented.

This can also be found in a git tree, the kdbus branch of char-misc.git at:
https://git.kernel.org/cgit/linux/kernel/git/gregkh/char-misc.git/

Changes since v2:

* Add FS_USERNS_MOUNT to the file system flags, so users can mount their own kdbusfs instances without being root in the parent user-ns. Spotted by Andy Lutomirski.

* Rewrite major parts of the metadata implementation to allow for per-recipient namespace translations. For this, namespaces are now not pinned by domains anymore. Instead, metadata is recorded in kernel scope, and exported into the currently active namespaces at the time of message installing.

* Split PID and TID from KDBUS_ITEM_CREDS into KDBUS_ITEM_PIDS. The starttime is there to detect re-used PIDs, so move it to that new item type as well. Consequently, introduce struct kdbus_pids to accommodate the information. Requested by Andy Lutomirski.

* Add {e,s,fs}{u,g}id to KDBUS_ITEM_CREDS, so users have a way to get more fine-grained credential information.

* Removed KDBUS_CMD_CANCEL. The interface was not usable from threaded userspace implementation due to inherent races. Instead, add an item type CANCEL_FD which can be used to pass a file descriptor to the CMD_SEND ioctl. When the SEND is done synchronously, it will get cancelled as soon as the passed FD signals POLLIN.

* Dropped startttime from KDBUS_ITEM_PIDS

* Restrict names of custom endpoints to names with a "<uid>-" prefix, just like we do for buses.

* Provide module-parameter "kdbus.attach_flags_mask" to specify the a mask of metadata items that is applied on all exported items.

* Monitors are now entirely invisible (IOW, there won't be any notification when they are created) and they don't need to install filters for broadcast messages anymore.

* All information exposed via a connection's pool now also reports the length in addition to the offset. That way, userspace applications can mmap() only parts of the pool on demand.

* Due to the metadata rework, KDBUS_ITEM_PAYLOAD_OFF items now describe the offset relative to the pool, where they used to be relative to the message header.

* Added return_flags bitmask to all kdbus_cmd_* structs, so the kernel can report details of the command processing. This is mostly reserved for future extensions.

* Some fixes in kdbus.txt and tests, spotted by Harald Hoyer, Andy Lutomirski, Michele Curti, Sergei Zviagintsev, Sheng Yong, Torstein Husebø and Hristo Venev.

* Fixed compiler warnings in test-message by Michele Curti

* Unexpected items are now rejected with -EINVAL

* Split signal and broadcast handling. Unicast signals are now supported, and messages have a new KDBUS_MSG_SIGNAL flag.

* KDBUS_CMD_MSG_SEND was renamed to KDBUS_CMD_SEND, and now takes a struct kdbus_cmd_send instead of a kdbus_msg.

* KDBUS_CMD_MSG_RECV was renamed to KDBUS_CMD_RECV.

* Test case memory leak plugged, and various other cleanups and fixes, by Rui Miguel Silva.

* Build fix for s390

* Test case fix for 32bit archs

* The test framework now supports mount, pid and user namespaces.

* The test framework learned a --tap command line parameter to format its output in the "Test Anything Protocol". This format is chosen by default when "make kselftest" is invoked.

* Fixed buses and custom endpoints name validation, reported by Andy Lutomirski.

* copy_from_user() return code issue fixed, reported by Dan Carpenter.

* Avoid signed int overflow on archs without atomic_sub

* Avoid variable size stack items. Fixes a sparse warning in queue.c.

* New test case for kernel notification quota

* Switched back to enums for the list of ioctls. This has advantages for userspace code as gdb, for instance, is able to resolve the numbers into names. Added features can easily be detected with autotools, and new iotcls can get #defines as well. Having #defines for the initial set of ioctls is uncecessary.

Daniel Mack (13):
kdbus: add documentation
kdbus: add header file
kdbus: add driver skeleton, ioctl entry points and utility functions
kdbus: add connection pool implementation
kdbus: add connection, queue handling and message validation code
kdbus: add node and filesystem implementation
kdbus: add code to gather metadata
kdbus: add code for notifications and matches
kdbus: add code for buses, domains and endpoints
kdbus: add name registry implementation
kdbus: add policy database implementation
kdbus: add Makefile, Kconfig and MAINTAINERS entry
kdbus: add selftests

 Documentation/ioctl/ioctl-number.txt              |    1 +
 Documentation/kdbus.txt                           | 2107 +++++++++++++++++++++
 MAINTAINERS                                       |   12 +
 include/uapi/linux/Kbuild                         |    1 +
 include/uapi/linux/kdbus.h                        | 1049 ++++++++++
 include/uapi/linux/magic.h                        |    2 +
 init/Kconfig                                      |   12 +
 ipc/Makefile                                      |    2 +-
 ipc/kdbus/Makefile                                |   22 +
 ipc/kdbus/bus.c                                   |  553 ++++++
 ipc/kdbus/bus.h                                   |  103 +
 ipc/kdbus/connection.c                            | 2004 ++++++++++++++++++++
 ipc/kdbus/connection.h                            |  262 +++
 ipc/kdbus/domain.c                                |  350 ++++
 ipc/kdbus/domain.h                                |   84 +
 ipc/kdbus/endpoint.c                              |  232 +++
 ipc/kdbus/endpoint.h                              |   68 +
 ipc/kdbus/fs.c                                    |  519 +++++
 ipc/kdbus/fs.h                                    |   25 +
 ipc/kdbus/handle.c                                | 1134 +++++++++++
 ipc/kdbus/handle.h                                |   20 +
 ipc/kdbus/item.c                                  |  309 +++
 ipc/kdbus/item.h                                  |   57 +
 ipc/kdbus/limits.h                                |   95 +
 ipc/kdbus/main.c                                  |   72 +
 ipc/kdbus/match.c                                 |  535 ++++++
 ipc/kdbus/match.h                                 |   32 +
 ipc/kdbus/message.c                               |  598 ++++++
 ipc/kdbus/message.h                               |  133 ++
 ipc/kdbus/metadata.c                              | 1066 +++++++++++
 ipc/kdbus/metadata.h                              |   52 +
 ipc/kdbus/names.c                                 |  891 +++++++++
 ipc/kdbus/names.h                                 |   82 +
 ipc/kdbus/node.c                                  |  910 +++++++++
 ipc/kdbus/node.h                                  |   87 +
 ipc/kdbus/notify.c                                |  244 +++
 ipc/kdbus/notify.h                                |   30 +
 ipc/kdbus/policy.c                                |  481 +++++
 ipc/kdbus/policy.h                                |   51 +
 ipc/kdbus/pool.c                                  |  784 ++++++++
 ipc/kdbus/pool.h                                  |   47 +
 ipc/kdbus/queue.c                                 |  505 +++++
 ipc/kdbus/queue.h                                 |  108 ++
 ipc/kdbus/reply.c                                 |  262 +++
 ipc/kdbus/reply.h                                 |   68 +
 ipc/kdbus/util.c                                  |  317 ++++
 ipc/kdbus/util.h                                  |  133 ++
 tools/testing/selftests/Makefile                  |    1 +
 tools/testing/selftests/kdbus/.gitignore          |   11 +
 tools/testing/selftests/kdbus/Makefile            |   46 +
 tools/testing/selftests/kdbus/kdbus-enum.c        |   95 +
 tools/testing/selftests/kdbus/kdbus-enum.h        |   14 +
 tools/testing/selftests/kdbus/kdbus-test.c        |  920 +++++++++
 tools/testing/selftests/kdbus/kdbus-test.h        |   85 +
 tools/testing/selftests/kdbus/kdbus-util.c        | 1646 ++++++++++++++++
 tools/testing/selftests/kdbus/kdbus-util.h        |  216 +++
 tools/testing/selftests/kdbus/test-activator.c    |  319 ++++
 tools/testing/selftests/kdbus/test-attach-flags.c |  751 ++++++++
 tools/testing/selftests/kdbus/test-benchmark.c    |  427 +++++
 tools/testing/selftests/kdbus/test-bus.c          |  174 ++
 tools/testing/selftests/kdbus/test-chat.c         |  123 ++
 tools/testing/selftests/kdbus/test-connection.c   |  611 ++++++
 tools/testing/selftests/kdbus/test-daemon.c       |   66 +
 tools/testing/selftests/kdbus/test-endpoint.c     |  344 ++++
 tools/testing/selftests/kdbus/test-fd.c           |  710 +++++++
 tools/testing/selftests/kdbus/test-free.c         |   36 +
 tools/testing/selftests/kdbus/test-match.c        |  442 +++++
 tools/testing/selftests/kdbus/test-message.c      |  658 +++++++
 tools/testing/selftests/kdbus/test-metadata-ns.c  |  507 +++++
 tools/testing/selftests/kdbus/test-monitor.c      |  158 ++
 tools/testing/selftests/kdbus/test-names.c        |  184 ++
 tools/testing/selftests/kdbus/test-policy-ns.c    |  633 +++++++
 tools/testing/selftests/kdbus/test-policy-priv.c  | 1270 +++++++++++++
 tools/testing/selftests/kdbus/test-policy.c       |   81 +
 tools/testing/selftests/kdbus/test-race.c         |  313 +++
 tools/testing/selftests/kdbus/test-sync.c         |  368 ++++
 tools/testing/selftests/kdbus/test-timeout.c      |   99 +
 77 files changed, 27818 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/kdbus.txt
 create mode 100644 include/uapi/linux/kdbus.h
 create mode 100644 ipc/kdbus/Makefile
 create mode 100644 ipc/kdbus/bus.c
 create mode 100644 ipc/kdbus/bus.h
 create mode 100644 ipc/kdbus/connection.c
 create mode 100644 ipc/kdbus/connection.h
 create mode 100644 ipc/kdbus/domain.c
 create mode 100644 ipc/kdbus/domain.h
 create mode 100644 ipc/kdbus/endpoint.c
 create mode 100644 ipc/kdbus/endpoint.h
 create mode 100644 ipc/kdbus/fs.c
 create mode 100644 ipc/kdbus/fs.h
 create mode 100644 ipc/kdbus/handle.c
 create mode 100644 ipc/kdbus/handle.h
 create mode 100644 ipc/kdbus/item.c
 create mode 100644 ipc/kdbus/item.h
 create mode 100644 ipc/kdbus/limits.h
 create mode 100644 ipc/kdbus/main.c
 create mode 100644 ipc/kdbus/match.c
 create mode 100644 ipc/kdbus/match.h
 create mode 100644 ipc/kdbus/message.c
 create mode 100644 ipc/kdbus/message.h
 create mode 100644 ipc/kdbus/metadata.c
 create mode 100644 ipc/kdbus/metadata.h
 create mode 100644 ipc/kdbus/names.c
 create mode 100644 ipc/kdbus/names.h
 create mode 100644 ipc/kdbus/node.c
 create mode 100644 ipc/kdbus/node.h
 create mode 100644 ipc/kdbus/notify.c
 create mode 100644 ipc/kdbus/notify.h
 create mode 100644 ipc/kdbus/policy.c
 create mode 100644 ipc/kdbus/policy.h
 create mode 100644 ipc/kdbus/pool.c
 create mode 100644 ipc/kdbus/pool.h
 create mode 100644 ipc/kdbus/queue.c
 create mode 100644 ipc/kdbus/queue.h
 create mode 100644 ipc/kdbus/reply.c
 create mode 100644 ipc/kdbus/reply.h
 create mode 100644 ipc/kdbus/util.c
 create mode 100644 ipc/kdbus/util.h
 create mode 100644 tools/testing/selftests/kdbus/.gitignore
 create mode 100644 tools/testing/selftests/kdbus/Makefile
 create mode 100644 tools/testing/selftests/kdbus/kdbus-enum.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-enum.h
 create mode 100644 tools/testing/selftests/kdbus/kdbus-test.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-test.h
 create mode 100644 tools/testing/selftests/kdbus/kdbus-util.c
 create mode 100644 tools/testing/selftests/kdbus/kdbus-util.h
 create mode 100644 tools/testing/selftests/kdbus/test-activator.c
 create mode 100644 tools/testing/selftests/kdbus/test-attach-flags.c
 create mode 100644 tools/testing/selftests/kdbus/test-benchmark.c
 create mode 100644 tools/testing/selftests/kdbus/test-bus.c
 create mode 100644 tools/testing/selftests/kdbus/test-chat.c
 create mode 100644 tools/testing/selftests/kdbus/test-connection.c
 create mode 100644 tools/testing/selftests/kdbus/test-daemon.c
 create mode 100644 tools/testing/selftests/kdbus/test-endpoint.c
 create mode 100644 tools/testing/selftests/kdbus/test-fd.c
 create mode 100644 tools/testing/selftests/kdbus/test-free.c
 create mode 100644 tools/testing/selftests/kdbus/test-match.c
 create mode 100644 tools/testing/selftests/kdbus/test-message.c
 create mode 100644 tools/testing/selftests/kdbus/test-metadata-ns.c
 create mode 100644 tools/testing/selftests/kdbus/test-monitor.c
 create mode 100644 tools/testing/selftests/kdbus/test-names.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy-ns.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy-priv.c
 create mode 100644 tools/testing/selftests/kdbus/test-policy.c
 create mode 100644 tools/testing/selftests/kdbus/test-race.c
 create mode 100644 tools/testing/selftests/kdbus/test-sync.c
 create mode 100644 tools/testing/selftests/kdbus/test-timeout.c

--
To unsubscribe from this list: send the line "unsubscribe linux-api" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/