2 * Copyright (C) 2013 Kay Sievers
3 * Copyright (C) 2013 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4 * Copyright (C) 2013 Linux Foundation
5 * Copyright (C) 2013 Lennart Poettering
6 * Copyright (C) 2013 Daniel Mack <daniel@zonque.org>
8 * kdbus is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Lesser General Public License as published by the
10 * Free Software Foundation; either version 2.1 of the License, or (at
11 * your option) any later version.
18 #include <sys/ioctl.h>
19 #include <sys/types.h>
20 #include <linux/types.h>
23 #define KDBUS_IOC_MAGIC 0x95
24 #define KDBUS_SRC_ID_KERNEL (0)
25 #define KDBUS_DST_ID_NAME (0)
26 #define KDBUS_MATCH_SRC_ID_ANY (~0ULL)
27 #define KDBUS_DST_ID_BROADCAST (~0ULL)
30 * struct kdbus_notify_name_change - name registry change message
31 * @old_id: Former owner of a name
32 * @new_id: New owner of a name
33 * @old_flags: flags from KDBUS_NAME_* the name entry used to have
34 * @new_flags: flags from KDBUS_NAME_* the name entry has now
35 * @name: Well-known name
37 * Sent from kernel to userspace when the owner or starter of
38 * a well-known name changes.
42 * KDBUS_ITEM_NAME_REMOVE
43 * KDBUS_ITEM_NAME_CHANGE
45 struct kdbus_notify_name_change {
54 * struct kdbus_notify_id_change - name registry change message
55 * @id: New or former owner of the name
56 * @flags: flags field from KDBUS_HELLO_*
58 * Sent from kernel to userspace when the owner or starter of
59 * a well-known name changes.
63 * KDBUS_ITEM_ID_REMOVE
65 struct kdbus_notify_id_change {
71 * struct kdbus_creds - process credentials
76 * @starttime: Starttime of the process
78 * The starttime of the process PID. This is useful to detect PID overruns
79 * from the client side. i.e. if you use the PID to look something up in
80 * /proc/$PID/ you can afterwards check the starttime field of it, to ensure
81 * you didn't run into a PID overrun.
95 * struct kdbus_audit - audit information
96 * @sessionid: The audit session ID
97 * @loginuid: The audit login uid
108 * struct kdbus_timestamp
109 * @monotonic_ns: Monotonic timestamp, in nanoseconds
110 * @realtime_ns: Realtime timestamp, in nanoseconds
113 * KDBUS_ITEM_TIMESTAMP
115 struct kdbus_timestamp {
121 * struct kdbus_vec - I/O vector for kdbus payload items
122 * @size: The size of the vector
123 * @address: Memory address for memory addresses
124 * @offset: Offset in the in-message payload memory
127 * KDBUS_ITEM_PAYLOAD_VEC
138 * struct kdbus_memfd - a kdbus memfd
139 * @size: The memfd's size
140 * @fd: The file descriptor number
141 * @__pad: Padding to make the struct aligned
144 * KDBUS_ITEM_PAYLOAD_MEMFD
153 * struct kdbus_name - a registered well-known name with its flags
154 * @flags: flags from KDBUS_NAME_*
155 * @name: well-known name
166 * struct kdbus_policy_access - policy access item
167 * @type: One of KDBUS_POLICY_ACCESS_* types
168 * @bits: Access to grant. One of KDBUS_POLICY_*
169 * @id: For KDBUS_POLICY_ACCESS_USER, the uid
170 * For KDBUS_POLICY_ACCESS_GROUP, the gid
173 * struct kdbus_policy
175 struct kdbus_policy_access {
176 __u64 type; /* USER, GROUP, WORLD */
177 __u64 bits; /* RECV, SEND, OWN */
178 __u64 id; /* uid, gid, 0 */
182 * struct kdbus_policy - a policy item
183 * @access: Policy access details
184 * @name: Well-known name to grant access to
187 * KDBUS_POLICY_ACCESS
188 * KDBUS_ITEM_POLICY_NAME
190 struct kdbus_policy {
192 struct kdbus_policy_access access;
198 * enum kdbus_item_type - item types to chain data in a list
199 * @KDBUS_ITEM_PAYLOAD_VEC: Vector to data
200 * @KDBUS_ITEM_PAYLOAD_OFF: Data at returned offset in the pool
201 * @KDBUS_ITEM_PAYLOAD_MEMFD: Data as sealed memfd
202 * @KDBUS_ITEM_FDS: Attached file descriptors
203 * @KDBUS_ITEM_BLOOM: For broadcasts, carries bloom filter
204 * @KDBUS_ITEM_DST_NAME: Destination's well-known name
205 * @KDBUS_ITEM_PRIORITY: Queue priority for message
206 * @KDBUS_ITEM_MAKE_NAME: Name of namespace, bus, endpoint
207 * @KDBUS_ITEM_POLICY_NAME: Policy in struct kdbus_policy
208 * @KDBUS_ITEM_POLICY_ACCESS: Policy in struct kdbus_policy
209 * @KDBUS_ITEM_NAME: Well-know name with flags
210 * @KDBUS_ITEM_STARTER_NAME: Well-known name for the starter
211 * @KDBUS_ITEM_TIMESTAMP: Timestamp
212 * @KDBUS_ITEM_CREDS: Process credential
213 * @KDBUS_ITEM_PID_COMM: Process ID "comm" identifier
214 * @KDBUS_ITEM_TID_COMM: Thread ID "comm" identifier
215 * @KDBUS_ITEM_EXE: The path of the executable
216 * @KDBUS_ITEM_CMDLINE: The process command line
217 * @KDBUS_ITEM_CGROUP: The croup membership
218 * @KDBUS_ITEM_CAPS: The process capabilities
219 * @KDBUS_ITEM_SECLABEL: The security label
220 * @KDBUS_ITEM_AUDIT: The audit IDs
221 * @KDBUS_ITEM_NAME_ADD: Notify in struct kdbus_notify_name_change
222 * @KDBUS_ITEM_NAME_REMOVE: Notify in struct kdbus_notify_name_change
223 * @KDBUS_ITEM_NAME_CHANGE: Notify in struct kdbus_notify_name_change
224 * @KDBUS_ITEM_ID_ADD: Notify in struct kdbus_notify_id_change
225 * @KDBUS_ITEM_ID_REMOVE: Notify in struct kdbus_notify_id_change
226 * @KDBUS_ITEM_REPLY_TIMEOUT: Timeout has been reached
227 * @KDBUS_ITEM_REPLY_DEAD: Destination died
229 enum kdbus_item_type {
231 _KDBUS_ITEM_USER_BASE,
232 KDBUS_ITEM_PAYLOAD_VEC = _KDBUS_ITEM_USER_BASE,
233 KDBUS_ITEM_PAYLOAD_OFF,
234 KDBUS_ITEM_PAYLOAD_MEMFD,
239 KDBUS_ITEM_MAKE_NAME,
241 _KDBUS_ITEM_POLICY_BASE = 0x400,
242 KDBUS_ITEM_POLICY_NAME = _KDBUS_ITEM_POLICY_BASE,
243 KDBUS_ITEM_POLICY_ACCESS,
245 _KDBUS_ITEM_ATTACH_BASE = 0x600,
246 KDBUS_ITEM_NAME = _KDBUS_ITEM_ATTACH_BASE,
247 KDBUS_ITEM_STARTER_NAME,
248 KDBUS_ITEM_TIMESTAMP,
259 _KDBUS_ITEM_KERNEL_BASE = 0x800,
260 KDBUS_ITEM_NAME_ADD = _KDBUS_ITEM_KERNEL_BASE,
261 KDBUS_ITEM_NAME_REMOVE,
262 KDBUS_ITEM_NAME_CHANGE,
264 KDBUS_ITEM_ID_REMOVE,
265 KDBUS_ITEM_REPLY_TIMEOUT,
266 KDBUS_ITEM_REPLY_DEAD,
270 * struct kdbus_item - chain of data blocks
271 * @size: Overall data record size
272 * @type: Kdbus_item type of data
273 * @data: Generic bytes
274 * @data32: Generic 32 bit array
275 * @data64: Generic 64 bit array
276 * @str: Generic string
278 * @vec: KDBUS_ITEM_PAYLOAD_VEC
279 * @creds: KDBUS_ITEM_CREDS
280 * @audit: KDBUS_ITEM_AUDIT
281 * @timestamp: KDBUS_ITEM_TIMESTAMP
282 * @name: KDBUS_ITEM_NAME
283 * @memfd: KDBUS_ITEM_PAYLOAD_MEMFD
284 * @name_change: KDBUS_ITEM_NAME_ADD
285 * KDBUS_ITEM_NAME_REMOVE
286 * KDBUS_ITEM_NAME_CHANGE
287 * @id_change: KDBUS_ITEM_ID_ADD
288 * KDBUS_ITEM_ID_REMOVE
289 * @policy: KDBUS_ITEM_POLICY_NAME
290 * KDBUS_ITEM_POLICY_ACCESS
302 struct kdbus_vec vec;
303 struct kdbus_creds creds;
304 struct kdbus_audit audit;
305 struct kdbus_timestamp timestamp;
306 struct kdbus_name name;
307 struct kdbus_memfd memfd;
309 struct kdbus_notify_name_change name_change;
310 struct kdbus_notify_id_change id_change;
311 struct kdbus_policy policy;
316 * enum kdbus_msg_flags - type of message
317 * @KDBUS_MSG_FLAGS_EXPECT_REPLY: Expect a reply message, used for method
318 * calls. The cookie identifies the
319 * message and the respective reply
320 * @KDBUS_MSG_FLAGS_NO_AUTO_START: Do not start a service, if the addressed
321 * name is not currently active
323 enum kdbus_msg_flags {
324 KDBUS_MSG_FLAGS_EXPECT_REPLY = 1 << 0,
325 KDBUS_MSG_FLAGS_NO_AUTO_START = 1 << 1,
329 * enum kdbus_payload_type - type of payload carried by message
330 * @KDBUS_PAYLOAD_KERNEL: Kernel-generated simple message
331 * @KDBUS_PAYLOAD_DBUS: D-Bus marshalling
333 enum kdbus_payload_type {
334 KDBUS_PAYLOAD_KERNEL,
335 KDBUS_PAYLOAD_DBUS = 0x4442757344427573ULL, /* 'DBusDBus' */
339 * struct kdbus_msg - the representation of a kdbus message
340 * @size: Total size of the message
341 * @flags: Message flags (KDBUS_MSG_FLAGS_*)
342 * @dst_id: 64-bit ID of the destination connection
343 * @src_id: 64-bit ID of the source connection
344 * @payload_type: Payload type (KDBUS_PAYLOAD_*)
345 * @cookie: Userspace-supplied cookie
346 * @cookie_reply: For kernel-generated messages, this is the cookie
347 * the message is a reply to
348 * @timeout_ns: For non-kernel-generated messages, this denotes the
349 * message timeout in nanoseconds
350 * @items: A list of kdbus_items containing the message payload
363 struct kdbus_item items[0];
367 * enum kdbus_policy_access_type - permissions of a policy record
368 * @KDBUS_POLICY_ACCESS_USER: Grant access to a uid
369 * @KDBUS_POLICY_ACCESS_GROUP: Grant access to gid
370 * @KDBUS_POLICY_ACCESS_WORLD: World-accessible
372 enum kdbus_policy_access_type {
373 _KDBUS_POLICY_ACCESS_NULL,
374 KDBUS_POLICY_ACCESS_USER,
375 KDBUS_POLICY_ACCESS_GROUP,
376 KDBUS_POLICY_ACCESS_WORLD,
380 * enum kdbus_policy_access_flags - mode flags
381 * @KDBUS_POLICY_RECV: Allow receive
382 * @KDBUS_POLICY_SEND: Allow send
383 * @KDBUS_POLICY_OWN: Allow to own a well-known name
385 enum kdbus_policy_type {
386 KDBUS_POLICY_RECV = 1 << 2,
387 KDBUS_POLICY_SEND = 1 << 1,
388 KDBUS_POLICY_OWN = 1 << 0,
392 * struct kdbus_cmd_policy - a series of policies to upload
393 * @size: The total size of the structure
394 * @policies: The policies to upload
396 * A KDBUS_POLICY_NAME must always preceeds a KDBUS_POLICY_ACCESS entry.
397 * A new KDBUS_POLICY_NAME can be added after KDBUS_POLICY_ACCESS for
398 * chaining multiple policies together.
400 struct kdbus_cmd_policy {
402 struct kdbus_item policies[0];
406 * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello
407 * @KDBUS_HELLO_STARTER: The connection registers a name for activation
409 * @KDBUS_HELLO_ACCEPT_FD: The connection allows the receiving of
410 * any passed file descriptors
412 enum kdbus_hello_flags {
413 KDBUS_HELLO_STARTER = 1 << 0,
414 KDBUS_HELLO_ACCEPT_FD = 1 << 1,
418 * enum kdbus_attach_flags - flags for metadata attachments
419 * @KDBUS_ATTACH_TIMESTAMP: Timestamp
420 * @KDBUS_ATTACH_CREDS: Credentials
421 * @KDBUS_ATTACH_NAMES: Well-known names
422 * @KDBUS_ATTACH_COMM: The "comm" process identifier
423 * @KDBUS_ATTACH_EXE: The path of the executable
424 * @KDBUS_ATTACH_CMDLINE: The process command line
425 * @KDBUS_ATTACH_CGROUP: The croup membership
426 * @KDBUS_ATTACH_CAPS: The process capabilities
427 * @KDBUS_ATTACH_SECLABEL: The security label
428 * @KDBUS_ATTACH_AUDIT: The audit IDs
430 enum kdbus_attach_flags {
431 KDBUS_ATTACH_TIMESTAMP = 1 << 0,
432 KDBUS_ATTACH_CREDS = 1 << 1,
433 KDBUS_ATTACH_NAMES = 1 << 2,
434 KDBUS_ATTACH_COMM = 1 << 3,
435 KDBUS_ATTACH_EXE = 1 << 4,
436 KDBUS_ATTACH_CMDLINE = 1 << 5,
437 KDBUS_ATTACH_CGROUP = 1 << 6,
438 KDBUS_ATTACH_CAPS = 1 << 7,
439 KDBUS_ATTACH_SECLABEL = 1 << 8,
440 KDBUS_ATTACH_AUDIT = 1 << 9,
444 * struct kdbus_cmd_hello - struct to say hello to kdbus
445 * @size: The total size of the structure
446 * @conn_flags: Connection flags (KDBUS_HELLO_*). The kernel will
447 * return its capabilities in that field.
448 * @attach_flags: Mask of metadata to attach to each message sent
450 * @bus_flags: The flags field copied verbatim from the original
451 * KDBUS_CMD_BUS_MAKE ioctl. It's intended to be useful
452 * to do negotiation of features of the payload that is
453 * transferred (kernel → userspace)
454 * @id: The ID of this connection (kernel → userspace)
455 * @bloom_size: The bloom filter size chosen by the owner
456 * (kernel → userspace)
457 * @pool_size: Maximum size of the pool buffer (kernel → userspace)
458 * @id128: Unique 128-bit ID of the bus (kernel → userspace)
459 * @items: A list of items
461 * This struct is used with the KDBUS_CMD_HELLO ioctl. See the ioctl
462 * documentation for more information.
464 struct kdbus_cmd_hello {
473 struct kdbus_item items[0];
476 /* Flags for KDBUS_CMD_{BUS,EP,NS}_MAKE */
477 enum kdbus_make_flags {
478 KDBUS_MAKE_ACCESS_GROUP = 1 << 0,
479 KDBUS_MAKE_ACCESS_WORLD = 1 << 1,
480 KDBUS_MAKE_POLICY_OPEN = 1 << 2,
484 * struct kdbus_cmd_bus_make - struct to make a bus
485 * @size: The total size of the struct
486 * @flags: Properties for the bus to create
487 * @bloom_size: Size of the bloom filter for this bus
488 * @items: Items describing details such as the name of the bus
490 * This structure is used with the KDBUS_CMD_BUS_MAKE ioctl.
492 struct kdbus_cmd_bus_make {
496 struct kdbus_item items[0];
500 * struct kdbus_cmd_ep_make - struct to make an endpoint
501 * @size: The total size of the struct
502 * @flags: Unused for now
503 * @items: Items describing details such as the
504 * name of the endpoint
506 * This structure is used with the KDBUS_CMD_EP_MAKE ioctl.
508 struct kdbus_cmd_ep_make {
511 struct kdbus_item items[0];
515 * struct kdbus_cmd_ns_make - struct to make a namespace
516 * @size: The total size of the struct
517 * @flags: Unused for now
518 * @items: Items describing details such as the
519 * name of the namespace
521 * This structure is used with the KDBUS_CMD_NS_MAKE ioctl.
523 struct kdbus_cmd_ns_make {
526 struct kdbus_item items[0];
530 * enum kdbus_name_flags - properties of a well-known name
531 * @KDBUS_NAME_REPLACE_EXISTING: Try to replace name of other connections
532 * @KDBUS_NAME_ALLOW_REPLACEMENT: Allow the replacement of the name
533 * @KDBUS_NAME_QUEUE: Name should be queued if busy
534 * @KDBUS_NAME_IN_QUEUE: Name is queued
535 * @KDBUS_NAME_STARTER: Name is owned by a starter connection
537 enum kdbus_name_flags {
538 KDBUS_NAME_REPLACE_EXISTING = 1 << 0,
539 KDBUS_NAME_ALLOW_REPLACEMENT = 1 << 1,
540 KDBUS_NAME_QUEUE = 1 << 2,
541 KDBUS_NAME_IN_QUEUE = 1 << 3,
542 KDBUS_NAME_STARTER = 1 << 4,
546 * struct kdbus_cmd_name - struct to describe a well-known name
547 * @size: The total size of the struct
548 * @flags: Flags for a name entry (KDBUS_NAME_*)
549 * @id: Privileged users may use this field to (de)register
550 * names on behalf of other peers.
551 * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*)
552 * @name: The well-known name
554 * This structure is used with the KDBUS_CMD_NAME_ACQUIRE ioctl.
556 struct kdbus_cmd_name {
565 * enum kdbus_name_list_flags - what to include into the returned list
566 * @KDBUS_NAME_LIST_UNIQUE: All active connections
567 * @KDBUS_NAME_LIST_NAMES: All known well-known names
568 * @KDBUS_NAME_LIST_STARTERS: All connections which are starter connections
569 * @KDBUS_NAME_LIST_QUEUED: All queued-up names
571 enum kdbus_name_list_flags {
572 KDBUS_NAME_LIST_UNIQUE = 1 << 0,
573 KDBUS_NAME_LIST_NAMES = 1 << 1,
574 KDBUS_NAME_LIST_STARTERS = 1 << 2,
575 KDBUS_NAME_LIST_QUEUED = 1 << 3,
579 * struct kdbus_cmd_name_list - request a list of name entries
580 * @flags: Flags for the query (KDBUS_NAME_LIST_*)
581 * @offset: The returned offset in the caller's pool buffer.
582 * The user must use KDBUS_CMD_FREE to free the
585 * This structure is used with the KDBUS_CMD_NAME_LIST ioctl.
587 struct kdbus_cmd_name_list {
593 * struct kdbus_name_list - information returned by KDBUS_CMD_NAME_LIST
594 * @size: The total size of the structure
595 * @names: A list of names
597 * Note that the user is responsible for freeing the allocated memory with
598 * the KDBUS_CMD_FREE ioctl.
600 struct kdbus_name_list {
602 struct kdbus_cmd_name names[0];
606 * struct kdbus_cmd_conn_info - struct used for KDBUS_CMD_CONN_INFO ioctl
607 * @size: The total size of the struct
608 * @flags: KDBUS_ATTACH_* flags
609 * @id: The 64-bit ID of the connection. If set to zero, passing
610 * @name is required. kdbus will look up the name to determine
611 * the ID in this case.
612 * @offset: Returned offset in the caller's pool buffer where the
613 * kdbus_conn_info struct result is stored. The user must
614 * use KDBUS_CMD_FREE to free the allocated memory.
615 * @name: The optional well-known name to look up. Only needed in
618 * On success, the KDBUS_CMD_CONN_INFO ioctl will return 0 and @offset will
619 * tell the user the offset in the connection pool buffer at which to find the
620 * result in a struct kdbus_conn_info.
622 struct kdbus_cmd_conn_info {
631 * struct kdbus_conn_info - information returned by KDBUS_CMD_CONN_INFO
632 * @size: The total size of the struct
633 * @id: The connection's 64-bit ID
634 * @flags: The connection's flags
635 * @items: A list of struct kdbus_item
637 * Note that the user is responsible for freeing the allocated memory with
638 * the KDBUS_CMD_FREE ioctl.
640 struct kdbus_conn_info {
644 struct kdbus_item items[0];
648 * enum kdbus_match_type - type of match record
649 * @KDBUS_MATCH_BLOOM: Matches against KDBUS_MSG_BLOOM
650 * @KDBUS_MATCH_SRC_NAME: Matches a name string
651 * @KDBUS_MATCH_NAME_ADD: Matches a name string
652 * @KDBUS_MATCH_NAME_REMOVE: Matches a name string
653 * @KDBUS_MATCH_NAME_CHANGE: Matches a name string
654 * @KDBUS_MATCH_ID_ADD: Matches an ID
655 * @KDBUS_MATCH_ID_REMOVE: Matches an ID
657 enum kdbus_match_type {
660 KDBUS_MATCH_SRC_NAME,
661 KDBUS_MATCH_NAME_ADD,
662 KDBUS_MATCH_NAME_REMOVE,
663 KDBUS_MATCH_NAME_CHANGE,
665 KDBUS_MATCH_ID_REMOVE,
669 * struct kdbus_cmd_match - struct to add or remove matches
670 * @size: The total size of the struct
671 * @id: Privileged users may (de)register matches on behalf
672 * of other peers. In other cases, set to 0.
673 * @cookie: Userspace supplied cookie. When removing, the cookie
674 * identifies the match to remove.
675 * @src_id: The source ID to match against. Use
676 * KDBUS_MATCH_SRC_ID_ANY or any other value for a unique
678 * @items: A list of items for additional information
680 * This structure is used with the KDBUS_CMD_ADD_MATCH and
681 * KDBUS_CMD_REMOVE_MATCH ioctl.
683 struct kdbus_cmd_match {
688 struct kdbus_item items[0];
692 * enum kdbus_monitor_flags - flags for monitoring
693 * @KDBUS_MONITOR_ENABLE: Enable monitoring
695 enum kdbus_monitor_flags {
696 KDBUS_MONITOR_ENABLE = 1 << 0,
700 * struct kdbus_cmd_monitor - struct to enable or disable eavesdropping
701 * @id: Privileged users may enable or disable the monitor feature
702 * on behalf of other peers
703 * @flags: Use KDBUS_MONITOR_ENABLE to enable eavesdropping
705 * This structure is used with the KDBUS_CMD_MONITOR ioctl.
707 struct kdbus_cmd_monitor {
713 * enum kdbus_ioctl_type - Ioctl API
714 * @KDBUS_CMD_BUS_MAKE: After opening the "control" device node, this
715 * command creates a new bus with the specified
716 * name. The bus is immediately shut down and
717 * cleaned up when the opened "control" device node
719 * @KDBUS_CMD_NS_MAKE: Similar to KDBUS_CMD_BUS_MAKE, but it creates a
720 * new kdbus namespace.
721 * @KDBUS_CMD_EP_MAKE: Creates a new named special endpoint to talk to
722 * the bus. Such endpoints usually carry a more
723 * restrictive policy and grant restricted access
724 * to specific applications.
725 * @KDBUS_CMD_HELLO: By opening the bus device node a connection is
726 * created. After a HELLO the opened connection
727 * becomes an active peer on the bus.
728 * @KDBUS_CMD_MSG_SEND: Send a message and pass data from userspace to
730 * @KDBUS_CMD_MSG_RECV: Receive a message from the kernel which is
731 * placed in the receiver's pool.
732 * @KDBUS_CMD_FREE: Release the allocated memory in the receiver's
734 * @KDBUS_CMD_NAME_ACQUIRE: Request a well-known bus name to associate with
735 * the connection. Well-known names are used to
736 * address a peer on the bus.
737 * @KDBUS_CMD_NAME_RELEASE: Release a well-known name the connection
739 * @KDBUS_CMD_NAME_LIST: Retrieve the list of all currently registered
740 * well-known and unique names.
741 * @KDBUS_CMD_CONN_INFO: Retrieve credentials and properties of the
742 * initial creator of the connection. The data was
743 * stored at registration time and does not
744 * necessarily represent the connected process or
745 * the actual state of the process.
746 * @KDBUS_CMD_MATCH_ADD: Install a match which broadcast messages should
747 * be delivered to the connection.
748 * @KDBUS_CMD_MATCH_REMOVE: Remove a current match for broadcast messages.
749 * @KDBUS_CMD_MONITOR: Monitor the bus and receive all transmitted
750 * messages. Privileges are required for this
752 * @KDBUS_CMD_EP_POLICY_SET: Set the policy of an endpoint. It is used to
753 * restrict the access for endpoints created with
755 * @KDBUS_CMD_MEMFD_NEW: Return a new file descriptor which provides an
756 * anonymous shared memory file and which can be
757 * used to pass around larger chunks of data.
758 * Kdbus memfd files can be sealed, which allows
759 * the receiver to trust the data it has received.
760 * Kdbus memfd files expose only very limited
761 * operations, they can be mmap()ed, seek()ed,
762 * (p)read(v)() and (p)write(v)(); most other
763 * common file operations are not implemented.
764 * Special caution needs to be taken with
765 * read(v)()/write(v)() on a shared file; the
766 * underlying file position is always shared
767 * between all users of the file and race against
768 * each other, pread(v)()/pwrite(v)() avoid these
770 * @KDBUS_CMD_MEMFD_SIZE_GET: Return the size of the underlying file, which
771 * changes with write().
772 * @KDBUS_CMD_MEMFD_SIZE_SET: Truncate the underlying file to the specified
774 * @KDBUS_CMD_MEMFD_SEAL_GET: Return the state of the file sealing.
775 * @KDBUS_CMD_MEMFD_SEAL_SET: Seal or break a seal of the file. Only files
776 * which are not shared with other processes and
777 * which are currently not mapped can be sealed.
778 * The current process needs to be the one and
779 * single owner of the file, the sealing cannot
780 * be changed as long as the file is shared.
782 enum kdbus_ioctl_type {
783 KDBUS_CMD_BUS_MAKE = _IOW (KDBUS_IOC_MAGIC, 0x00, struct kdbus_cmd_bus_make),
784 KDBUS_CMD_NS_MAKE = _IOR (KDBUS_IOC_MAGIC, 0x10, struct kdbus_cmd_ns_make),
786 KDBUS_CMD_EP_MAKE = _IOW (KDBUS_IOC_MAGIC, 0x20, struct kdbus_cmd_ep_make),
787 KDBUS_CMD_HELLO = _IOWR(KDBUS_IOC_MAGIC, 0x30, struct kdbus_cmd_hello),
789 KDBUS_CMD_MSG_SEND = _IOW (KDBUS_IOC_MAGIC, 0x40, struct kdbus_msg),
790 KDBUS_CMD_MSG_RECV = _IOR (KDBUS_IOC_MAGIC, 0x41, __u64 *),
791 KDBUS_CMD_FREE = _IOW (KDBUS_IOC_MAGIC, 0x42, __u64 *),
793 KDBUS_CMD_NAME_ACQUIRE = _IOWR(KDBUS_IOC_MAGIC, 0x50, struct kdbus_cmd_name),
794 KDBUS_CMD_NAME_RELEASE = _IOW (KDBUS_IOC_MAGIC, 0x51, struct kdbus_cmd_name),
795 KDBUS_CMD_NAME_LIST = _IOWR(KDBUS_IOC_MAGIC, 0x52, struct kdbus_cmd_name_list),
797 KDBUS_CMD_CONN_INFO = _IOWR(KDBUS_IOC_MAGIC, 0x60, struct kdbus_cmd_conn_info),
799 KDBUS_CMD_MATCH_ADD = _IOW (KDBUS_IOC_MAGIC, 0x70, struct kdbus_cmd_match),
800 KDBUS_CMD_MATCH_REMOVE = _IOW (KDBUS_IOC_MAGIC, 0x71, struct kdbus_cmd_match),
801 KDBUS_CMD_MONITOR = _IOW (KDBUS_IOC_MAGIC, 0x72, struct kdbus_cmd_monitor),
803 KDBUS_CMD_EP_POLICY_SET = _IOW (KDBUS_IOC_MAGIC, 0x80, struct kdbus_cmd_policy),
805 KDBUS_CMD_MEMFD_NEW = _IOR (KDBUS_IOC_MAGIC, 0x90, int *),
806 KDBUS_CMD_MEMFD_SIZE_GET = _IOR (KDBUS_IOC_MAGIC, 0x91, __u64 *),
807 KDBUS_CMD_MEMFD_SIZE_SET = _IOW (KDBUS_IOC_MAGIC, 0x92, __u64 *),
808 KDBUS_CMD_MEMFD_SEAL_GET = _IOR (KDBUS_IOC_MAGIC, 0x93, int *),
809 KDBUS_CMD_MEMFD_SEAL_SET = _IO (KDBUS_IOC_MAGIC, 0x94),
813 * errno - api error codes
814 * @E2BIG: A message contains too many records or items.
815 * @EADDRINUSE: A well-known bus name is already taken by another
817 * @EADDRNOTAVAIL: A message flagged not to activate a service, addressed
818 * a service which is not currently running.
819 * @EAGAIN: No messages are queued at the moment.
820 * @EBADF: File descriptors passed with the message are not valid.
821 * @EBADFD: A bus connection is in a corrupted state.
822 * @EBADMSG: Passed data contains a combination of conflicting or
823 * inconsistent types.
824 * @ECOMM: A peer does not accept the file descriptors addressed
826 * @EDESTADDRREQ: The well-known bus name is required but missing.
827 * @EDOM: The size of data does not match the expectations. Used
828 * for the size of the bloom filter bit field.
829 * @EEXIST: A requested namespace, bus or endpoint with the same
830 * name already exists. A specific data type, which is
831 * only expected once, is provided multiple times.
832 * @EFAULT: The supplied memory could not be accessed, or the data
833 * is not properly aligned.
834 * @EINVAL: The provided data does not match its type or other
835 * expectations, like a string which is not NUL terminated,
836 * or a string length that points behind the first
837 * \0-byte in the string.
838 * @EMEDIUMTYPE: A file descriptor which is not a kdbus memfd was
839 * refused to send as KDBUS_MSG_PAYLOAD_MEMFD.
840 * @EMFILE: Too many file descriptors have been supplied with a
842 * @EMSGSIZE: The supplied data is larger than the allowed maximum
844 * @ENAMETOOLONG: The requested name is larger than the allowed maximum
846 * @ENOBUFS: There is no space left for the submitted data to fit
847 * into the receiver's pool.
848 * @ENOMEM: Out of memory.
849 * @ENOSYS: The requested functionality is not available.
850 * @ENOTCONN: The addressed peer is not an active connection.
851 * @ENOTSUPP: The feature negotiation failed, a not supported feature
852 * was requested, or an unknown item type was received.
853 * @ENOTTY: An unknown ioctl command was received.
854 * @ENOTUNIQ: A specific data type was addressed to a broadcast
855 * address, but only direct addresses support this kind of
857 * @ENXIO: A unique address does not exist.
858 * @EPERM: The policy prevented an operation. The requested
859 * resource is owned by another entity.
860 * @ESHUTDOWN: The connection is currently shutting down, no further
861 * operations are possible.
862 * @ESRCH: A requested well-known bus name is not found.
863 * @ETXTBSY: A kdbus memfd file cannot be sealed or the seal removed,
864 * because it is shared with other processes or still
866 * @EXFULL: The size limits in the pool are reached, no data of
867 * the size tried to submit can be queued.