summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bus.c42
-rw-r--r--bus.h8
-rw-r--r--endpoint.c8
-rw-r--r--endpoint.h2
-rw-r--r--handle.c37
-rw-r--r--kdbus.h51
-rw-r--r--namespace.c8
-rw-r--r--namespace.h2
-rw-r--r--test/test-kdbus-activator.c16
-rw-r--r--test/test-kdbus-benchmark.c16
-rw-r--r--test/test-kdbus-chat.c16
-rw-r--r--test/test-kdbus-daemon.c17
-rw-r--r--test/test-kdbus-fuzz.c20
-rw-r--r--test/test-kdbus.c40
14 files changed, 172 insertions, 111 deletions
diff --git a/bus.c b/bus.c
index f3a6582e847..52696fd164f 100644
--- a/bus.c
+++ b/bus.c
@@ -160,7 +160,7 @@ static struct kdbus_bus *kdbus_bus_find(struct kdbus_ns *ns, const char *name)
/**
* kdbus_bus_new() - create a new bus
* @ns: The namespace to work on
- * @bus_make: Pointer to a struct kdbus_cmd_bus_make containing the
+ * @make: Pointer to a struct kdbus_cmd_make containing the
* details for the bus creation
* @name: Name of the bus
* @mode: The access mode for the device node
@@ -174,8 +174,9 @@ static struct kdbus_bus *kdbus_bus_find(struct kdbus_ns *ns, const char *name)
* Returns: 0 on success, negative errno on failure.
*/
int kdbus_bus_new(struct kdbus_ns *ns,
- struct kdbus_cmd_bus_make *bus_make, const char *name,
- umode_t mode, kuid_t uid, kgid_t gid, struct kdbus_bus **bus)
+ struct kdbus_cmd_make *make, const char *name,
+ size_t bloom_size, umode_t mode, kuid_t uid,
+ kgid_t gid, struct kdbus_bus **bus)
{
char prefix[16];
struct kdbus_bus *b;
@@ -198,8 +199,8 @@ int kdbus_bus_new(struct kdbus_ns *ns,
kref_init(&b->kref);
b->uid_owner = uid;
- b->bus_flags = bus_make->flags;
- b->bloom_size = bus_make->bloom_size;
+ b->bus_flags = make->flags;
+ b->bloom_size = bloom_size;
b->conn_id_next = 1; /* connection 0 == kernel */
mutex_init(&b->lock);
hash_init(b->conn_hash);
@@ -248,29 +249,32 @@ exit:
}
/**
- * kdbus_bus_make_user() - create a kdbus_cmd_bus_make from user-supplied data
+ * kdbus_bus_make_user() - create a kdbus_cmd_make from user-supplied data
* @buf: The user supplied data from the ioctl() call
* @make: Reference to the location where to store the result
* @name: Shortcut to the requested name
+ * @bloom_size: The bloom filter size as denoted in the make items
*
* This function is part of the connection ioctl() interface and will parse
* the user-supplied data.
*
* Returns: 0 on success, negative errno on failure.
*/
-int kdbus_bus_make_user(void __user *buf,
- struct kdbus_cmd_bus_make **make, char **name)
+int kdbus_bus_make_user(void __user *buf, struct kdbus_cmd_make **make,
+ char **name, size_t *bloom_size)
{
u64 size;
- struct kdbus_cmd_bus_make *m;
+ struct kdbus_cmd_make *m;
const char *n = NULL;
const struct kdbus_item *item;
+ u64 bsize = 0;
int ret;
- if (kdbus_size_get_user(&size, buf, struct kdbus_cmd_bus_make))
+
+ if (kdbus_size_get_user(&size, buf, struct kdbus_cmd_make))
return -EFAULT;
- if (size < sizeof(struct kdbus_cmd_bus_make) || size > KDBUS_MAKE_MAX_SIZE)
+ if (size < sizeof(struct kdbus_cmd_make) || size > KDBUS_MAKE_MAX_SIZE)
return -EMSGSIZE;
m = memdup_user(buf, size);
@@ -309,7 +313,16 @@ int kdbus_bus_make_user(void __user *buf,
}
n = item->str;
- continue;
+ break;
+
+ case KDBUS_ITEM_BLOOM_SIZE:
+ if (item->size < KDBUS_ITEM_HEADER_SIZE + sizeof(u64)) {
+ ret = -EINVAL;
+ goto exit;
+ }
+
+ bsize = item->data64[0];
+ break;
default:
ret = -ENOTSUPP;
@@ -325,18 +338,19 @@ int kdbus_bus_make_user(void __user *buf,
goto exit;
}
- if (!KDBUS_IS_ALIGNED8(m->bloom_size)) {
+ if (!KDBUS_IS_ALIGNED8(bsize)) {
ret = -EINVAL;
goto exit;
}
- if (m->bloom_size < 8 || m->bloom_size > 16 * 1024) {
+ if (bsize < 8 || bsize > SZ_16K) {
ret = -EINVAL;
goto exit;
}
*make = m;
*name = (char *)n;
+ *bloom_size = (size_t)bsize;
return 0;
exit:
diff --git a/bus.h b/bus.h
index a99e09d5588..dfeea98dba5 100644
--- a/bus.h
+++ b/bus.h
@@ -68,10 +68,10 @@ struct kdbus_bus {
u8 id128[16];
};
-int kdbus_bus_make_user(void __user *buf,
- struct kdbus_cmd_bus_make **make, char **name);
-int kdbus_bus_new(struct kdbus_ns *ns,
- struct kdbus_cmd_bus_make *make, const char *name,
+int kdbus_bus_make_user(void __user *buf, struct kdbus_cmd_make **make,
+ char **name, size_t *bsize);
+int kdbus_bus_new(struct kdbus_ns *ns, struct kdbus_cmd_make *make,
+ const char *name, size_t bloom_size,
umode_t mode, kuid_t uid, kgid_t gid, struct kdbus_bus **bus);
struct kdbus_bus *kdbus_bus_ref(struct kdbus_bus *bus);
struct kdbus_bus *kdbus_bus_unref(struct kdbus_bus *bus);
diff --git a/endpoint.c b/endpoint.c
index 146fb2d0039..07742c3b50f 100644
--- a/endpoint.c
+++ b/endpoint.c
@@ -235,18 +235,18 @@ exit:
* Returns: 0 on success, negative errno on failure.
*/
int kdbus_ep_make_user(void __user *buf,
- struct kdbus_cmd_ep_make **make, char **name)
+ struct kdbus_cmd_make **make, char **name)
{
u64 size;
- struct kdbus_cmd_ep_make *m;
+ struct kdbus_cmd_make *m;
const struct kdbus_item *item;
const char *n = NULL;
int ret;
- if (kdbus_size_get_user(&size, buf, struct kdbus_cmd_ep_make))
+ if (kdbus_size_get_user(&size, buf, struct kdbus_cmd_make))
return -EFAULT;
- if (size < sizeof(struct kdbus_cmd_ep_make) || size > KDBUS_MAKE_MAX_SIZE)
+ if (size < sizeof(struct kdbus_cmd_make) || size > KDBUS_MAKE_MAX_SIZE)
return -EMSGSIZE;
m = memdup_user(buf, size);
diff --git a/endpoint.h b/endpoint.h
index 3064dc8a3cc..0db1bda657b 100644
--- a/endpoint.h
+++ b/endpoint.h
@@ -63,5 +63,5 @@ struct kdbus_ep *kdbus_ep_ref(struct kdbus_ep *ep);
struct kdbus_ep *kdbus_ep_unref(struct kdbus_ep *ep);
void kdbus_ep_disconnect(struct kdbus_ep *ep);
int kdbus_ep_make_user(void __user *buf,
- struct kdbus_cmd_ep_make **make, char **name);
+ struct kdbus_cmd_make **make, char **name);
#endif
diff --git a/handle.c b/handle.c
index d73c90082c9..ed2945cde81 100644
--- a/handle.c
+++ b/handle.c
@@ -185,8 +185,7 @@ static long kdbus_handle_ioctl_control(struct file *file, unsigned int cmd,
void __user *buf)
{
struct kdbus_handle *handle = file->private_data;
- struct kdbus_cmd_bus_make *bus_make = NULL;
- struct kdbus_cmd_ns_make *ns_make = NULL;
+ struct kdbus_cmd_make *make = NULL;
struct kdbus_bus *bus = NULL;
struct kdbus_ns *ns = NULL;
umode_t mode = 0600;
@@ -195,6 +194,7 @@ static long kdbus_handle_ioctl_control(struct file *file, unsigned int cmd,
switch (cmd) {
case KDBUS_CMD_BUS_MAKE: {
kgid_t gid = KGIDT_INIT(0);
+ size_t bloom_size;
char *name;
if (!KDBUS_IS_ALIGNED8((uintptr_t)buf)) {
@@ -202,23 +202,23 @@ static long kdbus_handle_ioctl_control(struct file *file, unsigned int cmd,
break;
}
- ret = kdbus_bus_make_user(buf, &bus_make, &name);
+ ret = kdbus_bus_make_user(buf, &make, &name, &bloom_size);
if (ret < 0)
break;
- if (!kdbus_check_flags(bus_make->flags)) {
+ if (!kdbus_check_flags(make->flags)) {
ret = -ENOTSUPP;
break;
}
- if (bus_make->flags & KDBUS_MAKE_ACCESS_WORLD) {
+ if (make->flags & KDBUS_MAKE_ACCESS_WORLD) {
mode = 0666;
- } else if (bus_make->flags & KDBUS_MAKE_ACCESS_GROUP) {
+ } else if (make->flags & KDBUS_MAKE_ACCESS_GROUP) {
mode = 0660;
gid = current_fsgid();
}
- ret = kdbus_bus_new(handle->ns, bus_make, name,
+ ret = kdbus_bus_new(handle->ns, make, name, bloom_size,
mode, current_fsuid(), gid, &bus);
if (ret < 0)
break;
@@ -242,16 +242,16 @@ static long kdbus_handle_ioctl_control(struct file *file, unsigned int cmd,
break;
}
- ret = kdbus_ns_make_user(buf, &ns_make, &name);
+ ret = kdbus_ns_make_user(buf, &make, &name);
if (ret < 0)
break;
- if (!kdbus_check_flags(ns_make->flags)) {
+ if (!kdbus_check_flags(make->flags)) {
ret = -ENOTSUPP;
break;
}
- if (ns_make->flags & KDBUS_MAKE_ACCESS_WORLD)
+ if (make->flags & KDBUS_MAKE_ACCESS_WORLD)
mode = 0666;
ret = kdbus_ns_new(kdbus_ns_init, name, mode, &ns);
@@ -282,8 +282,7 @@ static long kdbus_handle_ioctl_control(struct file *file, unsigned int cmd,
break;
}
- kfree(bus_make);
- kfree(ns_make);
+ kfree(make);
return ret;
}
@@ -292,7 +291,7 @@ static long kdbus_handle_ioctl_ep(struct file *file, unsigned int cmd,
void __user *buf)
{
struct kdbus_handle *handle = file->private_data;
- struct kdbus_cmd_ep_make *m = NULL;
+ struct kdbus_cmd_make *make = NULL;
struct kdbus_cmd_hello *hello = NULL;
long ret = 0;
@@ -307,25 +306,25 @@ static long kdbus_handle_ioctl_ep(struct file *file, unsigned int cmd,
break;
}
- ret = kdbus_ep_make_user(buf, &m, &n);
+ ret = kdbus_ep_make_user(buf, &make, &n);
if (ret < 0)
break;
- if (!kdbus_check_flags(m->flags)) {
+ if (!kdbus_check_flags(make->flags)) {
ret = -ENOTSUPP;
break;
}
- if (m->flags & KDBUS_MAKE_ACCESS_WORLD) {
+ if (make->flags & KDBUS_MAKE_ACCESS_WORLD) {
mode = 0666;
- } else if (m->flags & KDBUS_MAKE_ACCESS_GROUP) {
+ } else if (make->flags & KDBUS_MAKE_ACCESS_GROUP) {
mode = 0660;
gid = current_fsgid();
}
ret = kdbus_ep_new(handle->ep->bus, handle->ep->bus->ns, n,
mode, current_fsuid(), gid,
- m->flags & KDBUS_MAKE_POLICY_OPEN);
+ make->flags & KDBUS_MAKE_POLICY_OPEN);
handle->type = KDBUS_HANDLE_EP_OWNER;
break;
@@ -390,7 +389,7 @@ static long kdbus_handle_ioctl_ep(struct file *file, unsigned int cmd,
break;
}
- kfree(m);
+ kfree(make);
kfree(hello);
return ret;
diff --git a/kdbus.h b/kdbus.h
index 972a02df8d9..e9ffecd54b2 100644
--- a/kdbus.h
+++ b/kdbus.h
@@ -201,6 +201,7 @@ struct kdbus_policy {
* @KDBUS_ITEM_PAYLOAD_MEMFD: Data as sealed memfd
* @KDBUS_ITEM_FDS: Attached file descriptors
* @KDBUS_ITEM_BLOOM: For broadcasts, carries bloom filter
+ * @KDBUS_ITEM_BLOOM_SIZE: Desired bloom size, used by KDBUS_CMD_BUS_MAKE
* @KDBUS_ITEM_DST_NAME: Destination's well-known name
* @KDBUS_ITEM_PRIORITY: Queue priority for message
* @KDBUS_ITEM_MAKE_NAME: Name of namespace, bus, endpoint
@@ -233,6 +234,7 @@ enum kdbus_item_type {
KDBUS_ITEM_PAYLOAD_MEMFD,
KDBUS_ITEM_FDS,
KDBUS_ITEM_BLOOM,
+ KDBUS_ITEM_BLOOM_SIZE,
KDBUS_ITEM_DST_NAME,
KDBUS_ITEM_PRIORITY,
KDBUS_ITEM_MAKE_NAME,
@@ -493,46 +495,15 @@ enum kdbus_make_flags {
};
/**
- * struct kdbus_cmd_bus_make - struct to make a bus
+ * struct kdbus_cmd_make - struct to make a bus, an endpoint or a namespace
* @size: The total size of the struct
- * @flags: Properties for the bus to create
- * @bloom_size: Size of the bloom filter for this bus
- * @items: Items describing details such as the name of the bus
+ * @flags: Properties for the bus/ep/ns to create
+ * @items: Items describing details
*
- * This structure is used with the KDBUS_CMD_BUS_MAKE ioctl.
+ * This structure is used with the KDBUS_CMD_BUS_MAKE, KDBUS_CMD_EP_MAKE and
+ * KDBUS_CMD_NS_MAKE ioctls.
*/
-struct kdbus_cmd_bus_make {
- __u64 size;
- __u64 flags;
- __u64 bloom_size;
- struct kdbus_item items[0];
-} __attribute__((aligned(8)));
-
-/**
- * struct kdbus_cmd_ep_make - struct to make an endpoint
- * @size: The total size of the struct
- * @flags: Unused for now
- * @items: Items describing details such as the
- * name of the endpoint
- *
- * This structure is used with the KDBUS_CMD_EP_MAKE ioctl.
- */
-struct kdbus_cmd_ep_make {
- __u64 size;
- __u64 flags;
- struct kdbus_item items[0];
-} __attribute__((aligned(8)));
-
-/**
- * struct kdbus_cmd_ns_make - struct to make a namespace
- * @size: The total size of the struct
- * @flags: Unused for now
- * @items: Items describing details such as the
- * name of the namespace
- *
- * This structure is used with the KDBUS_CMD_NS_MAKE ioctl.
- */
-struct kdbus_cmd_ns_make {
+struct kdbus_cmd_make {
__u64 size;
__u64 flags;
struct kdbus_item items[0];
@@ -772,9 +743,9 @@ struct kdbus_cmd_match {
* be changed as long as the file is shared.
*/
enum kdbus_ioctl_type {
- KDBUS_CMD_BUS_MAKE = _IOW (KDBUS_IOC_MAGIC, 0x00, struct kdbus_cmd_bus_make),
- KDBUS_CMD_NS_MAKE = _IOR (KDBUS_IOC_MAGIC, 0x10, struct kdbus_cmd_ns_make),
- KDBUS_CMD_EP_MAKE = _IOW (KDBUS_IOC_MAGIC, 0x20, struct kdbus_cmd_ep_make),
+ KDBUS_CMD_BUS_MAKE = _IOW (KDBUS_IOC_MAGIC, 0x00, struct kdbus_cmd_make),
+ KDBUS_CMD_NS_MAKE = _IOR (KDBUS_IOC_MAGIC, 0x10, struct kdbus_cmd_make),
+ KDBUS_CMD_EP_MAKE = _IOW (KDBUS_IOC_MAGIC, 0x20, struct kdbus_cmd_make),
KDBUS_CMD_HELLO = _IOWR(KDBUS_IOC_MAGIC, 0x30, struct kdbus_cmd_hello),
diff --git a/namespace.c b/namespace.c
index edbb5bd75f8..837390e0b7c 100644
--- a/namespace.c
+++ b/namespace.c
@@ -309,18 +309,18 @@ exit_unlock:
* Returns: 0 on success, negative errno on failure.
*/
int kdbus_ns_make_user(void __user *buf,
- struct kdbus_cmd_ns_make **make, char **name)
+ struct kdbus_cmd_make **make, char **name)
{
u64 size;
- struct kdbus_cmd_ns_make *m;
+ struct kdbus_cmd_make *m;
const struct kdbus_item *item;
const char *n = NULL;
int ret;
- if (kdbus_size_get_user(&size, buf, struct kdbus_cmd_ns_make))
+ if (kdbus_size_get_user(&size, buf, struct kdbus_cmd_make))
return -EFAULT;
- if (size < sizeof(struct kdbus_cmd_ns_make) || size > KDBUS_MAKE_MAX_SIZE)
+ if (size < sizeof(struct kdbus_cmd_make) || size > KDBUS_MAKE_MAX_SIZE)
return -EMSGSIZE;
m = memdup_user(buf, size);
diff --git a/namespace.h b/namespace.h
index c68f6209323..b9d3187fd27 100644
--- a/namespace.h
+++ b/namespace.h
@@ -66,6 +66,6 @@ struct kdbus_ns *kdbus_ns_ref(struct kdbus_ns *ns);
struct kdbus_ns *kdbus_ns_unref(struct kdbus_ns *ns);
void kdbus_ns_disconnect(struct kdbus_ns *ns);
int kdbus_ns_new(struct kdbus_ns *parent, const char *name, umode_t mode, struct kdbus_ns **ns);
-int kdbus_ns_make_user(void __user *buf, struct kdbus_cmd_ns_make **make, char **name);
+int kdbus_ns_make_user(void __user *buf, struct kdbus_cmd_make **make, char **name);
struct kdbus_ns *kdbus_ns_find_by_major(unsigned int major);
#endif
diff --git a/test/test-kdbus-activator.c b/test/test-kdbus-activator.c
index d5d5f319eed..6d4ac61b0a6 100644
--- a/test/test-kdbus-activator.c
+++ b/test/test-kdbus-activator.c
@@ -69,7 +69,14 @@ static struct conn *make_activator(const char *path, const char *name)
int main(int argc, char *argv[])
{
struct {
- struct kdbus_cmd_bus_make head;
+ struct kdbus_cmd_make head;
+
+ /* bloom size item */
+ struct {
+ uint64_t size;
+ uint64_t type;
+ uint64_t bloom_size;
+ } bs;
/* name item */
uint64_t n_size;
@@ -90,13 +97,16 @@ int main(int argc, char *argv[])
}
memset(&bus_make, 0, sizeof(bus_make));
- bus_make.head.bloom_size = 64;
+ bus_make.bs.size = sizeof(bus_make.bs);
+ bus_make.bs.type = KDBUS_ITEM_BLOOM_SIZE;
+ bus_make.bs.bloom_size = 64;
snprintf(bus_make.name, sizeof(bus_make.name), "%u-testbus", getuid());
bus_make.n_type = KDBUS_ITEM_MAKE_NAME;
bus_make.n_size = KDBUS_ITEM_HEADER_SIZE + strlen(bus_make.name) + 1;
- bus_make.head.size = sizeof(struct kdbus_cmd_bus_make) +
+ bus_make.head.size = sizeof(struct kdbus_cmd_make) +
+ sizeof(bus_make.bs) +
bus_make.n_size;
printf("-- creating bus '%s'\n", bus_make.name);
diff --git a/test/test-kdbus-benchmark.c b/test/test-kdbus-benchmark.c
index c4967daf10d..daa11dddb31 100644
--- a/test/test-kdbus-benchmark.c
+++ b/test/test-kdbus-benchmark.c
@@ -205,7 +205,14 @@ handle_echo_reply(struct conn *conn)
int main(int argc, char *argv[])
{
struct {
- struct kdbus_cmd_bus_make head;
+ struct kdbus_cmd_make head;
+
+ /* bloom size item */
+ struct {
+ uint64_t size;
+ uint64_t type;
+ uint64_t bloom_size;
+ } bs;
/* name item */
uint64_t n_size;
@@ -231,13 +238,16 @@ int main(int argc, char *argv[])
}
memset(&bus_make, 0, sizeof(bus_make));
- bus_make.head.bloom_size = 64;
+ bus_make.bs.size = sizeof(bus_make.bs);
+ bus_make.bs.type = KDBUS_ITEM_BLOOM_SIZE;
+ bus_make.bs.bloom_size = 64;
snprintf(bus_make.name, sizeof(bus_make.name), "%u-testbus", getuid());
bus_make.n_type = KDBUS_ITEM_MAKE_NAME;
bus_make.n_size = KDBUS_ITEM_HEADER_SIZE + strlen(bus_make.name) + 1;
- bus_make.head.size = sizeof(struct kdbus_cmd_bus_make) +
+ bus_make.head.size = sizeof(struct kdbus_cmd_make) +
+ sizeof(bus_make.bs) +
bus_make.n_size;
printf("-- creating bus '%s'\n", bus_make.name);
diff --git a/test/test-kdbus-chat.c b/test/test-kdbus-chat.c
index 00980b85b51..ef61c8db571 100644
--- a/test/test-kdbus-chat.c
+++ b/test/test-kdbus-chat.c
@@ -17,7 +17,14 @@
int main(int argc, char *argv[])
{
struct {
- struct kdbus_cmd_bus_make head;
+ struct kdbus_cmd_make head;
+
+ /* bloom size item */
+ struct {
+ uint64_t size;
+ uint64_t type;
+ uint64_t bloom_size;
+ } bs;
/* name item */
uint64_t n_size;
@@ -39,13 +46,16 @@ int main(int argc, char *argv[])
}
memset(&bus_make, 0, sizeof(bus_make));
- bus_make.head.bloom_size = 64;
+ bus_make.bs.size = sizeof(bus_make.bs);
+ bus_make.bs.type = KDBUS_ITEM_BLOOM_SIZE;
+ bus_make.bs.bloom_size = 64;
snprintf(bus_make.name, sizeof(bus_make.name), "%u-testbus", getuid());
bus_make.n_type = KDBUS_ITEM_MAKE_NAME;
bus_make.n_size = KDBUS_ITEM_HEADER_SIZE + strlen(bus_make.name) + 1;
- bus_make.head.size = sizeof(struct kdbus_cmd_bus_make) +
+ bus_make.head.size = sizeof(struct kdbus_cmd_make) +
+ sizeof(bus_make.bs) +
bus_make.n_size;
printf("-- creating bus '%s'\n", bus_make.name);
diff --git a/test/test-kdbus-daemon.c b/test/test-kdbus-daemon.c
index fa7058858a3..f010ab051a3 100644
--- a/test/test-kdbus-daemon.c
+++ b/test/test-kdbus-daemon.c
@@ -18,7 +18,15 @@
int main(int argc, char *argv[])
{
struct {
- struct kdbus_cmd_bus_make head;
+ struct kdbus_cmd_make head;
+
+ /* bloom size item */
+ struct {
+ uint64_t size;
+ uint64_t type;
+ uint64_t bloom_size;
+ } bs;
+
uint64_t n_size;
uint64_t n_type;
char name[64];
@@ -39,13 +47,16 @@ int main(int argc, char *argv[])
}
memset(&bus_make, 0, sizeof(bus_make));
- bus_make.head.bloom_size = 64;
+ bus_make.bs.size = sizeof(bus_make.bs);
+ bus_make.bs.type = KDBUS_ITEM_BLOOM_SIZE;
+ bus_make.bs.bloom_size = 64;
snprintf(bus_make.name, sizeof(bus_make.name), "%u-testbus", getuid());
bus_make.n_type = KDBUS_ITEM_MAKE_NAME;
bus_make.n_size = KDBUS_ITEM_HEADER_SIZE + strlen(bus_make.name) + 1;
- bus_make.head.size = sizeof(struct kdbus_cmd_bus_make) +
+ bus_make.head.size = sizeof(struct kdbus_cmd_make) +
+ sizeof(bus_make.bs) +
bus_make.n_size;
ret = ioctl(fd_owner, KDBUS_CMD_BUS_MAKE, &bus_make);
diff --git a/test/test-kdbus-fuzz.c b/test/test-kdbus-fuzz.c
index a1a7564c3d2..3536a2d2558 100644
--- a/test/test-kdbus-fuzz.c
+++ b/test/test-kdbus-fuzz.c
@@ -80,7 +80,18 @@ static void add_fd(int fd)
static int make_bus(void)
{
struct {
- struct kdbus_cmd_bus_make head;
+ struct kdbus_cmd_make head;
+
+ /* bloom size item */
+ struct {
+ uint64_t size;
+ uint64_t type;
+ uint64_t bloom_size;
+ } bs;
+
+ /* name item */
+ uint64_t n_size;
+ uint64_t n_type;
char name[64];
} bus_make;
char name[10];
@@ -105,8 +116,11 @@ static int make_bus(void)
memset(&bus_make, 0, sizeof(bus_make));
snprintf(bus_make.name, sizeof(bus_make.name), "%u-%s", getuid(), name);
bus_make.head.flags = KDBUS_MAKE_ACCESS_WORLD;
- bus_make.head.size = sizeof(struct kdbus_cmd_bus_make) + strlen(bus_make.name) + 1;
- bus_make.head.bloom_size = 64;
+ bus_make.head.size = sizeof(struct kdbus_cmd_make) + strlen(bus_make.name) + 1;
+
+ bus_make.bs.size = sizeof(bus_make.bs);
+ bus_make.bs.type = KDBUS_ITEM_BLOOM_SIZE;
+ bus_make.bs.bloom_size = 64;
printf("-- creating bus '%s'\n", bus_make.name);
ret = ioctl(fdc, KDBUS_CMD_BUS_MAKE, &bus_make);
diff --git a/test/test-kdbus.c b/test/test-kdbus.c
index 27fb46161a3..7e8aa670fce 100644
--- a/test/test-kdbus.c
+++ b/test/test-kdbus.c
@@ -258,7 +258,7 @@ static int check_nsmake(struct kdbus_check_env *env)
{
int fd, fd2;
struct {
- struct kdbus_cmd_ns_make head;
+ struct kdbus_cmd_make head;
/* name item */
uint64_t n_size;
@@ -277,7 +277,7 @@ static int check_nsmake(struct kdbus_check_env *env)
/* create a new namespace */
snprintf(ns_make.name, sizeof(ns_make.name), "blah");
ns_make.n_size = KDBUS_ITEM_HEADER_SIZE + strlen(ns_make.name) + 1;
- ns_make.head.size = sizeof(struct kdbus_cmd_ns_make) + ns_make.n_size;
+ ns_make.head.size = sizeof(struct kdbus_cmd_make) + ns_make.n_size;
ret = ioctl(fd, KDBUS_CMD_NS_MAKE, &ns_make);
if (ret < 0 && errno == EPERM)
return CHECK_SKIP;
@@ -306,7 +306,14 @@ static int check_nsmake(struct kdbus_check_env *env)
static int check_busmake(struct kdbus_check_env *env)
{
struct {
- struct kdbus_cmd_bus_make head;
+ struct kdbus_cmd_make head;
+
+ /* bloom size item */
+ struct {
+ uint64_t size;
+ uint64_t type;
+ uint64_t bloom_size;
+ } bs;
/* name item */
uint64_t n_size;
@@ -320,7 +327,10 @@ static int check_busmake(struct kdbus_check_env *env)
ASSERT_RETURN(env->control_fd >= 0);
memset(&bus_make, 0, sizeof(bus_make));
- bus_make.head.bloom_size = 64;
+
+ bus_make.bs.size = sizeof(bus_make.bs);
+ bus_make.bs.type = KDBUS_ITEM_BLOOM_SIZE;
+ bus_make.bs.bloom_size = 64;
bus_make.n_type = KDBUS_ITEM_MAKE_NAME;
@@ -328,7 +338,7 @@ static int check_busmake(struct kdbus_check_env *env)
/* check some illegal names */
snprintf(bus_make.name, sizeof(bus_make.name), "foo");
bus_make.n_size = KDBUS_ITEM_HEADER_SIZE + strlen(bus_make.name) + 1;
- bus_make.head.size = sizeof(struct kdbus_cmd_bus_make) + bus_make.n_size;
+ bus_make.head.size = sizeof(struct kdbus_cmd_make) + bus_make.n_size;
ret = ioctl(env->control_fd, KDBUS_CMD_BUS_MAKE, &bus_make);
ASSERT_RETURN(ret == -1 && errno == EINVAL);
#endif
@@ -336,7 +346,9 @@ static int check_busmake(struct kdbus_check_env *env)
/* create a new bus */
snprintf(bus_make.name, sizeof(bus_make.name), "%u-blah", getuid());
bus_make.n_size = KDBUS_ITEM_HEADER_SIZE + strlen(bus_make.name) + 1;
- bus_make.head.size = sizeof(struct kdbus_cmd_bus_make) + bus_make.n_size;
+ bus_make.head.size = sizeof(struct kdbus_cmd_make) +
+ sizeof(uint64_t) * 3 +
+ bus_make.n_size;
ret = ioctl(env->control_fd, KDBUS_CMD_BUS_MAKE, &bus_make);
ASSERT_RETURN(ret == 0);
snprintf(s, sizeof(s), "/dev/kdbus/%u-blah/bus", getuid());
@@ -651,7 +663,14 @@ static int check_prepare_env(const struct kdbus_check *c, struct kdbus_check_env
{
if (c->flags & CHECK_CREATE_BUS) {
struct {
- struct kdbus_cmd_bus_make head;
+ struct kdbus_cmd_make head;
+
+ /* bloom size item */
+ struct {
+ uint64_t size;
+ uint64_t type;
+ uint64_t bloom_size;
+ } bs;
/* name item */
uint64_t n_size;
@@ -666,7 +685,9 @@ static int check_prepare_env(const struct kdbus_check *c, struct kdbus_check_env
ASSERT_RETURN(env->control_fd >= 0);
memset(&bus_make, 0, sizeof(bus_make));
- bus_make.head.bloom_size = 64;
+ bus_make.bs.size = sizeof(bus_make.bs);
+ bus_make.bs.type = KDBUS_ITEM_BLOOM_SIZE;
+ bus_make.bs.bloom_size = 64;
for (i = 0; i < sizeof(n); i++)
n[i] = 'a' + (random() % ('z' - 'a'));
@@ -676,7 +697,8 @@ static int check_prepare_env(const struct kdbus_check *c, struct kdbus_check_env
bus_make.n_type = KDBUS_ITEM_MAKE_NAME;
bus_make.n_size = KDBUS_ITEM_HEADER_SIZE + strlen(bus_make.name) + 1;
- bus_make.head.size = sizeof(struct kdbus_cmd_bus_make) +
+ bus_make.head.size = sizeof(struct kdbus_cmd_make) +
+ sizeof(bus_make.bs) +
bus_make.n_size;
ret = ioctl(env->control_fd, KDBUS_CMD_BUS_MAKE, &bus_make);