Features:
- allow to update the metadata subscription bit mask
- support the creation of anonymous buses
+ - implement EP_MAKE
External API:
- actually return compatible/incompatible flags to users
struct kdbus_bus *b;
int ret;
+ BUG_ON(*bus);
+
/* enforce "$UID-" prefix */
snprintf(prefix, sizeof(prefix), "%u-",
from_kuid(current_user_ns(), uid));
}
/* space for metadata/credential items */
- if (kmsg->meta->size > 0 && kmsg->meta->ns == conn->meta->ns) {
+ if (kmsg->meta && kmsg->meta->size > 0 &&
+ kmsg->meta->ns == conn->meta->ns) {
meta = msg_size;
msg_size += kmsg->meta->size;
}
u64 deadline_ns = 0;
int ret;
+ /* non-kernel senders append credentials/metadata */
+ if (conn_src) {
+ ret = kdbus_meta_new(&kmsg->meta);
+ if (ret < 0)
+ return ret;
+ }
+
/* broadcast message */
if (msg->dst_id == KDBUS_DST_ID_BROADCAST) {
unsigned int i;
LIST_HEAD(notify_list);
int ret;
+ BUG_ON(*c);
+
if (hello->conn_flags & KDBUS_HELLO_ACTIVATOR &&
hello->conn_flags & KDBUS_HELLO_MONITOR)
return -EINVAL;
* @type: Type of this handle (KDBUS_HANDLE_*)
* @ns: Namespace for this handle
* @meta: Cached connection creator's metadata/credentials
+ * @ep The endpoint this handle owns, in case @type
+ * is KDBUS_HANDLE_EP
* @ns_owner: The namespace this handle owns, in case @type
* is KDBUS_HANDLE_CONTROL_NS_OWNER
* @bus_owner: The bus this handle owns, in case @type
* is KDBUS_HANDLE_CONTROL_BUS_OWNER
+ * @ep_owner The endpoint this handle owns, in case @type
+ * is KDBUS_HANDLE_EP_OWNER
* @conn The connection this handle owns, in case @type
* is KDBUS_HANDLE_EP, after HELLO it is
* KDBUS_HANDLE_EP_CONNECTED
- * @ep The endpoint this handle owns, in case @type
- * is KDBUS_HANDLE_EP or KDBUS_HANDLE_EP_OWNER
*/
struct kdbus_handle {
enum kdbus_handle_type type;
struct kdbus_ns *ns;
struct kdbus_meta *meta;
+ struct kdbus_ep *ep;
union {
struct kdbus_ns *ns_owner;
struct kdbus_bus *bus_owner;
+ struct kdbus_ep *ep_owner;
struct kdbus_conn *conn;
- struct kdbus_ep *ep;
};
};
break;
case KDBUS_HANDLE_EP_OWNER:
- kdbus_ep_disconnect(handle->ep);
- kdbus_ep_unref(handle->ep);
+ kdbus_ep_disconnect(handle->ep_owner);
+ kdbus_ep_unref(handle->ep_owner);
break;
case KDBUS_HANDLE_EP:
gid = current_fsgid();
}
+ //FIXME: what to do with the holder connection now?
ret = kdbus_ep_new(handle->ep->bus, handle->ep->bus->ns, n,
mode, current_fsuid(), gid,
make->flags & KDBUS_MAKE_POLICY_OPEN);
case KDBUS_CMD_MSG_SEND: {
/* submit a message which will be queued in the receiver */
- struct kdbus_kmsg *kmsg;
+ struct kdbus_kmsg *kmsg = NULL;
if (!KDBUS_IS_ALIGNED8((uintptr_t)buf)) {
ret = -EFAULT;
{
struct kdbus_kmsg *m;
size_t size;
- int ret;
+
+ BUG_ON(*kmsg);
size = sizeof(struct kdbus_kmsg) + KDBUS_ITEM_SIZE(extra_size);
m = kzalloc(size, GFP_KERNEL);
if (!m)
return -ENOMEM;
- ret = kdbus_meta_new(&m->meta);
- if (ret < 0)
- return ret;
-
m->msg.size = size - KDBUS_KMSG_HEADER_SIZE;
m->msg.items[0].size = KDBUS_ITEM_SIZE(extra_size);
u64 size, alloc_size;
int ret;
+ BUG_ON(*kmsg);
+
if (!KDBUS_IS_ALIGNED8((unsigned long)msg))
return -EFAULT;
if (ret < 0)
goto exit_free;
- ret = kdbus_meta_new(&m->meta);
- if (ret < 0)
- goto exit_free;
-
/* patch-in the source of this message */
m->msg.src_id = conn->id;
{
struct kdbus_meta *m;
+ BUG_ON(*meta);
+
m = kzalloc(sizeof(struct kdbus_meta), GFP_KERNEL);
if (!m)
return -ENOMEM;
struct kdbus_ns *n;
int ret;
+ BUG_ON(*ns);
+
if ((parent && !name) || (!parent && name))
return -EINVAL;
static int kdbus_notify_reply(u64 id, u64 cookie, u64 msg_type,
struct list_head *queue_list)
{
- struct kdbus_kmsg *kmsg;
+ struct kdbus_kmsg *kmsg = NULL;
int ret;
BUG_ON(id == 0);
const char *name,
struct list_head *queue_list)
{
+ struct kdbus_kmsg *kmsg = NULL;
size_t name_len;
- struct kdbus_kmsg *kmsg;
size_t extra_size;
int ret;
int kdbus_notify_id_change(u64 type, u64 id, u64 flags,
struct list_head *queue_list)
{
- struct kdbus_kmsg *kmsg;
+ struct kdbus_kmsg *kmsg = NULL;
int ret;
ret = kdbus_kmsg_new(sizeof(struct kdbus_notify_id_change), &kmsg);
{
struct kdbus_policy_db *d;
+ BUG_ON(*db);
+
d = kzalloc(sizeof(*d), GFP_KERNEL);
if (!d)
return -ENOMEM;
struct kdbus_slice *s;
int ret;
+ BUG_ON(*pool);
+
p = kzalloc(sizeof(struct kdbus_pool), GFP_KERNEL);
if (!p)
return -ENOMEM;