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_CANCEL_FD: FD used to cancel a synchronous
233 * operation by writing to it from
235 * @KDBUS_ITEM_BLOOM_PARAMETER: Bus-wide bloom parameters, used with
236 * KDBUS_CMD_BUS_MAKE, carries a
237 * struct kdbus_bloom_parameter
238 * @KDBUS_ITEM_BLOOM_FILTER: Bloom filter carried with a message,
239 * used to match against a bloom mask of a
240 * connection, carries a struct
242 * @KDBUS_ITEM_BLOOM_MASK: Bloom mask used to match against a
243 * message'sbloom filter
244 * @KDBUS_ITEM_DST_NAME: Destination's well-known name
245 * @KDBUS_ITEM_MAKE_NAME: Name of domain, bus, endpoint
246 * @KDBUS_ITEM_ATTACH_FLAGS_SEND: Attach-flags, used for updating which
247 * metadata a connection opts in to send
248 * @KDBUS_ITEM_ATTACH_FLAGS_RECV: Attach-flags, used for updating which
249 * metadata a connection requests to
250 * receive for each reeceived message
251 * @KDBUS_ITEM_ID: Connection ID
252 * @KDBUS_ITEM_NAME: Well-know name with flags
253 * @_KDBUS_ITEM_ATTACH_BASE: Start of metadata attach items
254 * @KDBUS_ITEM_TIMESTAMP: Timestamp
255 * @KDBUS_ITEM_CREDS: Process credentials
256 * @KDBUS_ITEM_PIDS: Process identifiers
257 * @KDBUS_ITEM_AUXGROUPS: Auxiliary process groups
258 * @KDBUS_ITEM_OWNED_NAME: A name owned by the associated
260 * @KDBUS_ITEM_TID_COMM: Thread ID "comm" identifier
261 * (Don't trust this, see below.)
262 * @KDBUS_ITEM_PID_COMM: Process ID "comm" identifier
263 * (Don't trust this, see below.)
264 * @KDBUS_ITEM_EXE: The path of the executable
265 * (Don't trust this, see below.)
266 * @KDBUS_ITEM_CMDLINE: The process command line
267 * (Don't trust this, see below.)
268 * @KDBUS_ITEM_CGROUP: The croup membership
269 * @KDBUS_ITEM_CAPS: The process capabilities
270 * @KDBUS_ITEM_SECLABEL: The security label
271 * @KDBUS_ITEM_AUDIT: The audit IDs
272 * @KDBUS_ITEM_CONN_DESCRIPTION: The connection's human-readable name
274 * @_KDBUS_ITEM_POLICY_BASE: Start of policy items
275 * @KDBUS_ITEM_POLICY_ACCESS: Policy access block
276 * @_KDBUS_ITEM_KERNEL_BASE: Start of kernel-generated message items
277 * @KDBUS_ITEM_NAME_ADD: Notification in kdbus_notify_name_change
278 * @KDBUS_ITEM_NAME_REMOVE: Notification in kdbus_notify_name_change
279 * @KDBUS_ITEM_NAME_CHANGE: Notification in kdbus_notify_name_change
280 * @KDBUS_ITEM_ID_ADD: Notification in kdbus_notify_id_change
281 * @KDBUS_ITEM_ID_REMOVE: Notification in kdbus_notify_id_change
282 * @KDBUS_ITEM_REPLY_TIMEOUT: Timeout has been reached
283 * @KDBUS_ITEM_REPLY_DEAD: Destination died
285 * N.B: The process and thread COMM fields, as well as the CMDLINE and
286 * EXE fields may be altered by unprivileged processes und should
287 * hence *not* used for security decisions. Peers should make use of
288 * these items only for informational purposes, such as generating log
291 enum kdbus_item_type {
293 _KDBUS_ITEM_USER_BASE,
294 KDBUS_ITEM_PAYLOAD_VEC = _KDBUS_ITEM_USER_BASE,
295 KDBUS_ITEM_PAYLOAD_OFF,
296 KDBUS_ITEM_PAYLOAD_MEMFD,
298 KDBUS_ITEM_CANCEL_FD,
299 KDBUS_ITEM_BLOOM_PARAMETER,
300 KDBUS_ITEM_BLOOM_FILTER,
301 KDBUS_ITEM_BLOOM_MASK,
303 KDBUS_ITEM_MAKE_NAME,
304 KDBUS_ITEM_ATTACH_FLAGS_SEND,
305 KDBUS_ITEM_ATTACH_FLAGS_RECV,
310 /* keep these item types in sync with KDBUS_ATTACH_* flags */
311 _KDBUS_ITEM_ATTACH_BASE = 0x1000,
312 KDBUS_ITEM_TIMESTAMP = _KDBUS_ITEM_ATTACH_BASE,
315 KDBUS_ITEM_AUXGROUPS,
316 KDBUS_ITEM_OWNED_NAME,
325 KDBUS_ITEM_CONN_DESCRIPTION,
327 _KDBUS_ITEM_POLICY_BASE = 0x2000,
328 KDBUS_ITEM_POLICY_ACCESS = _KDBUS_ITEM_POLICY_BASE,
330 _KDBUS_ITEM_KERNEL_BASE = 0x8000,
331 KDBUS_ITEM_NAME_ADD = _KDBUS_ITEM_KERNEL_BASE,
332 KDBUS_ITEM_NAME_REMOVE,
333 KDBUS_ITEM_NAME_CHANGE,
335 KDBUS_ITEM_ID_REMOVE,
336 KDBUS_ITEM_REPLY_TIMEOUT,
337 KDBUS_ITEM_REPLY_DEAD,
341 * struct kdbus_item - chain of data blocks
342 * @size: Overall data record size
343 * @type: Kdbus_item type of data
344 * @data: Generic bytes
345 * @data32: Generic 32 bit array
346 * @data64: Generic 64 bit array
347 * @str: Generic string
349 * @vec: KDBUS_ITEM_PAYLOAD_VEC
350 * @creds: KDBUS_ITEM_CREDS
351 * @audit: KDBUS_ITEM_AUDIT
352 * @timestamp: KDBUS_ITEM_TIMESTAMP
353 * @name: KDBUS_ITEM_NAME
354 * @bloom_parameter: KDBUS_ITEM_BLOOM_PARAMETER
355 * @bloom_filter: KDBUS_ITEM_BLOOM_FILTER
356 * @memfd: KDBUS_ITEM_PAYLOAD_MEMFD
357 * @name_change: KDBUS_ITEM_NAME_ADD
358 * KDBUS_ITEM_NAME_REMOVE
359 * KDBUS_ITEM_NAME_CHANGE
360 * @id_change: KDBUS_ITEM_ID_ADD
361 * KDBUS_ITEM_ID_REMOVE
362 * @policy: KDBUS_ITEM_POLICY_ACCESS
374 struct kdbus_vec vec;
375 struct kdbus_creds creds;
376 struct kdbus_pids pids;
377 struct kdbus_audit audit;
378 struct kdbus_caps caps;
379 struct kdbus_timestamp timestamp;
380 struct kdbus_name name;
381 struct kdbus_bloom_parameter bloom_parameter;
382 struct kdbus_bloom_filter bloom_filter;
383 struct kdbus_memfd memfd;
385 struct kdbus_notify_name_change name_change;
386 struct kdbus_notify_id_change id_change;
387 struct kdbus_policy_access policy_access;
393 * struct kdbus_item_list - A list of items
394 * @size: The total size of the structure
395 * @items: Array of items
397 struct kdbus_item_list {
399 struct kdbus_item items[0];
403 * enum kdbus_msg_flags - type of message
404 * @KDBUS_MSG_EXPECT_REPLY: Expect a reply message, used for
405 * method calls. The userspace-supplied
406 * cookie identifies the message and the
407 * respective reply carries the cookie
409 * @KDBUS_MSG_NO_AUTO_START: Do not start a service, if the addressed
410 * name is not currently active
412 enum kdbus_msg_flags {
413 KDBUS_MSG_EXPECT_REPLY = 1ULL << 0,
414 KDBUS_MSG_NO_AUTO_START = 1ULL << 1,
418 * enum kdbus_payload_type - type of payload carried by message
419 * @KDBUS_PAYLOAD_KERNEL: Kernel-generated simple message
420 * @KDBUS_PAYLOAD_DBUS: D-Bus marshalling "DBusDBus"
422 * Any payload-type is accepted. Common types will get added here once
425 enum kdbus_payload_type {
426 KDBUS_PAYLOAD_KERNEL,
427 KDBUS_PAYLOAD_DBUS = 0x4442757344427573ULL,
431 * struct kdbus_msg - the representation of a kdbus message
432 * @size: Total size of the message
433 * @flags: Message flags (KDBUS_MSG_*), userspace → kernel
434 * @priority: Message queue priority value
435 * @dst_id: 64-bit ID of the destination connection
436 * @src_id: 64-bit ID of the source connection
437 * @payload_type: Payload type (KDBUS_PAYLOAD_*)
438 * @cookie: Userspace-supplied cookie, for the connection
439 * to identify its messages
440 * @timeout_ns: The time to wait for a message reply from the peer.
441 * If there is no reply, a kernel-generated message
442 * with an attached KDBUS_ITEM_REPLY_TIMEOUT item
443 * is sent to @src_id. The timeout is expected in
444 * nanoseconds and as absolute CLOCK_MONOTONIC value.
445 * @cookie_reply: A reply to the requesting message with the same
446 * cookie. The requesting connection can match its
447 * request and the reply with this value
448 * @items: A list of kdbus_items containing the message payload
462 struct kdbus_item items[0];
463 } __attribute__((aligned(8)));
466 * struct kdbus_reply - reply container
467 * @offset: Offset of kdbus_msg slice in pool
468 * @msg_size: Copy of the kdbus_msg.size field
469 * @return_flags: Command return flags, kernel → userspace
478 * enum kdbus_send_flags - flags for sending messages
479 * @KDBUS_SEND_SYNC_REPLY: Wait for destination connection to
480 * reply to this message. The
481 * KDBUS_CMD_SEND ioctl() will block
482 * until the reply is received, and
483 * offset_reply in struct kdbus_msg will
484 * yield the offset in the sender's pool
485 * where the reply can be found.
486 * This flag is only valid if
487 * @KDBUS_MSG_EXPECT_REPLY is set as well.
489 enum kdbus_send_flags {
490 KDBUS_SEND_SYNC_REPLY = 1ULL << 0,
494 * struct kdbus_cmd_send - send message
495 * @size: Overall size of this structure
496 * @flags: Flags to change send behavior (KDBUS_SEND_*)
497 * @kernel_flags: Supported send flags, kernel → userspace
498 * @kernel_msg_flags: Supported message flags, kernel → userspace
499 * @return_flags: Command return flags, kernel → userspace
500 * @msg_address: Storage address of the kdbus_msg to send
501 * @reply: Storage for message reply if KDBUS_SEND_SYNC_REPLY
503 * @items: Additional items for this command
505 struct kdbus_cmd_send {
509 __u64 kernel_msg_flags;
512 struct kdbus_reply reply;
513 struct kdbus_item items[0];
514 } __attribute__((aligned(8)));
517 * enum kdbus_recv_flags - flags for de-queuing messages
518 * @KDBUS_RECV_PEEK: Return the next queued message without
519 * actually de-queuing it, and without installing
520 * any file descriptors or other resources. It is
521 * usually used to determine the activating
522 * connection of a bus name.
523 * @KDBUS_RECV_DROP: Drop and free the next queued message and all
524 * its resources without actually receiving it.
525 * @KDBUS_RECV_USE_PRIORITY: Only de-queue messages with the specified or
526 * higher priority (lowest values); if not set,
527 * the priority value is ignored.
529 enum kdbus_recv_flags {
530 KDBUS_RECV_PEEK = 1ULL << 0,
531 KDBUS_RECV_DROP = 1ULL << 1,
532 KDBUS_RECV_USE_PRIORITY = 1ULL << 2,
536 * enum kdbus_recv_return_flags - return flags for message receive commands
537 * @KDBUS_RECV_RETURN_INCOMPLETE_FDS: One or more file descriptors could not
538 * be installed. These descriptors in
539 * KDBUS_ITEM_FDS will carry the value -1.
541 enum kdbus_recv_return_flags {
542 KDBUS_RECV_RETURN_INCOMPLETE_FDS = 1ULL << 0,
546 * struct kdbus_cmd_recv - struct to de-queue a buffered message
547 * @size: Overall size of this object
548 * @flags: KDBUS_RECV_* flags, userspace → kernel
549 * @kernel_flags: Supported KDBUS_RECV_* flags, kernel → userspace
550 * @return_flags: Command return flags, kernel → userspace
551 * @priority: Minimum priority of the messages to de-queue. Lowest
552 * values have the highest priority.
553 * @dropped_msgs: In case the KDBUS_CMD_RECV ioctl returns
554 * -EOVERFLOW, this field will contain the number of
555 * broadcast messages that have been lost since the
557 * @reply: Return storage for received message.
558 * @items: Additional items for this command.
560 * This struct is used with the KDBUS_CMD_RECV ioctl.
562 struct kdbus_cmd_recv {
569 struct kdbus_reply reply;
570 struct kdbus_item items[0];
571 } __attribute__((aligned(8)));
574 * struct kdbus_cmd_free - struct to free a slice of memory in the pool
575 * @size: Overall size of this structure
576 * @offset: The offset of the memory slice, as returned by other
578 * @flags: Flags for the free command, userspace → kernel
579 * @return_flags: Command return flags, kernel → userspace
580 * @kernel_flags: Supported flags of the free command, userspace → kernel
581 * @items: Additional items to modify the behavior
583 * This struct is used with the KDBUS_CMD_FREE ioctl.
585 struct kdbus_cmd_free {
591 struct kdbus_item items[0];
592 } __attribute__((aligned(8)));
595 * enum kdbus_policy_access_type - permissions of a policy record
596 * @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid
597 * @KDBUS_POLICY_ACCESS_USER: Grant access to a uid
598 * @KDBUS_POLICY_ACCESS_GROUP: Grant access to gid
599 * @KDBUS_POLICY_ACCESS_WORLD: World-accessible
601 enum kdbus_policy_access_type {
602 _KDBUS_POLICY_ACCESS_NULL,
603 KDBUS_POLICY_ACCESS_USER,
604 KDBUS_POLICY_ACCESS_GROUP,
605 KDBUS_POLICY_ACCESS_WORLD,
609 * enum kdbus_policy_access_flags - mode flags
610 * @KDBUS_POLICY_OWN: Allow to own a well-known name
611 * Implies KDBUS_POLICY_TALK and KDBUS_POLICY_SEE
612 * @KDBUS_POLICY_TALK: Allow communication to a well-known name
613 * Implies KDBUS_POLICY_SEE
614 * @KDBUS_POLICY_SEE: Allow to see a well-known name
616 enum kdbus_policy_type {
617 KDBUS_POLICY_SEE = 0,
623 * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello
624 * @KDBUS_HELLO_ACCEPT_FD: The connection allows the reception of
625 * any passed file descriptors
626 * @KDBUS_HELLO_ACTIVATOR: Special-purpose connection which registers
627 * a well-know name for a process to be started
628 * when traffic arrives
629 * @KDBUS_HELLO_POLICY_HOLDER: Special-purpose connection which registers
630 * policy entries for a name. The provided name
631 * is not activated and not registered with the
632 * name database, it only allows unprivileged
633 * connections to acquire a name, talk or discover
635 * @KDBUS_HELLO_MONITOR: Special-purpose connection to monitor
637 * @KDBUS_HELLO_UNPRIVILEGED: Don't treat this connection as privileged once
638 * the bus connection was established.
640 enum kdbus_hello_flags {
641 KDBUS_HELLO_ACCEPT_FD = 1ULL << 0,
642 KDBUS_HELLO_ACTIVATOR = 1ULL << 1,
643 KDBUS_HELLO_POLICY_HOLDER = 1ULL << 2,
644 KDBUS_HELLO_MONITOR = 1ULL << 3,
645 KDBUS_HELLO_UNPRIVILEGED = 1ULL << 4,
649 * enum kdbus_attach_flags - flags for metadata attachments
650 * @KDBUS_ATTACH_TIMESTAMP: Timestamp
651 * @KDBUS_ATTACH_CREDS: Credentials
652 * @KDBUS_ATTACH_PIDS: PIDs
653 * @KDBUS_ATTACH_AUXGROUPS: Auxiliary groups
654 * @KDBUS_ATTACH_NAMES: Well-known names
655 * @KDBUS_ATTACH_TID_COMM: The "comm" process identifier of the TID
656 * @KDBUS_ATTACH_PID_COMM: The "comm" process identifier of the PID
657 * @KDBUS_ATTACH_EXE: The path of the executable
658 * @KDBUS_ATTACH_CMDLINE: The process command line
659 * @KDBUS_ATTACH_CGROUP: The croup membership
660 * @KDBUS_ATTACH_CAPS: The process capabilities
661 * @KDBUS_ATTACH_SECLABEL: The security label
662 * @KDBUS_ATTACH_AUDIT: The audit IDs
663 * @KDBUS_ATTACH_CONN_DESCRIPTION: The human-readable connection name
664 * @_KDBUS_ATTACH_ALL: All of the above
665 * @_KDBUS_ATTACH_ANY: Wildcard match to enable any kind of
668 enum kdbus_attach_flags {
669 KDBUS_ATTACH_TIMESTAMP = 1ULL << 0,
670 KDBUS_ATTACH_CREDS = 1ULL << 1,
671 KDBUS_ATTACH_PIDS = 1ULL << 2,
672 KDBUS_ATTACH_AUXGROUPS = 1ULL << 3,
673 KDBUS_ATTACH_NAMES = 1ULL << 4,
674 KDBUS_ATTACH_TID_COMM = 1ULL << 5,
675 KDBUS_ATTACH_PID_COMM = 1ULL << 6,
676 KDBUS_ATTACH_EXE = 1ULL << 7,
677 KDBUS_ATTACH_CMDLINE = 1ULL << 8,
678 KDBUS_ATTACH_CGROUP = 1ULL << 9,
679 KDBUS_ATTACH_CAPS = 1ULL << 10,
680 KDBUS_ATTACH_SECLABEL = 1ULL << 11,
681 KDBUS_ATTACH_AUDIT = 1ULL << 12,
682 KDBUS_ATTACH_CONN_DESCRIPTION = 1ULL << 13,
683 _KDBUS_ATTACH_ALL = (1ULL << 14) - 1,
684 _KDBUS_ATTACH_ANY = ~0ULL
688 * struct kdbus_cmd_hello - struct to say hello to kdbus
689 * @size: The total size of the structure
690 * @flags: Connection flags (KDBUS_HELLO_*), userspace → kernel
691 * @kernel_flags: Supported connection flags, kernel → userspace
692 * @return_flags: Command return flags, kernel → userspace
693 * @attach_flags_send: Mask of metadata to attach to each message sent
694 * off by this connection (KDBUS_ATTACH_*)
695 * @attach_flags_recv: Mask of metadata to attach to each message receieved
696 * by the new connection (KDBUS_ATTACH_*)
697 * @bus_flags: The flags field copied verbatim from the original
698 * KDBUS_CMD_BUS_MAKE ioctl. It's intended to be useful
699 * to do negotiation of features of the payload that is
700 * transferred (kernel → userspace)
701 * @id: The ID of this connection (kernel → userspace)
702 * @pool_size: Size of the connection's buffer where the received
703 * messages are placed
704 * @offset: Pool offset where additional items of type
705 * kdbus_item_list are stored. They contain information
706 * about the bus and the newly created connection.
707 * @items_size: Copy of item_list.size stored in @offset.
708 * @id128: Unique 128-bit ID of the bus (kernel → userspace)
709 * @items: A list of items
711 * This struct is used with the KDBUS_CMD_HELLO ioctl.
713 struct kdbus_cmd_hello {
718 __u64 attach_flags_send;
719 __u64 attach_flags_recv;
726 struct kdbus_item items[0];
727 } __attribute__((aligned(8)));
730 * enum kdbus_make_flags - Flags for KDBUS_CMD_{BUS,EP,NS}_MAKE
731 * @KDBUS_MAKE_ACCESS_GROUP: Make the bus or endpoint node group-accessible
732 * @KDBUS_MAKE_ACCESS_WORLD: Make the bus or endpoint node world-accessible
734 enum kdbus_make_flags {
735 KDBUS_MAKE_ACCESS_GROUP = 1ULL << 0,
736 KDBUS_MAKE_ACCESS_WORLD = 1ULL << 1,
740 * struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain
741 * @size: The total size of the struct
742 * @flags: Properties for the bus/ep/domain to create,
744 * @kernel_flags: Supported flags for the used command, kernel → userspace
745 * @return_flags: Command return flags, kernel → userspace
746 * @items: Items describing details
748 * This structure is used with the KDBUS_CMD_BUS_MAKE and
749 * KDBUS_CMD_ENDPOINT_MAKE ioctls.
751 struct kdbus_cmd_make {
756 struct kdbus_item items[0];
757 } __attribute__((aligned(8)));
760 * enum kdbus_name_flags - properties of a well-known name
761 * @KDBUS_NAME_REPLACE_EXISTING: Try to replace name of other connections
762 * @KDBUS_NAME_ALLOW_REPLACEMENT: Allow the replacement of the name
763 * @KDBUS_NAME_QUEUE: Name should be queued if busy
764 * @KDBUS_NAME_IN_QUEUE: Name is queued
765 * @KDBUS_NAME_ACTIVATOR: Name is owned by a activator connection
767 enum kdbus_name_flags {
768 KDBUS_NAME_REPLACE_EXISTING = 1ULL << 0,
769 KDBUS_NAME_ALLOW_REPLACEMENT = 1ULL << 1,
770 KDBUS_NAME_QUEUE = 1ULL << 2,
771 KDBUS_NAME_IN_QUEUE = 1ULL << 3,
772 KDBUS_NAME_ACTIVATOR = 1ULL << 4,
776 * struct kdbus_cmd_name - struct to describe a well-known name
777 * @size: The total size of the struct
778 * @flags: Flags for a name entry (KDBUS_NAME_*),
779 * userspace → kernel, kernel → userspace
780 * @kernel_flags: Supported flags for a name entry, kernel → userspace
781 * @return_flags: Command return flags, kernel → userspace
782 * @items: Item list, containing the well-known name as
785 * This structure is used with the KDBUS_CMD_NAME_ACQUIRE ioctl.
787 struct kdbus_cmd_name {
792 struct kdbus_item items[0];
793 } __attribute__((aligned(8)));
796 * struct kdbus_name_info - struct to describe a well-known name
797 * @size: The total size of the struct
798 * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*)
799 * @owner_id: The current owner of the name
800 * @items: Item list, containing the well-known name as
801 * KDBUS_ITEM_OWNED_NAME
803 * This structure is used as return struct for the KDBUS_CMD_NAME_LIST ioctl.
805 struct kdbus_name_info {
809 struct kdbus_item items[0];
810 } __attribute__((aligned(8)));
813 * struct kdbus_name_list - information returned by KDBUS_CMD_NAME_LIST
814 * @size: The total size of the structure
815 * @names: A list of names
817 * Note that the user is responsible for freeing the allocated memory with
818 * the KDBUS_CMD_FREE ioctl.
820 struct kdbus_name_list {
822 struct kdbus_name_info names[0];
826 * enum kdbus_name_list_flags - what to include into the returned list
827 * @KDBUS_NAME_LIST_UNIQUE: All active connections
828 * @KDBUS_NAME_LIST_NAMES: All known well-known names
829 * @KDBUS_NAME_LIST_ACTIVATORS: All activator connections
830 * @KDBUS_NAME_LIST_QUEUED: All queued-up names
832 enum kdbus_name_list_flags {
833 KDBUS_NAME_LIST_UNIQUE = 1ULL << 0,
834 KDBUS_NAME_LIST_NAMES = 1ULL << 1,
835 KDBUS_NAME_LIST_ACTIVATORS = 1ULL << 2,
836 KDBUS_NAME_LIST_QUEUED = 1ULL << 3,
840 * struct kdbus_cmd_name_list - request a list of name entries
841 * @flags: Flags for the query (KDBUS_NAME_LIST_*),
843 * @kernel_flags: Supported flags for queries, kernel → userspace
844 * @return_flags: Command return flags, kernel → userspace
845 * @offset: The returned offset in the caller's pool buffer.
846 * The user must use KDBUS_CMD_FREE to free the
848 * @list_size: Returned size of list in bytes
849 * @size: Output buffer to report size of data at @offset.
850 * @items: Items for the command. Reserved for future use.
852 * This structure is used with the KDBUS_CMD_NAME_LIST ioctl.
854 struct kdbus_cmd_name_list {
861 struct kdbus_item items[0];
862 } __attribute__((aligned(8)));
865 * struct kdbus_info - information returned by KDBUS_CMD_*_INFO
866 * @size: The total size of the struct
867 * @id: The connection's or bus' 64-bit ID
868 * @flags: The connection's or bus' flags
869 * @items: A list of struct kdbus_item
871 * Note that the user is responsible for freeing the allocated memory with
872 * the KDBUS_CMD_FREE ioctl.
878 struct kdbus_item items[0];
882 * struct kdbus_cmd_info - struct used for KDBUS_CMD_CONN_INFO ioctl
883 * @size: The total size of the struct
884 * @flags: KDBUS_ATTACH_* flags, userspace → kernel
885 * @kernel_flags: Supported KDBUS_ATTACH_* flags, kernel → userspace
886 * @return_flags: Command return flags, kernel → userspace
887 * @id: The 64-bit ID of the connection. If set to zero, passing
888 * @name is required. kdbus will look up the name to
889 * determine the ID in this case.
890 * @offset: Returned offset in the caller's pool buffer where the
891 * kdbus_info struct result is stored. The user must
892 * use KDBUS_CMD_FREE to free the allocated memory.
893 * @info_size: Output buffer to report size of data at @offset.
894 * @items: The optional item list, containing the
895 * well-known name to look up as a KDBUS_ITEM_NAME.
896 * Only needed in case @id is zero.
898 * On success, the KDBUS_CMD_CONN_INFO ioctl will return 0 and @offset will
899 * tell the user the offset in the connection pool buffer at which to find the
900 * result in a struct kdbus_info.
902 struct kdbus_cmd_info {
910 struct kdbus_item items[0];
911 } __attribute__((aligned(8)));
914 * struct kdbus_cmd_update - update flags of a connection
915 * @size: The total size of the struct
916 * @flags: Flags for the update command, userspace → kernel
917 * @kernel_flags: Supported flags for this command, kernel → userspace
918 * @return_flags: Command return flags, kernel → userspace
919 * @items: A list of struct kdbus_item
921 * This struct is used with the KDBUS_CMD_CONN_UPDATE ioctl.
923 struct kdbus_cmd_update {
928 struct kdbus_item items[0];
929 } __attribute__((aligned(8)));
932 * enum kdbus_cmd_match_flags - flags to control the KDBUS_CMD_MATCH_ADD ioctl
933 * @KDBUS_MATCH_REPLACE: If entries with the supplied cookie already
934 * exists, remove them before installing the new
937 enum kdbus_cmd_match_flags {
938 KDBUS_MATCH_REPLACE = 1ULL << 0,
942 * struct kdbus_cmd_match - struct to add or remove matches
943 * @size: The total size of the struct
944 * @cookie: Userspace supplied cookie. When removing, the cookie
945 * identifies the match to remove
946 * @flags: Flags for match command (KDBUS_MATCH_*),
948 * @kernel_flags: Supported flags of the used command, kernel → userspace
949 * @return_flags: Command return flags, kernel → userspace
950 * @items: A list of items for additional information
952 * This structure is used with the KDBUS_CMD_MATCH_ADD and
953 * KDBUS_CMD_MATCH_REMOVE ioctl.
955 struct kdbus_cmd_match {
961 struct kdbus_item items[0];
962 } __attribute__((aligned(8)));
966 * KDBUS_CMD_BUS_MAKE: After opening the "control" node, this command
967 * creates a new bus with the specified
968 * name. The bus is immediately shut down and
969 * cleaned up when the opened file descriptor is
971 * KDBUS_CMD_ENDPOINT_MAKE: Creates a new named special endpoint to talk to
972 * the bus. Such endpoints usually carry a more
973 * restrictive policy and grant restricted access
974 * to specific applications.
975 * KDBUS_CMD_HELLO: By opening the bus node, a connection is
976 * created. After a HELLO the opened connection
977 * becomes an active peer on the bus.
978 * KDBUS_CMD_BYEBYE: Disconnect a connection. If there are no
979 * messages queued up in the connection's pool,
980 * the call succeeds, and the handle is rendered
981 * unusable. Otherwise, -EBUSY is returned without
982 * any further side-effects.
983 * KDBUS_CMD_SEND: Send a message and pass data from userspace to
985 * KDBUS_CMD_RECV: Receive a message from the kernel which is
986 * placed in the receiver's pool.
987 * KDBUS_CMD_FREE: Release the allocated memory in the receiver's
989 * KDBUS_CMD_NAME_ACQUIRE: Request a well-known bus name to associate with
990 * the connection. Well-known names are used to
991 * address a peer on the bus.
992 * KDBUS_CMD_NAME_RELEASE: Release a well-known name the connection
994 * KDBUS_CMD_NAME_LIST: Retrieve the list of all currently registered
995 * well-known and unique names.
996 * KDBUS_CMD_CONN_INFO: Retrieve credentials and properties of the
997 * initial creator of the connection. The data was
998 * stored at registration time and does not
999 * necessarily represent the connected process or
1000 * the actual state of the process.
1001 * KDBUS_CMD_CONN_UPDATE: Update the properties of a connection. Used to
1002 * update the metadata subscription mask and
1004 * KDBUS_CMD_BUS_CREATOR_INFO: Retrieve information of the creator of the bus
1005 * a connection is attached to.
1006 * KDBUS_CMD_ENDPOINT_UPDATE: Update the properties of a custom enpoint. Used
1007 * to update the policy.
1008 * KDBUS_CMD_MATCH_ADD: Install a match which broadcast messages should
1009 * be delivered to the connection.
1010 * KDBUS_CMD_MATCH_REMOVE: Remove a current match for broadcast messages.
1012 #define KDBUS_CMD_BUS_MAKE _IOW(KDBUS_IOCTL_MAGIC, 0x00, \
1013 struct kdbus_cmd_make)
1014 #define KDBUS_CMD_ENDPOINT_MAKE _IOW(KDBUS_IOCTL_MAGIC, 0x10, \
1015 struct kdbus_cmd_make)
1017 #define KDBUS_CMD_HELLO _IOWR(KDBUS_IOCTL_MAGIC, 0x20, \
1018 struct kdbus_cmd_hello)
1019 #define KDBUS_CMD_BYEBYE _IO(KDBUS_IOCTL_MAGIC, 0x21) \
1021 #define KDBUS_CMD_SEND _IOWR(KDBUS_IOCTL_MAGIC, 0x30, \
1022 struct kdbus_cmd_send)
1023 #define KDBUS_CMD_RECV _IOWR(KDBUS_IOCTL_MAGIC, 0x31, \
1024 struct kdbus_cmd_recv)
1025 #define KDBUS_CMD_FREE _IOW(KDBUS_IOCTL_MAGIC, 0x33, \
1026 struct kdbus_cmd_free)
1028 #define KDBUS_CMD_NAME_ACQUIRE _IOWR(KDBUS_IOCTL_MAGIC, 0x40, \
1029 struct kdbus_cmd_name)
1030 #define KDBUS_CMD_NAME_RELEASE _IOW(KDBUS_IOCTL_MAGIC, 0x41, \
1031 struct kdbus_cmd_name)
1032 #define KDBUS_CMD_NAME_LIST _IOWR(KDBUS_IOCTL_MAGIC, 0x42, \
1033 struct kdbus_cmd_name_list)
1035 #define KDBUS_CMD_CONN_INFO _IOWR(KDBUS_IOCTL_MAGIC, 0x50, \
1036 struct kdbus_cmd_info)
1037 #define KDBUS_CMD_CONN_UPDATE _IOW(KDBUS_IOCTL_MAGIC, 0x51, \
1038 struct kdbus_cmd_update)
1039 #define KDBUS_CMD_BUS_CREATOR_INFO _IOWR(KDBUS_IOCTL_MAGIC, 0x52, \
1040 struct kdbus_cmd_info)
1042 #define KDBUS_CMD_ENDPOINT_UPDATE _IOW(KDBUS_IOCTL_MAGIC, 0x61, \
1043 struct kdbus_cmd_update)
1045 #define KDBUS_CMD_MATCH_ADD _IOW(KDBUS_IOCTL_MAGIC, 0x70, \
1046 struct kdbus_cmd_match)
1047 #define KDBUS_CMD_MATCH_REMOVE _IOW(KDBUS_IOCTL_MAGIC, 0x71, \
1048 struct kdbus_cmd_match)
1050 #endif /* _KDBUS_UAPI_H_ */