u64 flags;
if (cmd_info->id == 0) {
- size_t len = cmd_info->size -
- offsetof(struct kdbus_cmd_conn_info, name);
+ const char *name;
- if (strnlen(cmd_info->name, len) + 1 != len)
+ ret = kdbus_items_get_str(cmd_info->items,
+ KDBUS_ITEMS_SIZE(cmd_info, items),
+ KDBUS_ITEM_NAME, &name);
+ if (ret < 0)
return -EINVAL;
- if (!kdbus_name_is_valid(cmd_info->name, false))
+ if (!kdbus_name_is_valid(name, false))
return -EINVAL;
/* check if 'conn' is allowed to see 'name' */
mutex_lock(&conn->lock);
ret = kdbus_ep_policy_check_see_access_unlocked(conn->ep, conn,
- cmd_info->name);
+ name);
mutex_unlock(&conn->lock);
up_read(&conn->ep->policy_db.entries_rwlock);
if (ret < 0)
return ret;
- entry = kdbus_name_lock(conn->bus->name_registry,
- cmd_info->name);
+ entry = kdbus_name_lock(conn->bus->name_registry, name);
if (!entry)
return -ESRCH;
else if (entry->conn)
__u64 flags;
__u64 id;
__u64 offset;
- char name[0];
+ struct kdbus_item items[0];
} __attribute__((aligned(8)));
/**
When the ioctl returns, this value will yield the offset of the connection
information inside the caller's pool.
- char name[0];
- The name of the connection to retrieve information for. Only looked at if
- the 'id' field is set to 0.
+ struct kdbus_item items[0];
+ The name of the connection to retrieve information for, stored in an item
+ of type KDBUS_ITEM_NAME. Only required at if the 'id' field is set to 0.
+ All other items are currently ignored.
};
After the ioctl returns, the following struct will be stored in the caller's
int ret;
if (name)
- size += strlen(name) + 1;
+ size += KDBUS_ITEM_HEADER_SIZE + strlen(name) + 1;
cmd = alloca(size);
memset(cmd, 0, size);
cmd->size = size;
- if (name)
- strcpy(cmd->name, name);
- else
+ if (name) {
+ cmd->items[0].size = KDBUS_ITEM_HEADER_SIZE + strlen(name) + 1;
+ cmd->items[0].type = KDBUS_ITEM_NAME;
+ strcpy(cmd->items[0].str, name);
+ } else {
cmd->id = id;
+ }
ret = ioctl(conn->fd, KDBUS_CMD_CONN_INFO, cmd);
if (ret < 0)
int ret;
struct {
struct kdbus_cmd_conn_info cmd_info;
- char name[64];
+
+ struct {
+ uint64_t size;
+ uint64_t type;
+ char str[64];
+ } name;
} buf;
buf.cmd_info.size = sizeof(struct kdbus_cmd_conn_info);
ASSERT_RETURN(ret == 0);
/* try to pass a name that is longer than the buffer's size */
- strcpy(buf.cmd_info.name, "foo.bar.bla");
+ buf.name.size = KDBUS_ITEM_HEADER_SIZE + 1;
+ buf.name.type = KDBUS_ITEM_NAME;
+ strcpy(buf.name.str, "foo.bar.bla");
+
buf.cmd_info.id = 0;
- buf.cmd_info.size = sizeof(struct kdbus_cmd_conn_info) + 10;
+ buf.cmd_info.size = sizeof(buf.cmd_info) + buf.name.size;
ret = ioctl(env->conn->fd, KDBUS_CMD_CONN_INFO, &buf);
ASSERT_RETURN(ret == -1 && errno == EINVAL);