Skip to contentSkip to conversation

kdbus: fix wrong message size on 32bit

PATCH New David Herrmann 1 participant 1 message Jul 24, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kdbus: fix wrong message size on 32bit

When broadcasting messages, each receiver might get a different message due to different metadata requirements. Therefore, the value of msg->size might be different for each receiver. To account for that, we use a temporary variable to store the real size and use it as source for the iovec-copy transaction instead of &msg->size.

But we incorrectly used "size_t" for this variable. Hence, on 32bit, we end up missing 4 bytes of the message header as "size_t" might only be 32bit wide.

Fix this and properly use "u64" for the message size that is copied to user-space.

---
 ipc/kdbus/message.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
ipc/kdbus/message.c +2 -2
index 27a5021..432dba4 100644
@@ -886,9 +886,9 @@ struct kdbus_pool_slice *kdbus_staging_emit(struct kdbus_staging *staging,
 {
 	struct kdbus_item *item, *meta_items = NULL;
 	struct kdbus_pool_slice *slice = NULL;
-	size_t off, size, msg_size, meta_size;
+	size_t off, size, meta_size;
 	struct iovec *v;
-	u64 attach;
+	u64 attach, msg_size;
 	int ret;
 
 	/*
Signature · 1 line
2.4.6