2 * kdbus is free software; you can redistribute it and/or modify it under
3 * the terms of the GNU Lesser General Public License as published by the
4 * Free Software Foundation; either version 2.1 of the License, or (at
5 * your option) any later version.
11 #include <linux/ioctl.h>
12 #include <linux/types.h>
14 #define KDBUS_IOCTL_MAGIC 0x95
15 #define KDBUS_SRC_ID_KERNEL (0)
16 #define KDBUS_DST_ID_NAME (0)
17 #define KDBUS_MATCH_ID_ANY (~0ULL)
18 #define KDBUS_DST_ID_BROADCAST (~0ULL)
19 #define KDBUS_FLAG_KERNEL (1ULL << 63)
22 * struct kdbus_notify_id_change - name registry change message
23 * @id: New or former owner of the name
24 * @flags: flags field from KDBUS_HELLO_*
26 * Sent from kernel to userspace when the owner or activator of
27 * a well-known name changes.
31 * KDBUS_ITEM_ID_REMOVE
33 struct kdbus_notify_id_change {
39 * struct kdbus_notify_name_change - name registry change message
40 * @old_id: ID and flags of former owner of a name
41 * @new_id: ID and flags of new owner of a name
42 * @name: Well-known name
44 * Sent from kernel to userspace when the owner or activator of
45 * a well-known name changes.
49 * KDBUS_ITEM_NAME_REMOVE
50 * KDBUS_ITEM_NAME_CHANGE
52 struct kdbus_notify_name_change {
53 struct kdbus_notify_id_change old_id;
54 struct kdbus_notify_id_change new_id;
59 * struct kdbus_creds - process credentials
61 * @euid: Effective UID
63 * @fsuid: Filesystem UID
65 * @egid: Effective GID
67 * @fsgid: Filesystem GID
84 * struct kdbus_pids - process identifiers
87 * @ppid: Parent process ID
89 * The PID and TID of a process.
101 * struct kdbus_caps - process capabilities
102 * @last_cap: Highest currently known capability bit
103 * @caps: Variable number of 32-bit capabilities flags
105 * Contains a variable number of 32-bit capabilities flags.
116 * struct kdbus_audit - audit information
117 * @sessionid: The audit session ID
118 * @loginuid: The audit login uid
129 * struct kdbus_timestamp
130 * @seqnum: Global per-domain message sequence number
131 * @monotonic_ns: Monotonic timestamp, in nanoseconds
132 * @realtime_ns: Realtime timestamp, in nanoseconds
135 * KDBUS_ITEM_TIMESTAMP
137 struct kdbus_timestamp {
144 * struct kdbus_vec - I/O vector for kdbus payload items
145 * @size: The size of the vector
146 * @address: Memory address of data buffer
147 * @offset: Offset in the in-message payload memory,
148 * relative to the message head
151 * KDBUS_ITEM_PAYLOAD_VEC, KDBUS_ITEM_PAYLOAD_OFF
162 * struct kdbus_bloom_parameter - bus-wide bloom parameters
163 * @size: Size of the bit field in bytes (m / 8)
164 * @n_hash: Number of hash functions used (k)
166 struct kdbus_bloom_parameter {
172 * struct kdbus_bloom_filter - bloom filter containing n elements
173 * @generation: Generation of the element set in the filter
174 * @data: Bit field, multiple of 8 bytes
176 struct kdbus_bloom_filter {
182 * struct kdbus_memfd - a kdbus memfd
183 * @start: The offset into the memfd where the segment starts
184 * @size: The size of the memfd segment
185 * @fd: The file descriptor number
186 * @__pad: Padding to ensure proper alignment and size
189 * KDBUS_ITEM_PAYLOAD_MEMFD
199 * struct kdbus_name - a registered well-known name with its flags
200 * @flags: Flags from KDBUS_NAME_*
201 * @name: Well-known name
204 * KDBUS_ITEM_OWNED_NAME
212 * struct kdbus_policy_access - policy access item
213 * @type: One of KDBUS_POLICY_ACCESS_* types
214 * @access: Access to grant
215 * @id: For KDBUS_POLICY_ACCESS_USER, the uid
216 * For KDBUS_POLICY_ACCESS_GROUP, the gid
218 struct kdbus_policy_access {
219 __u64 type; /* USER, GROUP, WORLD */
220 __u64 access; /* OWN, TALK, SEE */
221 __u64 id; /* uid, gid, 0 */
225 * enum kdbus_item_type - item types to chain data in a list
226 * @_KDBUS_ITEM_NULL: Uninitialized/invalid
227 * @_KDBUS_ITEM_USER_BASE: Start of user items
228 * @KDBUS_ITEM_PAYLOAD_VEC: Vector to data
229 * @KDBUS_ITEM_PAYLOAD_OFF: Data at returned offset to message head
230 * @KDBUS_ITEM_PAYLOAD_MEMFD: Data as sealed memfd
231 * @KDBUS_ITEM_FDS: Attached file descriptors
232 * @KDBUS_ITEM_BLOOM_PARAMETER: Bus-wide bloom parameters, used with
233 * KDBUS_CMD_BUS_MAKE, carries a
234 * struct kdbus_bloom_parameter
235 * @KDBUS_ITEM_BLOOM_FILTER: Bloom filter carried with a message,
236 * used to match against a bloom mask of a
237 * connection, carries a struct
239 * @KDBUS_ITEM_BLOOM_MASK: Bloom mask used to match against a
240 * message'sbloom filter
241 * @KDBUS_ITEM_DST_NAME: Destination's well-known name
242 * @KDBUS_ITEM_MAKE_NAME: Name of domain, bus, endpoint
243 * @KDBUS_ITEM_ATTACH_FLAGS_SEND: Attach-flags, used for updating which
244 * metadata a connection opts in to send
245 * @KDBUS_ITEM_ATTACH_FLAGS_RECV: Attach-flags, used for updating which
246 * metadata a connection requests to
247 * receive for each reeceived message
248 * @KDBUS_ITEM_ID: Connection ID
249 * @KDBUS_ITEM_NAME: Well-know name with flags
250 * @_KDBUS_ITEM_ATTACH_BASE: Start of metadata attach items
251 * @KDBUS_ITEM_TIMESTAMP: Timestamp
252 * @KDBUS_ITEM_CREDS: Process credentials
253 * @KDBUS_ITEM_PIDS: Process identifiers
254 * @KDBUS_ITEM_AUXGROUPS: Auxiliary process groups
255 * @KDBUS_ITEM_OWNED_NAME: A name owned by the associated
257 * @KDBUS_ITEM_TID_COMM: Thread ID "comm" identifier
258 * (Don't trust this, see below.)
259 * @KDBUS_ITEM_PID_COMM: Process ID "comm" identifier
260 * (Don't trust this, see below.)
261 * @KDBUS_ITEM_EXE: The path of the executable
262 * (Don't trust this, see below.)
263 * @KDBUS_ITEM_CMDLINE: The process command line
264 * (Don't trust this, see below.)
265 * @KDBUS_ITEM_CGROUP: The croup membership
266 * @KDBUS_ITEM_CAPS: The process capabilities
267 * @KDBUS_ITEM_SECLABEL: The security label
268 * @KDBUS_ITEM_AUDIT: The audit IDs
269 * @KDBUS_ITEM_CONN_DESCRIPTION: The connection's human-readable name
271 * @_KDBUS_ITEM_POLICY_BASE: Start of policy items
272 * @KDBUS_ITEM_POLICY_ACCESS: Policy access block
273 * @_KDBUS_ITEM_KERNEL_BASE: Start of kernel-generated message items
274 * @KDBUS_ITEM_NAME_ADD: Notification in kdbus_notify_name_change
275 * @KDBUS_ITEM_NAME_REMOVE: Notification in kdbus_notify_name_change
276 * @KDBUS_ITEM_NAME_CHANGE: Notification in kdbus_notify_name_change
277 * @KDBUS_ITEM_ID_ADD: Notification in kdbus_notify_id_change
278 * @KDBUS_ITEM_ID_REMOVE: Notification in kdbus_notify_id_change
279 * @KDBUS_ITEM_REPLY_TIMEOUT: Timeout has been reached
280 * @KDBUS_ITEM_REPLY_DEAD: Destination died
282 * N.B: The process and thread COMM fields, as well as the CMDLINE and
283 * EXE fields may be altered by unprivileged processes und should
284 * hence *not* used for security decisions. Peers should make use of
285 * these items only for informational purposes, such as generating log
288 enum kdbus_item_type {
290 _KDBUS_ITEM_USER_BASE,
291 KDBUS_ITEM_PAYLOAD_VEC = _KDBUS_ITEM_USER_BASE,
292 KDBUS_ITEM_PAYLOAD_OFF,
293 KDBUS_ITEM_PAYLOAD_MEMFD,
295 KDBUS_ITEM_BLOOM_PARAMETER,
296 KDBUS_ITEM_BLOOM_FILTER,
297 KDBUS_ITEM_BLOOM_MASK,
299 KDBUS_ITEM_MAKE_NAME,
300 KDBUS_ITEM_ATTACH_FLAGS_SEND,
301 KDBUS_ITEM_ATTACH_FLAGS_RECV,
305 /* keep these item types in sync with KDBUS_ATTACH_* flags */
306 _KDBUS_ITEM_ATTACH_BASE = 0x1000,
307 KDBUS_ITEM_TIMESTAMP = _KDBUS_ITEM_ATTACH_BASE,
310 KDBUS_ITEM_AUXGROUPS,
311 KDBUS_ITEM_OWNED_NAME,
320 KDBUS_ITEM_CONN_DESCRIPTION,
322 _KDBUS_ITEM_POLICY_BASE = 0x2000,
323 KDBUS_ITEM_POLICY_ACCESS = _KDBUS_ITEM_POLICY_BASE,
325 _KDBUS_ITEM_KERNEL_BASE = 0x8000,
326 KDBUS_ITEM_NAME_ADD = _KDBUS_ITEM_KERNEL_BASE,
327 KDBUS_ITEM_NAME_REMOVE,
328 KDBUS_ITEM_NAME_CHANGE,
330 KDBUS_ITEM_ID_REMOVE,
331 KDBUS_ITEM_REPLY_TIMEOUT,
332 KDBUS_ITEM_REPLY_DEAD,
336 * struct kdbus_item - chain of data blocks
337 * @size: Overall data record size
338 * @type: Kdbus_item type of data
339 * @data: Generic bytes
340 * @data32: Generic 32 bit array
341 * @data64: Generic 64 bit array
342 * @str: Generic string
344 * @vec: KDBUS_ITEM_PAYLOAD_VEC
345 * @creds: KDBUS_ITEM_CREDS
346 * @audit: KDBUS_ITEM_AUDIT
347 * @timestamp: KDBUS_ITEM_TIMESTAMP
348 * @name: KDBUS_ITEM_NAME
349 * @bloom_parameter: KDBUS_ITEM_BLOOM_PARAMETER
350 * @bloom_filter: KDBUS_ITEM_BLOOM_FILTER
351 * @memfd: KDBUS_ITEM_PAYLOAD_MEMFD
352 * @name_change: KDBUS_ITEM_NAME_ADD
353 * KDBUS_ITEM_NAME_REMOVE
354 * KDBUS_ITEM_NAME_CHANGE
355 * @id_change: KDBUS_ITEM_ID_ADD
356 * KDBUS_ITEM_ID_REMOVE
357 * @policy: KDBUS_ITEM_POLICY_ACCESS
369 struct kdbus_vec vec;
370 struct kdbus_creds creds;
371 struct kdbus_pids pids;
372 struct kdbus_audit audit;
373 struct kdbus_caps caps;
374 struct kdbus_timestamp timestamp;
375 struct kdbus_name name;
376 struct kdbus_bloom_parameter bloom_parameter;
377 struct kdbus_bloom_filter bloom_filter;
378 struct kdbus_memfd memfd;
380 struct kdbus_notify_name_change name_change;
381 struct kdbus_notify_id_change id_change;
382 struct kdbus_policy_access policy_access;
387 * enum kdbus_msg_flags - type of message
388 * @KDBUS_MSG_EXPECT_REPLY: Expect a reply message, used for
389 * method calls. The userspace-supplied
390 * cookie identifies the message and the
391 * respective reply carries the cookie
393 * @KDBUS_MSG_NO_AUTO_START: Do not start a service, if the addressed
394 * name is not currently active
396 enum kdbus_msg_flags {
397 KDBUS_MSG_EXPECT_REPLY = 1ULL << 0,
398 KDBUS_MSG_NO_AUTO_START = 1ULL << 1,
402 * enum kdbus_payload_type - type of payload carried by message
403 * @KDBUS_PAYLOAD_KERNEL: Kernel-generated simple message
404 * @KDBUS_PAYLOAD_DBUS: D-Bus marshalling "DBusDBus"
406 * Any payload-type is accepted. Common types will get added here once
409 enum kdbus_payload_type {
410 KDBUS_PAYLOAD_KERNEL,
411 KDBUS_PAYLOAD_DBUS = 0x4442757344427573ULL,
415 * struct kdbus_msg - the representation of a kdbus message
416 * @size: Total size of the message
417 * @flags: Message flags (KDBUS_MSG_*), userspace → kernel
418 * @priority: Message queue priority value
419 * @dst_id: 64-bit ID of the destination connection
420 * @src_id: 64-bit ID of the source connection
421 * @payload_type: Payload type (KDBUS_PAYLOAD_*)
422 * @cookie: Userspace-supplied cookie, for the connection
423 * to identify its messages
424 * @timeout_ns: The time to wait for a message reply from the peer.
425 * If there is no reply, a kernel-generated message
426 * with an attached KDBUS_ITEM_REPLY_TIMEOUT item
427 * is sent to @src_id. The timeout is expected in
428 * nanoseconds and as absolute CLOCK_MONOTONIC value.
429 * @cookie_reply: A reply to the requesting message with the same
430 * cookie. The requesting connection can match its
431 * request and the reply with this value
432 * @items: A list of kdbus_items containing the message payload
446 struct kdbus_item items[0];
447 } __attribute__((aligned(8)));
450 * struct kdbus_reply - reply container
451 * @offset: Offset of kdbus_msg slice in pool
452 * @msg_size: Copy of the kdbus_msg.size field
453 * @return_flags: Command return flags, kernel → userspace
462 * enum kdbus_send_flags - flags for sending messages
463 * @KDBUS_SEND_SYNC_REPLY: Wait for destination connection to
464 * reply to this message. The
465 * KDBUS_CMD_SEND ioctl() will block
466 * until the reply is received, and
467 * offset_reply in struct kdbus_msg will
468 * yield the offset in the sender's pool
469 * where the reply can be found.
470 * This flag is only valid if
471 * @KDBUS_MSG_EXPECT_REPLY is set as well.
473 enum kdbus_send_flags {
474 KDBUS_SEND_SYNC_REPLY = 1ULL << 0,
478 * struct kdbus_cmd_send - send message
479 * @size: Overall size of this structure
480 * @flags: Flags to change send behavior (KDBUS_SEND_*)
481 * @kernel_flags: Supported send flags, kernel → userspace
482 * @kernel_msg_flags: Supported message flags, kernel → userspace
483 * @return_flags: Command return flags, kernel → userspace
484 * @msg_address: Storage address of the kdbus_msg to send
485 * @reply: Storage for message reply if KDBUS_SEND_SYNC_REPLY
487 * @items: Additional items for this command
489 struct kdbus_cmd_send {
493 __u64 kernel_msg_flags;
496 struct kdbus_reply reply;
497 struct kdbus_item items[0];
498 } __attribute__((aligned(8)));
501 * enum kdbus_recv_flags - flags for de-queuing messages
502 * @KDBUS_RECV_PEEK: Return the next queued message without
503 * actually de-queuing it, and without installing
504 * any file descriptors or other resources. It is
505 * usually used to determine the activating
506 * connection of a bus name.
507 * @KDBUS_RECV_DROP: Drop and free the next queued message and all
508 * its resources without actually receiving it.
509 * @KDBUS_RECV_USE_PRIORITY: Only de-queue messages with the specified or
510 * higher priority (lowest values); if not set,
511 * the priority value is ignored.
513 enum kdbus_recv_flags {
514 KDBUS_RECV_PEEK = 1ULL << 0,
515 KDBUS_RECV_DROP = 1ULL << 1,
516 KDBUS_RECV_USE_PRIORITY = 1ULL << 2,
520 * enum kdbus_recv_return_flags - return flags for message receive commands
521 * @KDBUS_RECV_RETURN_INCOMPLETE_FDS: One or more file descriptors could not
522 * be installed. These descriptors in
523 * KDBUS_ITEM_FDS will carry the value -1.
525 enum kdbus_recv_return_flags {
526 KDBUS_RECV_RETURN_INCOMPLETE_FDS = 1ULL << 0,
530 * struct kdbus_cmd_recv - struct to de-queue a buffered message
531 * @size: Overall size of this object
532 * @flags: KDBUS_RECV_* flags, userspace → kernel
533 * @kernel_flags: Supported KDBUS_RECV_* flags, kernel → userspace
534 * @return_flags: Command return flags, kernel → userspace
535 * @priority: Minimum priority of the messages to de-queue. Lowest
536 * values have the highest priority.
537 * @dropped_msgs: In case the KDBUS_CMD_RECV ioctl returns
538 * -EOVERFLOW, this field will contain the number of
539 * broadcast messages that have been lost since the
541 * @reply: Return storage for received message.
542 * @items: Additional items for this command.
544 * This struct is used with the KDBUS_CMD_RECV ioctl.
546 struct kdbus_cmd_recv {
553 struct kdbus_reply reply;
554 struct kdbus_item items[0];
555 } __attribute__((aligned(8)));
558 * struct kdbus_cmd_cancel - struct to cancel a synchronously pending message
559 * @size: Overall size of this object
560 * @flags: Flags for the free command. Currently unused.
561 * @kernel_flags: Supported flags of CANCEL, kernel → userspace
562 * @return_flags: Command return flags, kernel → userspace
563 * @cookie: The cookie of the pending message
564 * @items: Items to modify the command behavior
566 * This struct is used with the KDBUS_CMD_CANCEL ioctl.
568 struct kdbus_cmd_cancel {
574 struct kdbus_item items[0];
575 } __attribute__((aligned(8)));
578 * struct kdbus_cmd_free - struct to free a slice of memory in the pool
579 * @size: Overall size of this structure
580 * @offset: The offset of the memory slice, as returned by other
582 * @flags: Flags for the free command, userspace → kernel
583 * @return_flags: Command return flags, kernel → userspace
584 * @kernel_flags: Supported flags of the free command, userspace → kernel
585 * @items: Additional items to modify the behavior
587 * This struct is used with the KDBUS_CMD_FREE ioctl.
589 struct kdbus_cmd_free {
595 struct kdbus_item items[0];
596 } __attribute__((aligned(8)));
599 * enum kdbus_policy_access_type - permissions of a policy record
600 * @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid
601 * @KDBUS_POLICY_ACCESS_USER: Grant access to a uid
602 * @KDBUS_POLICY_ACCESS_GROUP: Grant access to gid
603 * @KDBUS_POLICY_ACCESS_WORLD: World-accessible
605 enum kdbus_policy_access_type {
606 _KDBUS_POLICY_ACCESS_NULL,
607 KDBUS_POLICY_ACCESS_USER,
608 KDBUS_POLICY_ACCESS_GROUP,
609 KDBUS_POLICY_ACCESS_WORLD,
613 * enum kdbus_policy_access_flags - mode flags
614 * @KDBUS_POLICY_OWN: Allow to own a well-known name
615 * Implies KDBUS_POLICY_TALK and KDBUS_POLICY_SEE
616 * @KDBUS_POLICY_TALK: Allow communication to a well-known name
617 * Implies KDBUS_POLICY_SEE
618 * @KDBUS_POLICY_SEE: Allow to see a well-known name
620 enum kdbus_policy_type {
621 KDBUS_POLICY_SEE = 0,
627 * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello
628 * @KDBUS_HELLO_ACCEPT_FD: The connection allows the reception of
629 * any passed file descriptors
630 * @KDBUS_HELLO_ACTIVATOR: Special-purpose connection which registers
631 * a well-know name for a process to be started
632 * when traffic arrives
633 * @KDBUS_HELLO_POLICY_HOLDER: Special-purpose connection which registers
634 * policy entries for a name. The provided name
635 * is not activated and not registered with the
636 * name database, it only allows unprivileged
637 * connections to acquire a name, talk or discover
639 * @KDBUS_HELLO_MONITOR: Special-purpose connection to monitor
641 * @KDBUS_HELLO_UNPRIVILEGED: Don't treat this connection as privileged once
642 * the bus connection was established.
644 enum kdbus_hello_flags {
645 KDBUS_HELLO_ACCEPT_FD = 1ULL << 0,
646 KDBUS_HELLO_ACTIVATOR = 1ULL << 1,
647 KDBUS_HELLO_POLICY_HOLDER = 1ULL << 2,
648 KDBUS_HELLO_MONITOR = 1ULL << 3,
649 KDBUS_HELLO_UNPRIVILEGED = 1ULL << 4,
653 * enum kdbus_attach_flags - flags for metadata attachments
654 * @KDBUS_ATTACH_TIMESTAMP: Timestamp
655 * @KDBUS_ATTACH_CREDS: Credentials
656 * @KDBUS_ATTACH_PIDS: PIDs
657 * @KDBUS_ATTACH_AUXGROUPS: Auxiliary groups
658 * @KDBUS_ATTACH_NAMES: Well-known names
659 * @KDBUS_ATTACH_TID_COMM: The "comm" process identifier of the TID
660 * @KDBUS_ATTACH_PID_COMM: The "comm" process identifier of the PID
661 * @KDBUS_ATTACH_EXE: The path of the executable
662 * @KDBUS_ATTACH_CMDLINE: The process command line
663 * @KDBUS_ATTACH_CGROUP: The croup membership
664 * @KDBUS_ATTACH_CAPS: The process capabilities
665 * @KDBUS_ATTACH_SECLABEL: The security label
666 * @KDBUS_ATTACH_AUDIT: The audit IDs
667 * @KDBUS_ATTACH_CONN_DESCRIPTION: The human-readable connection name
668 * @_KDBUS_ATTACH_ALL: All of the above
669 * @_KDBUS_ATTACH_ANY: Wildcard match to enable any kind of
672 enum kdbus_attach_flags {
673 KDBUS_ATTACH_TIMESTAMP = 1ULL << 0,
674 KDBUS_ATTACH_CREDS = 1ULL << 1,
675 KDBUS_ATTACH_PIDS = 1ULL << 2,
676 KDBUS_ATTACH_AUXGROUPS = 1ULL << 3,
677 KDBUS_ATTACH_NAMES = 1ULL << 4,
678 KDBUS_ATTACH_TID_COMM = 1ULL << 5,
679 KDBUS_ATTACH_PID_COMM = 1ULL << 6,
680 KDBUS_ATTACH_EXE = 1ULL << 7,
681 KDBUS_ATTACH_CMDLINE = 1ULL << 8,
682 KDBUS_ATTACH_CGROUP = 1ULL << 9,
683 KDBUS_ATTACH_CAPS = 1ULL << 10,
684 KDBUS_ATTACH_SECLABEL = 1ULL << 11,
685 KDBUS_ATTACH_AUDIT = 1ULL << 12,
686 KDBUS_ATTACH_CONN_DESCRIPTION = 1ULL << 13,
687 _KDBUS_ATTACH_ALL = (1ULL << 14) - 1,
688 _KDBUS_ATTACH_ANY = ~0ULL
692 * struct kdbus_cmd_hello - struct to say hello to kdbus
693 * @size: The total size of the structure
694 * @flags: Connection flags (KDBUS_HELLO_*), userspace → kernel
695 * @kernel_flags: Supported connection flags, kernel → userspace
696 * @return_flags: Command return flags, kernel → userspace
697 * @attach_flags_send: Mask of metadata to attach to each message sent
698 * off by this connection (KDBUS_ATTACH_*)
699 * @attach_flags_recv: Mask of metadata to attach to each message receieved
700 * by the new connection (KDBUS_ATTACH_*)
701 * @bus_flags: The flags field copied verbatim from the original
702 * KDBUS_CMD_BUS_MAKE ioctl. It's intended to be useful
703 * to do negotiation of features of the payload that is
704 * transferred (kernel → userspace)
705 * @id: The ID of this connection (kernel → userspace)
706 * @pool_size: Size of the connection's buffer where the received
707 * messages are placed
708 * @bloom: The bloom properties of the bus, specified
709 * by the bus creator (kernel → userspace)
710 * @id128: Unique 128-bit ID of the bus (kernel → userspace)
711 * @items: A list of items
713 * This struct is used with the KDBUS_CMD_HELLO ioctl.
715 struct kdbus_cmd_hello {
720 __u64 attach_flags_send;
721 __u64 attach_flags_recv;
725 struct kdbus_bloom_parameter bloom;
727 struct kdbus_item items[0];
728 } __attribute__((aligned(8)));
731 * enum kdbus_make_flags - Flags for KDBUS_CMD_{BUS,EP,NS}_MAKE
732 * @KDBUS_MAKE_ACCESS_GROUP: Make the bus or endpoint node group-accessible
733 * @KDBUS_MAKE_ACCESS_WORLD: Make the bus or endpoint node world-accessible
735 enum kdbus_make_flags {
736 KDBUS_MAKE_ACCESS_GROUP = 1ULL << 0,
737 KDBUS_MAKE_ACCESS_WORLD = 1ULL << 1,
741 * struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain
742 * @size: The total size of the struct
743 * @flags: Properties for the bus/ep/domain to create,
745 * @kernel_flags: Supported flags for the used command, kernel → userspace
746 * @return_flags: Command return flags, kernel → userspace
747 * @items: Items describing details
749 * This structure is used with the KDBUS_CMD_BUS_MAKE and
750 * KDBUS_CMD_ENDPOINT_MAKE ioctls.
752 struct kdbus_cmd_make {
757 struct kdbus_item items[0];
758 } __attribute__((aligned(8)));
761 * enum kdbus_name_flags - properties of a well-known name
762 * @KDBUS_NAME_REPLACE_EXISTING: Try to replace name of other connections
763 * @KDBUS_NAME_ALLOW_REPLACEMENT: Allow the replacement of the name
764 * @KDBUS_NAME_QUEUE: Name should be queued if busy
765 * @KDBUS_NAME_IN_QUEUE: Name is queued
766 * @KDBUS_NAME_ACTIVATOR: Name is owned by a activator connection
768 enum kdbus_name_flags {
769 KDBUS_NAME_REPLACE_EXISTING = 1ULL << 0,
770 KDBUS_NAME_ALLOW_REPLACEMENT = 1ULL << 1,
771 KDBUS_NAME_QUEUE = 1ULL << 2,
772 KDBUS_NAME_IN_QUEUE = 1ULL << 3,
773 KDBUS_NAME_ACTIVATOR = 1ULL << 4,
777 * struct kdbus_cmd_name - struct to describe a well-known name
778 * @size: The total size of the struct
779 * @flags: Flags for a name entry (KDBUS_NAME_*),
780 * userspace → kernel, kernel → userspace
781 * @kernel_flags: Supported flags for a name entry, kernel → userspace
782 * @return_flags: Command return flags, kernel → userspace
783 * @items: Item list, containing the well-known name as
786 * This structure is used with the KDBUS_CMD_NAME_ACQUIRE ioctl.
788 struct kdbus_cmd_name {
793 struct kdbus_item items[0];
794 } __attribute__((aligned(8)));
797 * struct kdbus_name_info - struct to describe a well-known name
798 * @size: The total size of the struct
799 * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*)
800 * @owner_id: The current owner of the name
801 * @items: Item list, containing the well-known name as
802 * KDBUS_ITEM_OWNED_NAME
804 * This structure is used as return struct for the KDBUS_CMD_NAME_LIST ioctl.
806 struct kdbus_name_info {
810 struct kdbus_item items[0];
811 } __attribute__((aligned(8)));
814 * struct kdbus_name_list - information returned by KDBUS_CMD_NAME_LIST
815 * @size: The total size of the structure
816 * @names: A list of names
818 * Note that the user is responsible for freeing the allocated memory with
819 * the KDBUS_CMD_FREE ioctl.
821 struct kdbus_name_list {
823 struct kdbus_name_info names[0];
827 * enum kdbus_name_list_flags - what to include into the returned list
828 * @KDBUS_NAME_LIST_UNIQUE: All active connections
829 * @KDBUS_NAME_LIST_NAMES: All known well-known names
830 * @KDBUS_NAME_LIST_ACTIVATORS: All activator connections
831 * @KDBUS_NAME_LIST_QUEUED: All queued-up names
833 enum kdbus_name_list_flags {
834 KDBUS_NAME_LIST_UNIQUE = 1ULL << 0,
835 KDBUS_NAME_LIST_NAMES = 1ULL << 1,
836 KDBUS_NAME_LIST_ACTIVATORS = 1ULL << 2,
837 KDBUS_NAME_LIST_QUEUED = 1ULL << 3,
841 * struct kdbus_cmd_name_list - request a list of name entries
842 * @flags: Flags for the query (KDBUS_NAME_LIST_*),
844 * @kernel_flags: Supported flags for queries, kernel → userspace
845 * @return_flags: Command return flags, kernel → userspace
846 * @offset: The returned offset in the caller's pool buffer.
847 * The user must use KDBUS_CMD_FREE to free the
849 * @size: Output buffer to report size of data at @offset.
851 * This structure is used with the KDBUS_CMD_NAME_LIST ioctl.
853 struct kdbus_cmd_name_list {
860 struct kdbus_item items[0];
861 } __attribute__((aligned(8)));
864 * struct kdbus_info - information returned by KDBUS_CMD_*_INFO
865 * @size: The total size of the struct
866 * @id: The connection's or bus' 64-bit ID
867 * @flags: The connection's or bus' flags
868 * @items: A list of struct kdbus_item
870 * Note that the user is responsible for freeing the allocated memory with
871 * the KDBUS_CMD_FREE ioctl.
877 struct kdbus_item items[0];
881 * struct kdbus_cmd_info - struct used for KDBUS_CMD_CONN_INFO ioctl
882 * @size: The total size of the struct
883 * @flags: KDBUS_ATTACH_* flags, userspace → kernel
884 * @kernel_flags: Supported KDBUS_ATTACH_* flags, kernel → userspace
885 * @return_flags: Command return flags, kernel → userspace
886 * @id: The 64-bit ID of the connection. If set to zero, passing
887 * @name is required. kdbus will look up the name to
888 * determine the ID in this case.
889 * @offset: Returned offset in the caller's pool buffer where the
890 * kdbus_info struct result is stored. The user must
891 * use KDBUS_CMD_FREE to free the allocated memory.
892 * @info_size: Output buffer to report size of data at @offset.
893 * @items: The optional item list, containing the
894 * well-known name to look up as a KDBUS_ITEM_NAME.
895 * Only needed in case @id is zero.
897 * On success, the KDBUS_CMD_CONN_INFO ioctl will return 0 and @offset will
898 * tell the user the offset in the connection pool buffer at which to find the
899 * result in a struct kdbus_info.
901 struct kdbus_cmd_info {
909 struct kdbus_item items[0];
910 } __attribute__((aligned(8)));
913 * struct kdbus_cmd_update - update flags of a connection
914 * @size: The total size of the struct
915 * @flags: Flags for the update command, userspace → kernel
916 * @kernel_flags: Supported flags for this command, kernel → userspace
917 * @return_flags: Command return flags, kernel → userspace
918 * @items: A list of struct kdbus_item
920 * This struct is used with the KDBUS_CMD_CONN_UPDATE ioctl.
922 struct kdbus_cmd_update {
927 struct kdbus_item items[0];
928 } __attribute__((aligned(8)));
931 * enum kdbus_cmd_match_flags - flags to control the KDBUS_CMD_MATCH_ADD ioctl
932 * @KDBUS_MATCH_REPLACE: If entries with the supplied cookie already
933 * exists, remove them before installing the new
936 enum kdbus_cmd_match_flags {
937 KDBUS_MATCH_REPLACE = 1ULL << 0,
941 * struct kdbus_cmd_match - struct to add or remove matches
942 * @size: The total size of the struct
943 * @cookie: Userspace supplied cookie. When removing, the cookie
944 * identifies the match to remove
945 * @flags: Flags for match command (KDBUS_MATCH_*),
947 * @kernel_flags: Supported flags of the used command, kernel → userspace
948 * @return_flags: Command return flags, kernel → userspace
949 * @items: A list of items for additional information
951 * This structure is used with the KDBUS_CMD_MATCH_ADD and
952 * KDBUS_CMD_MATCH_REMOVE ioctl.
954 struct kdbus_cmd_match {
960 struct kdbus_item items[0];
961 } __attribute__((aligned(8)));
965 * KDBUS_CMD_BUS_MAKE: After opening the "control" node, this command
966 * creates a new bus with the specified
967 * name. The bus is immediately shut down and
968 * cleaned up when the opened file descriptor is
970 * KDBUS_CMD_ENDPOINT_MAKE: Creates a new named special endpoint to talk to
971 * the bus. Such endpoints usually carry a more
972 * restrictive policy and grant restricted access
973 * to specific applications.
974 * KDBUS_CMD_HELLO: By opening the bus node, a connection is
975 * created. After a HELLO the opened connection
976 * becomes an active peer on the bus.
977 * KDBUS_CMD_BYEBYE: Disconnect a connection. If there are no
978 * messages queued up in the connection's pool,
979 * the call succeeds, and the handle is rendered
980 * unusable. Otherwise, -EBUSY is returned without
981 * any further side-effects.
982 * KDBUS_CMD_SEND: Send a message and pass data from userspace to
984 * KDBUS_CMD_RECV: Receive a message from the kernel which is
985 * placed in the receiver's pool.
986 * KDBUS_CMD_CANCEL: Cancel a pending request of a message that
987 * blocks while waiting for a reply. The parameter
988 * denotes the cookie of the message in flight.
989 * KDBUS_CMD_FREE: Release the allocated memory in the receiver's
991 * KDBUS_CMD_NAME_ACQUIRE: Request a well-known bus name to associate with
992 * the connection. Well-known names are used to
993 * address a peer on the bus.
994 * KDBUS_CMD_NAME_RELEASE: Release a well-known name the connection
996 * KDBUS_CMD_NAME_LIST: Retrieve the list of all currently registered
997 * well-known and unique names.
998 * KDBUS_CMD_CONN_INFO: Retrieve credentials and properties of the
999 * initial creator of the connection. The data was
1000 * stored at registration time and does not
1001 * necessarily represent the connected process or
1002 * the actual state of the process.
1003 * KDBUS_CMD_CONN_UPDATE: Update the properties of a connection. Used to
1004 * update the metadata subscription mask and
1006 * KDBUS_CMD_BUS_CREATOR_INFO: Retrieve information of the creator of the bus
1007 * a connection is attached to.
1008 * KDBUS_CMD_ENDPOINT_UPDATE: Update the properties of a custom enpoint. Used
1009 * to update the policy.
1010 * KDBUS_CMD_MATCH_ADD: Install a match which broadcast messages should
1011 * be delivered to the connection.
1012 * KDBUS_CMD_MATCH_REMOVE: Remove a current match for broadcast messages.
1014 #define KDBUS_CMD_BUS_MAKE _IOW(KDBUS_IOCTL_MAGIC, 0x00, \
1015 struct kdbus_cmd_make)
1016 #define KDBUS_CMD_ENDPOINT_MAKE _IOW(KDBUS_IOCTL_MAGIC, 0x10, \
1017 struct kdbus_cmd_make)
1019 #define KDBUS_CMD_HELLO _IOWR(KDBUS_IOCTL_MAGIC, 0x20, \
1020 struct kdbus_cmd_hello)
1021 #define KDBUS_CMD_BYEBYE _IO(KDBUS_IOCTL_MAGIC, 0x21) \
1023 #define KDBUS_CMD_SEND _IOWR(KDBUS_IOCTL_MAGIC, 0x30, \
1025 #define KDBUS_CMD_RECV _IOWR(KDBUS_IOCTL_MAGIC, 0x31, \
1026 struct kdbus_cmd_recv)
1027 #define KDBUS_CMD_CANCEL _IOW(KDBUS_IOCTL_MAGIC, 0x32, \
1028 struct kdbus_cmd_cancel)
1029 #define KDBUS_CMD_FREE _IOW(KDBUS_IOCTL_MAGIC, 0x33, \
1030 struct kdbus_cmd_free)
1032 #define KDBUS_CMD_NAME_ACQUIRE _IOWR(KDBUS_IOCTL_MAGIC, 0x40, \
1033 struct kdbus_cmd_name)
1034 #define KDBUS_CMD_NAME_RELEASE _IOW(KDBUS_IOCTL_MAGIC, 0x41, \
1035 struct kdbus_cmd_name)
1036 #define KDBUS_CMD_NAME_LIST _IOWR(KDBUS_IOCTL_MAGIC, 0x42, \
1037 struct kdbus_cmd_name_list)
1039 #define KDBUS_CMD_CONN_INFO _IOWR(KDBUS_IOCTL_MAGIC, 0x50, \
1040 struct kdbus_cmd_info)
1041 #define KDBUS_CMD_CONN_UPDATE _IOW(KDBUS_IOCTL_MAGIC, 0x51, \
1042 struct kdbus_cmd_update)
1043 #define KDBUS_CMD_BUS_CREATOR_INFO _IOWR(KDBUS_IOCTL_MAGIC, 0x52, \
1044 struct kdbus_cmd_info)
1046 #define KDBUS_CMD_ENDPOINT_UPDATE _IOW(KDBUS_IOCTL_MAGIC, 0x61, \
1047 struct kdbus_cmd_update)
1049 #define KDBUS_CMD_MATCH_ADD _IOW(KDBUS_IOCTL_MAGIC, 0x70, \
1050 struct kdbus_cmd_match)
1051 #define KDBUS_CMD_MATCH_REMOVE _IOW(KDBUS_IOCTL_MAGIC, 0x71, \
1052 struct kdbus_cmd_match)
1054 #endif /* _KDBUS_UAPI_H_ */