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
64 * @starttime: Starttime of the process
66 * The starttime of the process PID. This is useful to detect PID overruns
67 * from the client side. i.e. if you use the PID to look something up in
68 * /proc/$PID/ you can afterwards check the starttime field of it, to ensure
69 * you didn't run into a PID overrun.
83 * struct kdbus_caps - process capabilities
84 * @last_cap: Highest currently known capability bit
85 * @caps: Variable number of 32-bit capabilities flags
87 * Contains a variable number of 32-bit capabilities flags.
98 * struct kdbus_audit - audit information
99 * @sessionid: The audit session ID
100 * @loginuid: The audit login uid
111 * struct kdbus_timestamp
112 * @seqnum: Global per-domain message sequence number
113 * @monotonic_ns: Monotonic timestamp, in nanoseconds
114 * @realtime_ns: Realtime timestamp, in nanoseconds
117 * KDBUS_ITEM_TIMESTAMP
119 struct kdbus_timestamp {
126 * struct kdbus_vec - I/O vector for kdbus payload items
127 * @size: The size of the vector
128 * @address: Memory address of data buffer
129 * @offset: Offset in the in-message payload memory,
130 * relative to the message head
133 * KDBUS_ITEM_PAYLOAD_VEC, KDBUS_ITEM_PAYLOAD_OFF
144 * struct kdbus_bloom_parameter - bus-wide bloom parameters
145 * @size: Size of the bit field in bytes (m / 8)
146 * @n_hash: Number of hash functions used (k)
148 struct kdbus_bloom_parameter {
154 * struct kdbus_bloom_filter - bloom filter containing n elements
155 * @generation: Generation of the element set in the filter
156 * @data: Bit field, multiple of 8 bytes
158 struct kdbus_bloom_filter {
164 * struct kdbus_memfd - a kdbus memfd
165 * @size: The memfd's size
166 * @fd: The file descriptor number
167 * @__pad: Padding to ensure proper alignment and size
170 * KDBUS_ITEM_PAYLOAD_MEMFD
179 * struct kdbus_name - a registered well-known name with its flags
180 * @flags: Flags from KDBUS_NAME_*
181 * @name: Well-known name
184 * KDBUS_ITEM_OWNED_NAME
192 * struct kdbus_policy_access - policy access item
193 * @type: One of KDBUS_POLICY_ACCESS_* types
194 * @access: Access to grant
195 * @id: For KDBUS_POLICY_ACCESS_USER, the uid
196 * For KDBUS_POLICY_ACCESS_GROUP, the gid
198 struct kdbus_policy_access {
199 __u64 type; /* USER, GROUP, WORLD */
200 __u64 access; /* OWN, TALK, SEE */
201 __u64 id; /* uid, gid, 0 */
205 * enum kdbus_item_type - item types to chain data in a list
206 * @_KDBUS_ITEM_NULL: Uninitialized/invalid
207 * @_KDBUS_ITEM_USER_BASE: Start of user items
208 * @KDBUS_ITEM_PAYLOAD_VEC: Vector to data
209 * @KDBUS_ITEM_PAYLOAD_OFF: Data at returned offset to message head
210 * @KDBUS_ITEM_PAYLOAD_MEMFD: Data as sealed memfd
211 * @KDBUS_ITEM_FDS: Attached file descriptors
212 * @KDBUS_ITEM_BLOOM_PARAMETER: Bus-wide bloom parameters, used with
213 * KDBUS_CMD_BUS_MAKE, carries a
214 * struct kdbus_bloom_parameter
215 * @KDBUS_ITEM_BLOOM_FILTER: Bloom filter carried with a message, used to
216 * match against a bloom mask of a connection,
217 * carries a struct kdbus_bloom_filter
218 * @KDBUS_ITEM_BLOOM_MASK: Bloom mask used to match against a message's
220 * @KDBUS_ITEM_DST_NAME: Destination's well-known name
221 * @KDBUS_ITEM_MAKE_NAME: Name of domain, bus, endpoint
222 * @KDBUS_ITEM_ATTACH_FLAGS: Attach-flags, used for updating which metadata
223 * a connection subscribes to
224 * @KDBUS_ITEM_ID: Connection ID
225 * @KDBUS_ITEM_NAME: Well-know name with flags
226 * @_KDBUS_ITEM_ATTACH_BASE: Start of metadata attach items
227 * @KDBUS_ITEM_TIMESTAMP: Timestamp
228 * @KDBUS_ITEM_CREDS: Process credential
229 * @KDBUS_ITEM_AUXGROUPS: Auxiliary process groups
230 * @KDBUS_ITEM_OWNED_NAME: A name owned by the associated connection
231 * @KDBUS_ITEM_TID_COMM: Thread ID "comm" identifier
232 * @KDBUS_ITEM_PID_COMM: Process ID "comm" identifier
233 * @KDBUS_ITEM_EXE: The path of the executable
234 * @KDBUS_ITEM_CMDLINE: The process command line
235 * @KDBUS_ITEM_CGROUP: The croup membership
236 * @KDBUS_ITEM_CAPS: The process capabilities
237 * @KDBUS_ITEM_SECLABEL: The security label
238 * @KDBUS_ITEM_AUDIT: The audit IDs
239 * @KDBUS_ITEM_CONN_DESCRIPTION:The connection's human-readable name (debugging)
240 * @_KDBUS_ITEM_POLICY_BASE: Start of policy items
241 * @KDBUS_ITEM_POLICY_ACCESS: Policy access block
242 * @_KDBUS_ITEM_KERNEL_BASE: Start of kernel-generated message items
243 * @KDBUS_ITEM_NAME_ADD: Notify in struct kdbus_notify_name_change
244 * @KDBUS_ITEM_NAME_REMOVE: Notify in struct kdbus_notify_name_change
245 * @KDBUS_ITEM_NAME_CHANGE: Notify in struct kdbus_notify_name_change
246 * @KDBUS_ITEM_ID_ADD: Notify in struct kdbus_notify_id_change
247 * @KDBUS_ITEM_ID_REMOVE: Notify in struct kdbus_notify_id_change
248 * @KDBUS_ITEM_REPLY_TIMEOUT: Timeout has been reached
249 * @KDBUS_ITEM_REPLY_DEAD: Destination died
251 enum kdbus_item_type {
253 _KDBUS_ITEM_USER_BASE,
254 KDBUS_ITEM_PAYLOAD_VEC = _KDBUS_ITEM_USER_BASE,
255 KDBUS_ITEM_PAYLOAD_OFF,
256 KDBUS_ITEM_PAYLOAD_MEMFD,
258 KDBUS_ITEM_BLOOM_PARAMETER,
259 KDBUS_ITEM_BLOOM_FILTER,
260 KDBUS_ITEM_BLOOM_MASK,
262 KDBUS_ITEM_MAKE_NAME,
263 KDBUS_ITEM_ATTACH_FLAGS,
267 /* keep these item types in sync with KDBUS_ATTACH_* flags */
268 _KDBUS_ITEM_ATTACH_BASE = 0x1000,
269 KDBUS_ITEM_TIMESTAMP = _KDBUS_ITEM_ATTACH_BASE,
271 KDBUS_ITEM_AUXGROUPS,
272 KDBUS_ITEM_OWNED_NAME,
281 KDBUS_ITEM_CONN_DESCRIPTION,
283 _KDBUS_ITEM_POLICY_BASE = 0x2000,
284 KDBUS_ITEM_POLICY_ACCESS = _KDBUS_ITEM_POLICY_BASE,
286 _KDBUS_ITEM_KERNEL_BASE = 0x8000,
287 KDBUS_ITEM_NAME_ADD = _KDBUS_ITEM_KERNEL_BASE,
288 KDBUS_ITEM_NAME_REMOVE,
289 KDBUS_ITEM_NAME_CHANGE,
291 KDBUS_ITEM_ID_REMOVE,
292 KDBUS_ITEM_REPLY_TIMEOUT,
293 KDBUS_ITEM_REPLY_DEAD,
297 * struct kdbus_item - chain of data blocks
298 * @size: Overall data record size
299 * @type: Kdbus_item type of data
300 * @data: Generic bytes
301 * @data32: Generic 32 bit array
302 * @data64: Generic 64 bit array
303 * @str: Generic string
305 * @vec: KDBUS_ITEM_PAYLOAD_VEC
306 * @creds: KDBUS_ITEM_CREDS
307 * @audit: KDBUS_ITEM_AUDIT
308 * @timestamp: KDBUS_ITEM_TIMESTAMP
309 * @name: KDBUS_ITEM_NAME
310 * @bloom_parameter: KDBUS_ITEM_BLOOM_PARAMETER
311 * @bloom_filter: KDBUS_ITEM_BLOOM_FILTER
312 * @memfd: KDBUS_ITEM_PAYLOAD_MEMFD
313 * @name_change: KDBUS_ITEM_NAME_ADD
314 * KDBUS_ITEM_NAME_REMOVE
315 * KDBUS_ITEM_NAME_CHANGE
316 * @id_change: KDBUS_ITEM_ID_ADD
317 * KDBUS_ITEM_ID_REMOVE
318 * @policy: KDBUS_ITEM_POLICY_ACCESS
330 struct kdbus_vec vec;
331 struct kdbus_creds creds;
332 struct kdbus_audit audit;
333 struct kdbus_caps caps;
334 struct kdbus_timestamp timestamp;
335 struct kdbus_name name;
336 struct kdbus_bloom_parameter bloom_parameter;
337 struct kdbus_bloom_filter bloom_filter;
338 struct kdbus_memfd memfd;
340 struct kdbus_notify_name_change name_change;
341 struct kdbus_notify_id_change id_change;
342 struct kdbus_policy_access policy_access;
347 * enum kdbus_msg_flags - type of message
348 * @KDBUS_MSG_FLAGS_EXPECT_REPLY: Expect a reply message, used for
349 * method calls. The userspace-supplied
350 * cookie identifies the message and the
351 * respective reply carries the cookie
353 * @KDBUS_MSG_FLAGS_SYNC_REPLY: Wait for destination connection to
354 * reply to this message. The
355 * KDBUS_CMD_MSG_SEND ioctl() will block
356 * until the reply is received, and
357 * offset_reply in struct kdbus_msg will
358 * yield the offset in the sender's pool
359 * where the reply can be found.
360 * This flag is only valid if
361 * @KDBUS_MSG_FLAGS_EXPECT_REPLY is set as
363 * @KDBUS_MSG_FLAGS_NO_AUTO_START: Do not start a service, if the addressed
364 * name is not currently active
366 enum kdbus_msg_flags {
367 KDBUS_MSG_FLAGS_EXPECT_REPLY = 1ULL << 0,
368 KDBUS_MSG_FLAGS_SYNC_REPLY = 1ULL << 1,
369 KDBUS_MSG_FLAGS_NO_AUTO_START = 1ULL << 2,
373 * enum kdbus_payload_type - type of payload carried by message
374 * @KDBUS_PAYLOAD_KERNEL: Kernel-generated simple message
375 * @KDBUS_PAYLOAD_DBUS: D-Bus marshalling "DBusDBus"
377 enum kdbus_payload_type {
378 KDBUS_PAYLOAD_KERNEL,
379 KDBUS_PAYLOAD_DBUS = 0x4442757344427573ULL,
383 * struct kdbus_msg - the representation of a kdbus message
384 * @size: Total size of the message
385 * @flags: Message flags (KDBUS_MSG_FLAGS_*), userspace → kernel
386 * @kernel_flags: Supported message flags, kernel → userspace
387 * @priority: Message queue priority value
388 * @dst_id: 64-bit ID of the destination connection
389 * @src_id: 64-bit ID of the source connection
390 * @payload_type: Payload type (KDBUS_PAYLOAD_*)
391 * @cookie: Userspace-supplied cookie, for the connection
392 * to identify its messages
393 * @timeout_ns: The time to wait for a message reply from the peer.
394 * If there is no reply, a kernel-generated message
395 * with an attached KDBUS_ITEM_REPLY_TIMEOUT item
396 * is sent to @src_id. The timeout is expected in
397 * nanoseconds and as absolute CLOCK_MONOTONIC value.
398 * @cookie_reply: A reply to the requesting message with the same
399 * cookie. The requesting connection can match its
400 * request and the reply with this value
401 * @offset_reply: If KDBUS_MSG_FLAGS_EXPECT_REPLY, this field will
402 * contain the offset in the sender's pool where the
404 * @items: A list of kdbus_items containing the message payload
420 struct kdbus_item items[0];
421 } __attribute__((aligned(8)));
424 * enum kdbus_recv_flags - flags for de-queuing messages
425 * @KDBUS_RECV_PEEK: Return the next queued message without
426 * actually de-queuing it, and without installing
427 * any file descriptors or other resources. It is
428 * usually used to determine the activating
429 * connection of a bus name.
430 * @KDBUS_RECV_DROP: Drop and free the next queued message and all
431 * its resources without actually receiving it.
432 * @KDBUS_RECV_USE_PRIORITY: Only de-queue messages with the specified or
433 * higher priority (lowest values); if not set,
434 * the priority value is ignored.
436 enum kdbus_recv_flags {
437 KDBUS_RECV_PEEK = 1ULL << 0,
438 KDBUS_RECV_DROP = 1ULL << 1,
439 KDBUS_RECV_USE_PRIORITY = 1ULL << 2,
443 * struct kdbus_cmd_recv - struct to de-queue a buffered message
444 * @flags: KDBUS_RECV_* flags, userspace → kernel
445 * @kernel_flags: Supported KDBUS_RECV_* flags, kernel → userspace
446 * @priority: Minimum priority of the messages to de-queue. Lowest
447 * values have the highest priority.
448 * @offset: Returned offset in the pool where the message is
449 * stored. The user must use KDBUS_CMD_FREE to free
450 * the allocated memory.
452 * This struct is used with the KDBUS_CMD_MSG_RECV ioctl.
454 struct kdbus_cmd_recv {
459 } __attribute__((aligned(8)));
462 * struct kdbus_cmd_cancel - struct to cancel a synchronously pending message
463 * @cookie: The cookie of the pending message
464 * @flags: Flags for the free command. Currently unused.
466 * This struct is used with the KDBUS_CMD_CANCEL ioctl.
468 struct kdbus_cmd_cancel {
471 } __attribute__((aligned(8)));
474 * struct kdbus_cmd_free - struct to free a slice of memory in the pool
475 * @offset: The offset of the memory slice, as returned by other
477 * @flags: Flags for the free command, userspace → kernel
478 * @kernel_flags: Supported flags of the free command, userspace → kernel
480 * This struct is used with the KDBUS_CMD_FREE ioctl.
482 struct kdbus_cmd_free {
486 } __attribute__((aligned(8)));
489 * enum kdbus_policy_access_type - permissions of a policy record
490 * @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid
491 * @KDBUS_POLICY_ACCESS_USER: Grant access to a uid
492 * @KDBUS_POLICY_ACCESS_GROUP: Grant access to gid
493 * @KDBUS_POLICY_ACCESS_WORLD: World-accessible
495 enum kdbus_policy_access_type {
496 _KDBUS_POLICY_ACCESS_NULL,
497 KDBUS_POLICY_ACCESS_USER,
498 KDBUS_POLICY_ACCESS_GROUP,
499 KDBUS_POLICY_ACCESS_WORLD,
503 * enum kdbus_policy_access_flags - mode flags
504 * @KDBUS_POLICY_OWN: Allow to own a well-known name
505 * Implies KDBUS_POLICY_TALK and KDBUS_POLICY_SEE
506 * @KDBUS_POLICY_TALK: Allow communication to a well-known name
507 * Implies KDBUS_POLICY_SEE
508 * @KDBUS_POLICY_SEE: Allow to see a well-known name
510 enum kdbus_policy_type {
511 KDBUS_POLICY_SEE = 0,
517 * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello
518 * @KDBUS_HELLO_ACCEPT_FD: The connection allows the reception of
519 * any passed file descriptors
520 * @KDBUS_HELLO_ACTIVATOR: Special-purpose connection which registers
521 * a well-know name for a process to be started
522 * when traffic arrives
523 * @KDBUS_HELLO_POLICY_HOLDER: Special-purpose connection which registers
524 * policy entries for a name. The provided name
525 * is not activated and not registered with the
526 * name database, it only allows unprivileged
527 * connections to aquire a name, talk or discover
529 * @KDBUS_HELLO_MONITOR: Special-purpose connection to monitor
532 enum kdbus_hello_flags {
533 KDBUS_HELLO_ACCEPT_FD = 1ULL << 0,
534 KDBUS_HELLO_ACTIVATOR = 1ULL << 1,
535 KDBUS_HELLO_POLICY_HOLDER = 1ULL << 2,
536 KDBUS_HELLO_MONITOR = 1ULL << 3,
540 * enum kdbus_attach_flags - flags for metadata attachments
541 * @KDBUS_ATTACH_TIMESTAMP: Timestamp
542 * @KDBUS_ATTACH_CREDS: Credentials
543 * @KDBUS_ATTACH_AUXGROUPS: Auxiliary groups
544 * @KDBUS_ATTACH_NAMES: Well-known names
545 * @KDBUS_ATTACH_TID_COMM: The "comm" process identifier of the TID
546 * @KDBUS_ATTACH_PID_COMM: The "comm" process identifier of the PID
547 * @KDBUS_ATTACH_EXE: The path of the executable
548 * @KDBUS_ATTACH_CMDLINE: The process command line
549 * @KDBUS_ATTACH_CGROUP: The croup membership
550 * @KDBUS_ATTACH_CAPS: The process capabilities
551 * @KDBUS_ATTACH_SECLABEL: The security label
552 * @KDBUS_ATTACH_AUDIT: The audit IDs
553 * @KDBUS_ATTACH_CONN_DESCRIPTION: The human-readable connection name
554 * @_KDBUS_ATTACH_ALL: All of the above
556 enum kdbus_attach_flags {
557 KDBUS_ATTACH_TIMESTAMP = 1ULL << 0,
558 KDBUS_ATTACH_CREDS = 1ULL << 1,
559 KDBUS_ATTACH_AUXGROUPS = 1ULL << 2,
560 KDBUS_ATTACH_NAMES = 1ULL << 3,
561 KDBUS_ATTACH_TID_COMM = 1ULL << 4,
562 KDBUS_ATTACH_PID_COMM = 1ULL << 5,
563 KDBUS_ATTACH_EXE = 1ULL << 6,
564 KDBUS_ATTACH_CMDLINE = 1ULL << 7,
565 KDBUS_ATTACH_CGROUP = 1ULL << 8,
566 KDBUS_ATTACH_CAPS = 1ULL << 9,
567 KDBUS_ATTACH_SECLABEL = 1ULL << 10,
568 KDBUS_ATTACH_AUDIT = 1ULL << 11,
569 KDBUS_ATTACH_CONN_DESCRIPTION = 1ULL << 12,
570 _KDBUS_ATTACH_ALL = (1ULL << 13) - 1,
574 * struct kdbus_cmd_hello - struct to say hello to kdbus
575 * @size: The total size of the structure
576 * @flags: Connection flags (KDBUS_HELLO_*), userspace → kernel
577 * @kernel_flags: Supported connection flags, kernel → userspace
578 * @attach_flags: Mask of metadata to attach to each message sent
580 * @bus_flags: The flags field copied verbatim from the original
581 * KDBUS_CMD_BUS_MAKE ioctl. It's intended to be useful
582 * to do negotiation of features of the payload that is
583 * transferred (kernel → userspace)
584 * @id: The ID of this connection (kernel → userspace)
585 * @pool_size: Size of the connection's buffer where the received
586 * messages are placed
587 * @bloom: The bloom properties of the bus, specified
588 * by the bus creator (kernel → userspace)
589 * @id128: Unique 128-bit ID of the bus (kernel → userspace)
590 * @items: A list of items
592 * This struct is used with the KDBUS_CMD_HELLO ioctl.
594 struct kdbus_cmd_hello {
602 struct kdbus_bloom_parameter bloom;
604 struct kdbus_item items[0];
605 } __attribute__((aligned(8)));
608 * enum kdbus_make_flags - Flags for KDBUS_CMD_{BUS,EP,NS}_MAKE
609 * @KDBUS_MAKE_ACCESS_GROUP: Make the device node group-accessible
610 * @KDBUS_MAKE_ACCESS_WORLD: Make the device node world-accessible
612 enum kdbus_make_flags {
613 KDBUS_MAKE_ACCESS_GROUP = 1ULL << 0,
614 KDBUS_MAKE_ACCESS_WORLD = 1ULL << 1,
618 * struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain
619 * @size: The total size of the struct
620 * @flags: Properties for the bus/ep/domain to create,
622 * @kernel_flags: Supported flags for the used command, kernel → userspace
623 * @items: Items describing details
625 * This structure is used with the KDBUS_CMD_BUS_MAKE, KDBUS_CMD_ENDPOINT_MAKE
626 * and KDBUS_CMD_DOMAIN_MAKE ioctls.
628 struct kdbus_cmd_make {
632 struct kdbus_item items[0];
633 } __attribute__((aligned(8)));
636 * enum kdbus_name_flags - properties of a well-known name
637 * @KDBUS_NAME_REPLACE_EXISTING: Try to replace name of other connections
638 * @KDBUS_NAME_ALLOW_REPLACEMENT: Allow the replacement of the name
639 * @KDBUS_NAME_QUEUE: Name should be queued if busy
640 * @KDBUS_NAME_IN_QUEUE: Name is queued
641 * @KDBUS_NAME_ACTIVATOR: Name is owned by a activator connection
643 enum kdbus_name_flags {
644 KDBUS_NAME_REPLACE_EXISTING = 1ULL << 0,
645 KDBUS_NAME_ALLOW_REPLACEMENT = 1ULL << 1,
646 KDBUS_NAME_QUEUE = 1ULL << 2,
647 KDBUS_NAME_IN_QUEUE = 1ULL << 3,
648 KDBUS_NAME_ACTIVATOR = 1ULL << 4,
652 * struct kdbus_cmd_name - struct to describe a well-known name
653 * @size: The total size of the struct
654 * @flags: Flags for a name entry (KDBUS_NAME_*),
655 * userspace → kernel, kernel → userspace
656 * @kernel_flags: Supported flags for a name entry, kernel → userspace
657 * @items: Item list, containing the well-known name as
660 * This structure is used with the KDBUS_CMD_NAME_ACQUIRE ioctl.
662 struct kdbus_cmd_name {
666 struct kdbus_item items[0];
667 } __attribute__((aligned(8)));
670 * struct kdbus_name_info - struct to describe a well-known name
671 * @size: The total size of the struct
672 * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*)
673 * @owner_id: The current owner of the name
674 * @items: Item list, containing the well-known name as
675 * KDBUS_ITEM_OWNED_NAME
677 * This structure is used as return struct for the KDBUS_CMD_NAME_LIST ioctl.
679 struct kdbus_name_info {
683 struct kdbus_item items[0];
684 } __attribute__((aligned(8)));
687 * enum kdbus_name_list_flags - what to include into the returned list
688 * @KDBUS_NAME_LIST_UNIQUE: All active connections
689 * @KDBUS_NAME_LIST_NAMES: All known well-known names
690 * @KDBUS_NAME_LIST_ACTIVATORS: All activator connections
691 * @KDBUS_NAME_LIST_QUEUED: All queued-up names
693 enum kdbus_name_list_flags {
694 KDBUS_NAME_LIST_UNIQUE = 1ULL << 0,
695 KDBUS_NAME_LIST_NAMES = 1ULL << 1,
696 KDBUS_NAME_LIST_ACTIVATORS = 1ULL << 2,
697 KDBUS_NAME_LIST_QUEUED = 1ULL << 3,
701 * struct kdbus_cmd_name_list - request a list of name entries
702 * @flags: Flags for the query (KDBUS_NAME_LIST_*),
704 * @kernel_flags: Supported flags for queries, kernel → userspace
705 * @offset: The returned offset in the caller's pool buffer.
706 * The user must use KDBUS_CMD_FREE to free the
709 * This structure is used with the KDBUS_CMD_NAME_LIST ioctl.
711 struct kdbus_cmd_name_list {
715 } __attribute__((aligned(8)));
718 * struct kdbus_name_list - information returned by KDBUS_CMD_NAME_LIST
719 * @size: The total size of the structure
720 * @names: A list of names
722 * Note that the user is responsible for freeing the allocated memory with
723 * the KDBUS_CMD_FREE ioctl.
725 struct kdbus_name_list {
727 struct kdbus_name_info names[0];
731 * struct kdbus_cmd_info - struct used for KDBUS_CMD_CONN_INFO ioctl
732 * @size: The total size of the struct
733 * @flags: KDBUS_ATTACH_* flags, userspace → kernel
734 * @kernel_flags: Supported KDBUS_ATTACH_* flags, kernel → userspace
735 * @id: The 64-bit ID of the connection. If set to zero, passing
736 * @name is required. kdbus will look up the name to
737 * determine the ID in this case.
738 * @offset: Returned offset in the caller's pool buffer where the
739 * kdbus_info struct result is stored. The user must
740 * use KDBUS_CMD_FREE to free the allocated memory.
741 * @items: The optional item list, containing the
742 * well-known name to look up as a KDBUS_ITEM_NAME.
743 * Only needed in case @id is zero.
745 * On success, the KDBUS_CMD_CONN_INFO ioctl will return 0 and @offset will
746 * tell the user the offset in the connection pool buffer at which to find the
747 * result in a struct kdbus_info.
749 struct kdbus_cmd_info {
755 struct kdbus_item items[0];
756 } __attribute__((aligned(8)));
759 * struct kdbus_info - information returned by KDBUS_CMD_*_INFO
760 * @size: The total size of the struct
761 * @id: The connection's or bus' 64-bit ID
762 * @flags: The connection's or bus' flags
763 * @items: A list of struct kdbus_item
765 * Note that the user is responsible for freeing the allocated memory with
766 * the KDBUS_CMD_FREE ioctl.
772 struct kdbus_item items[0];
776 * struct kdbus_cmd_update - update flags of a connection
777 * @size: The total size of the struct
778 * @flags: Flags for the update command, userspace → kernel
779 * @kernel_flags: Supported flags for this command, kernel → userspace
780 * @items: A list of struct kdbus_item
782 * This struct is used with the KDBUS_CMD_CONN_UPDATE ioctl.
784 struct kdbus_cmd_update {
788 struct kdbus_item items[0];
789 } __attribute__((aligned(8)));
792 * enum kdbus_cmd_match_flags - flags to control the KDBUS_CMD_MATCH_ADD ioctl
793 * @KDBUS_MATCH_REPLACE: If entries with the supplied cookie already
794 * exists, remove them before installing the new
797 enum kdbus_cmd_match_flags {
798 KDBUS_MATCH_REPLACE = 1ULL << 0,
802 * struct kdbus_cmd_match - struct to add or remove matches
803 * @size: The total size of the struct
804 * @cookie: Userspace supplied cookie. When removing, the cookie
805 * identifies the match to remove
806 * @flags: Flags for match command (KDBUS_MATCH_*),
808 * @kernel_flags: Supported flags of the used command, kernel → userspace
809 * @items: A list of items for additional information
811 * This structure is used with the KDBUS_CMD_MATCH_ADD and
812 * KDBUS_CMD_MATCH_REMOVE ioctl.
814 struct kdbus_cmd_match {
819 struct kdbus_item items[0];
820 } __attribute__((aligned(8)));
824 * KDBUS_CMD_BUS_MAKE: After opening the "control" device node, this
825 * command creates a new bus with the specified
826 * name. The bus is immediately shut down and
827 * cleaned up when the opened "control" device node
829 * KDBUS_CMD_DOMAIN_MAKE: Similar to KDBUS_CMD_BUS_MAKE, but it creates a
831 * KDBUS_CMD_ENDPOINT_MAKE: Creates a new named special endpoint to talk to
832 * the bus. Such endpoints usually carry a more
833 * restrictive policy and grant restricted access
834 * to specific applications.
835 * KDBUS_CMD_HELLO: By opening the bus device node a connection is
836 * created. After a HELLO the opened connection
837 * becomes an active peer on the bus.
838 * KDBUS_CMD_BYEBYE: Disconnect a connection. If there are no
839 * messages queued up in the connection's pool,
840 * the call succeeds, and the handle is rendered
841 * unusable. Otherwise, -EBUSY is returned without
842 * any further side-effects.
843 * KDBUS_CMD_MSG_SEND: Send a message and pass data from userspace to
845 * KDBUS_CMD_MSG_RECV: Receive a message from the kernel which is
846 * placed in the receiver's pool.
847 * KDBUS_CMD_MSG_CANCEL: Cancel a pending request of a message that
848 * blocks while waiting for a reply. The parameter
849 * denotes the cookie of the message in flight.
850 * KDBUS_CMD_FREE: Release the allocated memory in the receiver's
852 * KDBUS_CMD_NAME_ACQUIRE: Request a well-known bus name to associate with
853 * the connection. Well-known names are used to
854 * address a peer on the bus.
855 * KDBUS_CMD_NAME_RELEASE: Release a well-known name the connection
857 * KDBUS_CMD_NAME_LIST: Retrieve the list of all currently registered
858 * well-known and unique names.
859 * KDBUS_CMD_CONN_INFO: Retrieve credentials and properties of the
860 * initial creator of the connection. The data was
861 * stored at registration time and does not
862 * necessarily represent the connected process or
863 * the actual state of the process.
864 * KDBUS_CMD_CONN_UPDATE: Update the properties of a connection. Used to
865 * update the metadata subscription mask and
867 * KDBUS_CMD_BUS_CREATOR_INFO: Retrieve information of the creator of the bus
868 * a connection is attached to.
869 * KDBUS_CMD_ENDPOINT_UPDATE: Update the properties of a custom enpoint. Used
870 * to update the policy.
871 * KDBUS_CMD_MATCH_ADD: Install a match which broadcast messages should
872 * be delivered to the connection.
873 * KDBUS_CMD_MATCH_REMOVE: Remove a current match for broadcast messages.
875 #define KDBUS_CMD_BUS_MAKE _IOW(KDBUS_IOCTL_MAGIC, 0x00, \
876 struct kdbus_cmd_make)
877 #define KDBUS_CMD_DOMAIN_MAKE _IOW(KDBUS_IOCTL_MAGIC, 0x10, \
878 struct kdbus_cmd_make)
879 #define KDBUS_CMD_ENDPOINT_MAKE _IOW(KDBUS_IOCTL_MAGIC, 0x20, \
880 struct kdbus_cmd_make)
882 #define KDBUS_CMD_HELLO _IOWR(KDBUS_IOCTL_MAGIC, 0x30, \
883 struct kdbus_cmd_hello)
884 #define KDBUS_CMD_BYEBYE _IO(KDBUS_IOCTL_MAGIC, 0x31) \
886 #define KDBUS_CMD_MSG_SEND _IOWR(KDBUS_IOCTL_MAGIC, 0x40, \
888 #define KDBUS_CMD_MSG_RECV _IOWR(KDBUS_IOCTL_MAGIC, 0x41, \
889 struct kdbus_cmd_recv)
890 #define KDBUS_CMD_MSG_CANCEL _IOW(KDBUS_IOCTL_MAGIC, 0x42, \
891 struct kdbus_cmd_cancel)
892 #define KDBUS_CMD_FREE _IOW(KDBUS_IOCTL_MAGIC, 0x43, \
893 struct kdbus_cmd_free)
895 #define KDBUS_CMD_NAME_ACQUIRE _IOWR(KDBUS_IOCTL_MAGIC, 0x50, \
896 struct kdbus_cmd_name)
897 #define KDBUS_CMD_NAME_RELEASE _IOW(KDBUS_IOCTL_MAGIC, 0x51, \
898 struct kdbus_cmd_name)
899 #define KDBUS_CMD_NAME_LIST _IOWR(KDBUS_IOCTL_MAGIC, 0x52, \
900 struct kdbus_cmd_name_list)
902 #define KDBUS_CMD_CONN_INFO _IOWR(KDBUS_IOCTL_MAGIC, 0x60, \
903 struct kdbus_cmd_info)
904 #define KDBUS_CMD_CONN_UPDATE _IOW(KDBUS_IOCTL_MAGIC, 0x61, \
905 struct kdbus_cmd_update)
906 #define KDBUS_CMD_BUS_CREATOR_INFO _IOWR(KDBUS_IOCTL_MAGIC, 0x62, \
907 struct kdbus_cmd_info)
909 #define KDBUS_CMD_ENDPOINT_UPDATE _IOW(KDBUS_IOCTL_MAGIC, 0x71, \
910 struct kdbus_cmd_update)
912 #define KDBUS_CMD_MATCH_ADD _IOW(KDBUS_IOCTL_MAGIC, 0x80, \
913 struct kdbus_cmd_match)
914 #define KDBUS_CMD_MATCH_REMOVE _IOW(KDBUS_IOCTL_MAGIC, 0x81, \
915 struct kdbus_cmd_match)
917 #endif /* _KDBUS_UAPI_H_ */