chiark / gitweb /
sd-bus: sync kdbus.h
[elogind.git] / src / libsystemd / sd-bus / bus-kernel.c
index a7811eea0a10fc55f81e8337f108f7a718f67c99..5b193be0200349ecaea7db433127fadfd0deefce 100644 (file)
@@ -32,6 +32,7 @@
 #include "util.h"
 #include "strv.h"
 #include "memfd-util.h"
+#include "capability.h"
 #include "cgroup-util.h"
 #include "fileio.h"
 
@@ -295,7 +296,8 @@ static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) {
 
         m->kdbus->flags =
                 ((m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) ? 0 : KDBUS_MSG_EXPECT_REPLY) |
-                ((m->header->flags & BUS_MESSAGE_NO_AUTO_START) ? KDBUS_MSG_NO_AUTO_START : 0);
+                ((m->header->flags & BUS_MESSAGE_NO_AUTO_START) ? KDBUS_MSG_NO_AUTO_START : 0) |
+                ((m->header->type == SD_BUS_MESSAGE_SIGNAL) ? KDBUS_MSG_SIGNAL : 0);
 
         if (well_known)
                 /* verify_destination_id will usually be 0, which makes the kernel driver only look
@@ -673,8 +675,13 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
                         break;
 
                 case KDBUS_ITEM_CAPS:
-                        m->creds.capability = (uint8_t *) d->caps.caps;
-                        m->creds.capability_size = d->size - offsetof(struct kdbus_item, caps.caps);
+                        if (d->caps.last_cap != cap_last_cap() ||
+                            d->size - offsetof(struct kdbus_item, caps.caps) < DIV_ROUND_UP(d->caps.last_cap, 32U) * 4 * 4) {
+                                r = -EBADMSG;
+                                goto fail;
+                        }
+
+                        m->creds.capability = d->caps.caps;
                         m->creds.mask |= (SD_BUS_CREDS_EFFECTIVE_CAPS|SD_BUS_CREDS_PERMITTED_CAPS|SD_BUS_CREDS_INHERITABLE_CAPS|SD_BUS_CREDS_BOUNDING_CAPS) & bus->creds_mask;
                         break;
 
@@ -744,7 +751,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
 
         /* If we requested the list of well-known names to be appended
          * and the sender had none no item for it will be
-         * attached. However, this does *not* mean that we the kernel
+         * attached. However, this does *not* mean that the kernel
          * didn't want to provide this information to us. Hence, let's
          * explicitly mark this information as available if it was
          * requested. */