*d = (struct kdbus_item *) ((uint8_t*) *d + (*d)->size);
}
-static void append_payload_memfd(struct kdbus_item **d, int memfd, size_t sz) {
+static void append_payload_memfd(struct kdbus_item **d, int memfd, size_t start, size_t sz) {
assert(d);
assert(memfd >= 0);
assert(sz > 0);
(*d)->size = offsetof(struct kdbus_item, memfd) + sizeof(struct kdbus_memfd);
(*d)->type = KDBUS_ITEM_PAYLOAD_MEMFD;
(*d)->memfd.fd = memfd;
+ (*d)->memfd.start = start;
(*d)->memfd.size = sz;
*d = (struct kdbus_item *) ((uint8_t*) *d + (*d)->size);
sz = offsetof(struct kdbus_msg, items);
- assert_cc(ALIGN8(offsetof(struct kdbus_item, vec) + sizeof(struct kdbus_vec)) ==
- ALIGN8(offsetof(struct kdbus_item, memfd) + sizeof(struct kdbus_memfd)));
-
/* Add in fixed header, fields header and payload */
- sz += (1 + m->n_body_parts) *
- ALIGN8(offsetof(struct kdbus_item, vec) + sizeof(struct kdbus_vec));
+ sz += (1 + m->n_body_parts) * ALIGN8(offsetof(struct kdbus_item, vec) +
+ MAX(sizeof(struct kdbus_vec),
+ sizeof(struct kdbus_memfd)));
/* Add space for bloom filter */
sz += ALIGN8(offsetof(struct kdbus_item, bloom_filter) +
/* Try to send a memfd, if the part is
* sealed and this is not a broadcast. Since we can only */
- append_payload_memfd(&d, part->memfd, part->size);
+ append_payload_memfd(&d, part->memfd, part->memfd_offset, part->size);
continue;
}
}
part->memfd = d->memfd.fd;
+ part->memfd_offset = d->memfd.start;
part->size = d->memfd.size;
part->sealed = true;
case KDBUS_ITEM_PIDS:
- /* The PID starttime/TID might be missing,
- * when the data is faked by some data bus
- * proxy and it lacks that information about
- * the real client since SO_PEERCRED is used
- * for that. */
+ /* The PID/TID might be missing, when the data
+ * is faked by some data bus proxy and it
+ * lacks that information about the real
+ * client since SO_PEERCRED is used for
+ * that. */
if (d->pids.pid > 0) {
m->creds.pid = (pid_t) d->pids.pid;
m->creds.mask |= SD_BUS_CREDS_PID & bus->creds_mask;
}
- if (d->pids.starttime > 0) {
- m->creds.pid_starttime = d->pids.starttime / NSEC_PER_USEC;
- m->creds.mask |= SD_BUS_CREDS_PID_STARTTIME & bus->creds_mask;
- }
-
if (d->pids.tid > 0) {
m->creds.tid = (pid_t) d->pids.tid;
m->creds.mask |= SD_BUS_CREDS_TID & bus->creds_mask;
SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID))
m |= KDBUS_ATTACH_CREDS;
- if (mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID))
+ if (mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_TID))
m |= KDBUS_ATTACH_PIDS;
if (mask & SD_BUS_CREDS_COMM)