summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-kernel.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-09-22 12:49:47 +0200
committerDavid Herrmann <dh.herrmann@gmail.com>2014-09-22 14:27:02 +0200
commit7f3d3ba1a61f28a951ca5fbe59ed15c7ce55219c (patch)
tree9370d82e5ca140322c15e2c70af75c67de64511b /src/libsystemd/sd-bus/bus-kernel.c
parent95d78c7e7c81a6b788f28c33ef2cafd87471a0d7 (diff)
bus: align kdbus ioctl parameters to 8byte
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.
Diffstat (limited to 'src/libsystemd/sd-bus/bus-kernel.c')
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index b3cc996b1e..c30491e687 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -709,7 +709,7 @@ int bus_kernel_take_fd(sd_bus *b) {
sz += ALIGN8(offsetof(struct kdbus_item, str) + l + 1);
}
- hello = alloca0(sz);
+ hello = alloca0_align(sz, 8);
hello->size = sz;
hello->conn_flags = b->hello_flags;
hello->attach_flags = b->attach_flags;
@@ -796,7 +796,7 @@ int bus_kernel_connect(sd_bus *b) {
}
static void close_kdbus_msg(sd_bus *bus, struct kdbus_msg *k) {
- uint64_t off;
+ uint64_t off _alignas_(8);
struct kdbus_item *d;
assert(bus);
@@ -1268,10 +1268,11 @@ int bus_kernel_create_bus(const char *name, bool world, char **s) {
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);
@@ -1423,7 +1424,7 @@ int bus_kernel_create_endpoint(const char *bus_name, const char *ep_name, char *
size = ALIGN8(offsetof(struct kdbus_cmd_make, items));
size += ALIGN8(offsetof(struct kdbus_item, str) + strlen(ep_name) + 1);
- make = alloca0(size);
+ make = alloca0_align(size, 8);
make->size = size;
make->flags = KDBUS_MAKE_ACCESS_WORLD;
@@ -1472,7 +1473,7 @@ int bus_kernel_set_endpoint_policy(int fd, uid_t uid, BusEndpoint *ep) {
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;
@@ -1528,7 +1529,7 @@ int bus_kernel_make_starter(
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(size);
+ hello = alloca0_align(size, 8);
n = hello->items;
strcpy(n->str, name);
@@ -1588,9 +1589,10 @@ int bus_kernel_create_domain(const char *name, char **s) {
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);