All kdbus ioctl arguments must be 8byte aligned. Make sure we use
alloca_align() and _alignas_(8) in all situations where gcc doesn't
guarantee 8-byte alignment.
Note that objects on the stack are always 8byte aligned as we put
_alignas_(8) into the structure definition in kdbus.h.
l = strlen(name);
size = offsetof(struct kdbus_cmd_name, name) + l + 1;
l = strlen(name);
size = offsetof(struct kdbus_cmd_name, name) + l + 1;
+ n = alloca0_align(size, 8);
n->size = size;
kdbus_translate_request_name_flags(flags, (uint64_t *) &n->flags);
memcpy(n->name, name, l+1);
n->size = size;
kdbus_translate_request_name_flags(flags, (uint64_t *) &n->flags);
memcpy(n->name, name, l+1);
assert(name);
l = strlen(name);
assert(name);
l = strlen(name);
- n = alloca0(offsetof(struct kdbus_cmd_name, name) + l + 1);
+ n = alloca0_align(offsetof(struct kdbus_cmd_name, name) + l + 1, 8);
n->size = offsetof(struct kdbus_cmd_name, name) + l + 1;
memcpy(n->name, name, l+1);
n->size = offsetof(struct kdbus_cmd_name, name) + l + 1;
memcpy(n->name, name, l+1);
return r;
if (r > 0) {
size = offsetof(struct kdbus_cmd_conn_info, name);
return r;
if (r > 0) {
size = offsetof(struct kdbus_cmd_conn_info, name);
+ cmd = alloca0_align(size, 8);
cmd->id = id;
} else {
size = offsetof(struct kdbus_cmd_conn_info, name) + strlen(name) + 1;
cmd->id = id;
} else {
size = offsetof(struct kdbus_cmd_conn_info, name) + strlen(name) + 1;
+ cmd = alloca0_align(size, 8);
strcpy(cmd->name, name);
}
strcpy(cmd->name, name);
}
offsetof(struct kdbus_notify_name_change, name) +
l);
offsetof(struct kdbus_notify_name_change, name) +
l);
+ m = alloca0_align(sz, 8);
m->size = sz;
m->cookie = cookie;
m->size = sz;
m->cookie = cookie;
offsetof(struct kdbus_item, id_change) +
sizeof(struct kdbus_notify_id_change));
offsetof(struct kdbus_item, id_change) +
sizeof(struct kdbus_notify_id_change));
+ m = alloca0_align(sz, 8);
m->size = sz;
m->cookie = cookie;
m->size = sz;
m->cookie = cookie;
if (using_bloom)
sz += ALIGN8(offsetof(struct kdbus_item, data64) + bus->bloom_size);
if (using_bloom)
sz += ALIGN8(offsetof(struct kdbus_item, data64) + bus->bloom_size);
+ m = alloca0_align(sz, 8);
m->size = sz;
m->cookie = cookie;
m->size = sz;
m->cookie = cookie;
sz += ALIGN8(offsetof(struct kdbus_item, str) + l + 1);
}
sz += ALIGN8(offsetof(struct kdbus_item, str) + l + 1);
}
+ hello = alloca0_align(sz, 8);
hello->size = sz;
hello->conn_flags = b->hello_flags;
hello->attach_flags = b->attach_flags;
hello->size = sz;
hello->conn_flags = b->hello_flags;
hello->attach_flags = b->attach_flags;
}
static void close_kdbus_msg(sd_bus *bus, struct kdbus_msg *k) {
}
static void close_kdbus_msg(sd_bus *bus, struct kdbus_msg *k) {
+ uint64_t off _alignas_(8);
struct kdbus_item *d;
assert(bus);
struct kdbus_item *d;
assert(bus);
if (fd < 0)
return -errno;
if (fd < 0)
return -errno;
- make = alloca0(ALIGN8(offsetof(struct kdbus_cmd_make, items) +
- offsetof(struct kdbus_item, data64) + sizeof(uint64_t) +
- offsetof(struct kdbus_item, str) +
- DECIMAL_STR_MAX(uid_t) + 1 + strlen(name) + 1));
+ make = alloca0_align(ALIGN8(offsetof(struct kdbus_cmd_make, items) +
+ offsetof(struct kdbus_item, data64) + sizeof(uint64_t) +
+ offsetof(struct kdbus_item, str) +
+ DECIMAL_STR_MAX(uid_t) + 1 + strlen(name) + 1),
+ 8);
make->size = offsetof(struct kdbus_cmd_make, items);
make->size = offsetof(struct kdbus_cmd_make, items);
size = ALIGN8(offsetof(struct kdbus_cmd_make, items));
size += ALIGN8(offsetof(struct kdbus_item, str) + strlen(ep_name) + 1);
size = ALIGN8(offsetof(struct kdbus_cmd_make, items));
size += ALIGN8(offsetof(struct kdbus_item, str) + strlen(ep_name) + 1);
+ make = alloca0_align(size, 8);
make->size = size;
make->flags = KDBUS_MAKE_ACCESS_WORLD;
make->size = size;
make->flags = KDBUS_MAKE_ACCESS_WORLD;
size += ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
}
size += ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
}
- update = alloca0(size);
+ update = alloca0_align(size, 8);
update->size = size;
n = update->items;
update->size = size;
n = update->items;
ALIGN8(offsetof(struct kdbus_item, str) + strlen(name) + 1) +
policy_cnt * ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
ALIGN8(offsetof(struct kdbus_item, str) + strlen(name) + 1) +
policy_cnt * ALIGN8(offsetof(struct kdbus_item, policy_access) + sizeof(struct kdbus_policy_access));
+ hello = alloca0_align(size, 8);
n = hello->items;
strcpy(n->str, name);
n = hello->items;
strcpy(n->str, name);
if (fd < 0)
return -errno;
if (fd < 0)
return -errno;
- make = alloca0(ALIGN8(offsetof(struct kdbus_cmd_make, items) +
- offsetof(struct kdbus_item, str) +
- strlen(name) + 1));
+ make = alloca0_align(ALIGN8(offsetof(struct kdbus_cmd_make, items) +
+ offsetof(struct kdbus_item, str) +
+ strlen(name) + 1),
+ 8);
n = make->items;
strcpy(n->str, name);
n = make->items;
strcpy(n->str, name);
message_reset_parts(m);
if (m->release_kdbus) {
message_reset_parts(m);
if (m->release_kdbus) {
+ uint64_t off _alignas_(8);
off = (uint8_t *)m->kdbus - (uint8_t *)m->bus->kdbus_buffer;
ioctl(m->bus->input_fd, KDBUS_CMD_FREE, &off);
off = (uint8_t *)m->kdbus - (uint8_t *)m->bus->kdbus_buffer;
ioctl(m->bus->input_fd, KDBUS_CMD_FREE, &off);