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.
13 * "Everything should be made as simple as possible, but not simpler."
21 #include <sys/ioctl.h>
22 #include <sys/types.h>
23 #include <linux/types.h>
26 #define KDBUS_IOC_MAGIC 0x95
27 #define KDBUS_SRC_ID_KERNEL (0)
28 #define KDBUS_DST_ID_NAME (0)
29 #define KDBUS_MATCH_ID_ANY (~0ULL)
30 #define KDBUS_DST_ID_BROADCAST (~0ULL)
33 * struct kdbus_notify_id_change - name registry change message
34 * @id: New or former owner of the name
35 * @flags: flags field from KDBUS_HELLO_*
37 * Sent from kernel to userspace when the owner or activator of
38 * a well-known name changes.
42 * KDBUS_ITEM_ID_REMOVE
44 struct kdbus_notify_id_change {
50 * struct kdbus_notify_name_change - name registry change message
51 * @old: ID and flags of former owner of a name
52 * @new: ID and flags of new owner of a name
53 * @name: Well-known name
55 * Sent from kernel to userspace when the owner or activator of
56 * a well-known name changes.
60 * KDBUS_ITEM_NAME_REMOVE
61 * KDBUS_ITEM_NAME_CHANGE
63 struct kdbus_notify_name_change {
64 struct kdbus_notify_id_change old;
65 struct kdbus_notify_id_change new;
70 * struct kdbus_creds - process credentials
75 * @starttime: Starttime of the process
77 * The starttime of the process PID. This is useful to detect PID overruns
78 * from the client side. i.e. if you use the PID to look something up in
79 * /proc/$PID/ you can afterwards check the starttime field of it, to ensure
80 * you didn't run into a PID overrun.
94 * struct kdbus_audit - audit information
95 * @sessionid: The audit session ID
96 * @loginuid: The audit login uid
107 * struct kdbus_timestamp
108 * @seqnum: Global per-namespace message sequence number
109 * @monotonic_ns: Monotonic timestamp, in nanoseconds
110 * @realtime_ns: Realtime timestamp, in nanoseconds
113 * KDBUS_ITEM_TIMESTAMP
115 struct kdbus_timestamp {
122 * struct kdbus_vec - I/O vector for kdbus payload items
123 * @size: The size of the vector
124 * @address: Memory address for memory addresses
125 * @offset: Offset in the in-message payload memory,
126 * relative to the message head
129 * KDBUS_ITEM_PAYLOAD_VEC
140 * struct kdbus_memfd - a kdbus memfd
141 * @size: The memfd's size
142 * @fd: The file descriptor number
143 * @__pad: Padding to ensure proper alignement and size
146 * KDBUS_ITEM_PAYLOAD_MEMFD
155 * struct kdbus_name - a registered well-known name with its flags
156 * @flags: flags from KDBUS_NAME_*
157 * @name: well-known name
168 * struct kdbus_policy_access - policy access item
169 * @type: One of KDBUS_POLICY_ACCESS_* types
170 * @bits: Access to grant. One of KDBUS_POLICY_*
171 * @id: For KDBUS_POLICY_ACCESS_USER, the uid
172 * For KDBUS_POLICY_ACCESS_GROUP, the gid
175 * struct kdbus_policy
177 struct kdbus_policy_access {
178 __u64 type; /* USER, GROUP, WORLD */
179 __u64 bits; /* RECV, SEND, OWN */
180 __u64 id; /* uid, gid, 0 */
184 * struct kdbus_policy - a policy item
185 * @access: Policy access details
186 * @name: Well-known name to grant access to
189 * KDBUS_POLICY_ACCESS
190 * KDBUS_ITEM_POLICY_NAME
192 struct kdbus_policy {
194 struct kdbus_policy_access access;
200 * enum kdbus_item_type - item types to chain data in a list
201 * @_KDBUS_ITEM_NULL: Uninitialized/invalid
202 * @_KDBUS_ITEM_USER_BASE: Start of user items
203 * @KDBUS_ITEM_PAYLOAD_VEC: Vector to data
204 * @KDBUS_ITEM_PAYLOAD_OFF: Data at returned offset to message head
205 * @KDBUS_ITEM_PAYLOAD_MEMFD: Data as sealed memfd
206 * @KDBUS_ITEM_FDS: Attached file descriptors
207 * @KDBUS_ITEM_BLOOM: For broadcasts, carries bloom filter
208 * @KDBUS_ITEM_BLOOM_SIZE: Desired bloom size, used by KDBUS_CMD_BUS_MAKE
209 * @KDBUS_ITEM_DST_NAME: Destination's well-known name
210 * @KDBUS_ITEM_MAKE_NAME: Name of namespace, bus, endpoint
211 * @KDBUS_ITEM_MEMFD_NAME: The human readable name of a memfd (debugging)
212 * @_KDBUS_ITEM_POLICY_BASE: Start of policy items
213 * @KDBUS_ITEM_POLICY_NAME: Policy in struct kdbus_policy
214 * @KDBUS_ITEM_POLICY_ACCESS: Policy in struct kdbus_policy
215 * @_KDBUS_ITEM_ATTACH_BASE: Start of metadata attach items
216 * @KDBUS_ITEM_NAME: Well-know name with flags
217 * @KDBUS_ITEM_ID: Connection ID
218 * @KDBUS_ITEM_TIMESTAMP: Timestamp
219 * @KDBUS_ITEM_CREDS: Process credential
220 * @KDBUS_ITEM_PID_COMM: Process ID "comm" identifier
221 * @KDBUS_ITEM_TID_COMM: Thread ID "comm" identifier
222 * @KDBUS_ITEM_EXE: The path of the executable
223 * @KDBUS_ITEM_CMDLINE: The process command line
224 * @KDBUS_ITEM_CGROUP: The croup membership
225 * @KDBUS_ITEM_CAPS: The process capabilities
226 * @KDBUS_ITEM_SECLABEL: The security label
227 * @KDBUS_ITEM_AUDIT: The audit IDs
228 * @KDBUS_ITEM_CONN_NAME: The connection's human-readable name (debugging)
229 * @_KDBUS_ITEM_KERNEL_BASE: Start of kernel-generated message items
230 * @KDBUS_ITEM_NAME_ADD: Notify in struct kdbus_notify_name_change
231 * @KDBUS_ITEM_NAME_REMOVE: Notify in struct kdbus_notify_name_change
232 * @KDBUS_ITEM_NAME_CHANGE: Notify in struct kdbus_notify_name_change
233 * @KDBUS_ITEM_ID_ADD: Notify in struct kdbus_notify_id_change
234 * @KDBUS_ITEM_ID_REMOVE: Notify in struct kdbus_notify_id_change
235 * @KDBUS_ITEM_REPLY_TIMEOUT: Timeout has been reached
236 * @KDBUS_ITEM_REPLY_DEAD: Destination died
238 enum kdbus_item_type {
240 _KDBUS_ITEM_USER_BASE,
241 KDBUS_ITEM_PAYLOAD_VEC = _KDBUS_ITEM_USER_BASE,
242 KDBUS_ITEM_PAYLOAD_OFF,
243 KDBUS_ITEM_PAYLOAD_MEMFD,
246 KDBUS_ITEM_BLOOM_SIZE,
248 KDBUS_ITEM_MAKE_NAME,
249 KDBUS_ITEM_MEMFD_NAME,
251 _KDBUS_ITEM_POLICY_BASE = 0x1000,
252 KDBUS_ITEM_POLICY_NAME = _KDBUS_ITEM_POLICY_BASE,
253 KDBUS_ITEM_POLICY_ACCESS,
255 _KDBUS_ITEM_ATTACH_BASE = 0x2000,
256 KDBUS_ITEM_NAME = _KDBUS_ITEM_ATTACH_BASE,
258 KDBUS_ITEM_TIMESTAMP,
268 KDBUS_ITEM_CONN_NAME,
270 _KDBUS_ITEM_KERNEL_BASE = 0x3000,
271 KDBUS_ITEM_NAME_ADD = _KDBUS_ITEM_KERNEL_BASE,
272 KDBUS_ITEM_NAME_REMOVE,
273 KDBUS_ITEM_NAME_CHANGE,
275 KDBUS_ITEM_ID_REMOVE,
276 KDBUS_ITEM_REPLY_TIMEOUT,
277 KDBUS_ITEM_REPLY_DEAD,
281 * struct kdbus_item - chain of data blocks
282 * @size: Overall data record size
283 * @type: Kdbus_item type of data
284 * @data: Generic bytes
285 * @data32: Generic 32 bit array
286 * @data64: Generic 64 bit array
287 * @str: Generic string
289 * @vec: KDBUS_ITEM_PAYLOAD_VEC
290 * @creds: KDBUS_ITEM_CREDS
291 * @audit: KDBUS_ITEM_AUDIT
292 * @timestamp: KDBUS_ITEM_TIMESTAMP
293 * @name: KDBUS_ITEM_NAME
294 * @memfd: KDBUS_ITEM_PAYLOAD_MEMFD
295 * @name_change: KDBUS_ITEM_NAME_ADD
296 * KDBUS_ITEM_NAME_REMOVE
297 * KDBUS_ITEM_NAME_CHANGE
298 * @id_change: KDBUS_ITEM_ID_ADD
299 * KDBUS_ITEM_ID_REMOVE
300 * @policy: KDBUS_ITEM_POLICY_NAME
301 * KDBUS_ITEM_POLICY_ACCESS
313 struct kdbus_vec vec;
314 struct kdbus_creds creds;
315 struct kdbus_audit audit;
316 struct kdbus_timestamp timestamp;
317 struct kdbus_name name;
318 struct kdbus_memfd memfd;
320 struct kdbus_notify_name_change name_change;
321 struct kdbus_notify_id_change id_change;
322 struct kdbus_policy policy;
327 * enum kdbus_msg_flags - type of message
328 * @KDBUS_MSG_FLAGS_EXPECT_REPLY: Expect a reply message, used for
329 * method calls. The userspace-supplied
330 * cookie identifies the message and the
331 * respective reply carries the cookie
333 * @KDBUS_MSG_FLAGS_SYNC_REPLY: Wait for destination connection to
334 * reply to this message. The
335 * KDBUS_CMD_MSG_SEND ioctl() will block
336 * until the reply is received, and
337 * offset_reply in struct kdbus_msg will
338 * yield the offset in the sender's pool
339 * where the reply can be found.
340 * This flag is only valid if
341 * @KDBUS_MSG_FLAGS_EXPECT_REPLY is set as
343 * @KDBUS_MSG_FLAGS_NO_AUTO_START: Do not start a service, if the addressed
344 * name is not currently active
346 enum kdbus_msg_flags {
347 KDBUS_MSG_FLAGS_EXPECT_REPLY = 1 << 0,
348 KDBUS_MSG_FLAGS_SYNC_REPLY = 1 << 1,
349 KDBUS_MSG_FLAGS_NO_AUTO_START = 1 << 2,
353 * enum kdbus_payload_type - type of payload carried by message
354 * @KDBUS_PAYLOAD_KERNEL: Kernel-generated simple message
355 * @KDBUS_PAYLOAD_DBUS: D-Bus marshalling "DBusDBus"
357 enum kdbus_payload_type {
358 KDBUS_PAYLOAD_KERNEL,
359 KDBUS_PAYLOAD_DBUS = 0x4442757344427573ULL,
363 * struct kdbus_msg - the representation of a kdbus message
364 * @size: Total size of the message
365 * @flags: Message flags (KDBUS_MSG_FLAGS_*)
366 * @priority: Message queue priority value
367 * @dst_id: 64-bit ID of the destination connection
368 * @src_id: 64-bit ID of the source connection
369 * @payload_type: Payload type (KDBUS_PAYLOAD_*)
370 * @cookie: Userspace-supplied cookie, for the connection
371 * to identify its messages
372 * @timeout_ns: The time to wait for a message reply from the peer.
373 * If there is no reply, a kernel-generated message
374 * with an attached KDBUS_ITEM_REPLY_TIMEOUT item
375 * is sent to @src_id.
376 * @cookie_reply: A reply to the requesting message with the same
377 * cookie. The requesting connection can match its
378 * request and the reply with this value
379 * @offset_reply: If KDBUS_MSG_FLAGS_WAIT_FOR_REPLY, this field will
380 * contain the offset in the sender's pool where the
382 * @items: A list of kdbus_items containing the message payload
397 struct kdbus_item items[0];
398 } __attribute__((aligned(8)));
401 * enum kdbus_recv_flags - flags for de-queuing messages
402 * @KDBUS_RECV_PEEK: Return the next queued message without
403 * actually de-queuing it, and without installing
404 * any file descriptors or other resources. It is
405 * usually used to determine the activating
406 * connection of a bus name.
407 * @KDBUS_RECV_DROP: Drop and free the next queued message and all
408 * its resources without actually receiving it.
409 * @KDBUS_RECV_USE_PRIORITY: Only de-queue messages with the specified or
410 * higher priority (lowest values); if not set,
411 * the priority value is ignored.
413 enum kdbus_recv_flags {
414 KDBUS_RECV_PEEK = 1 << 0,
415 KDBUS_RECV_DROP = 1 << 1,
416 KDBUS_RECV_USE_PRIORITY = 1 << 2,
420 * struct kdbus_cmd_recv - struct to de-queue a buffered message
421 * @flags: KDBUS_RECV_* flags
422 * @priority: Minimum priority of the messages to de-queue. Lowest
423 * values have the highest priority.
424 * @offset: Returned offset in the pool where the message is
425 * stored. The user must use KDBUS_CMD_FREE to free
426 * the allocated memory.
428 * This struct is used with the KDBUS_CMD_MSG_RECV ioctl.
430 struct kdbus_cmd_recv {
434 } __attribute__((aligned(8)));
437 * enum kdbus_policy_access_type - permissions of a policy record
438 * @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid
439 * @KDBUS_POLICY_ACCESS_USER: Grant access to a uid
440 * @KDBUS_POLICY_ACCESS_GROUP: Grant access to gid
441 * @KDBUS_POLICY_ACCESS_WORLD: World-accessible
443 enum kdbus_policy_access_type {
444 _KDBUS_POLICY_ACCESS_NULL,
445 KDBUS_POLICY_ACCESS_USER,
446 KDBUS_POLICY_ACCESS_GROUP,
447 KDBUS_POLICY_ACCESS_WORLD,
451 * enum kdbus_policy_access_flags - mode flags
452 * @KDBUS_POLICY_RECV: Allow receive
453 * @KDBUS_POLICY_SEND: Allow send
454 * @KDBUS_POLICY_OWN: Allow to own a well-known name
456 enum kdbus_policy_type {
457 KDBUS_POLICY_RECV = 1 << 2,
458 KDBUS_POLICY_SEND = 1 << 1,
459 KDBUS_POLICY_OWN = 1 << 0,
463 * struct kdbus_cmd_policy - a series of policies to upload
464 * @size: The total size of the structure
465 * @policies: The policies to upload
467 * A KDBUS_POLICY_NAME must always preceeds a KDBUS_POLICY_ACCESS entry.
468 * A new KDBUS_POLICY_NAME can be added after KDBUS_POLICY_ACCESS for
469 * chaining multiple policies together.
471 struct kdbus_cmd_policy {
473 struct kdbus_item policies[0];
474 } __attribute__((aligned(8)));
477 * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello
478 * @KDBUS_HELLO_ACCEPT_FD: The connection allows the receiving of
479 * any passed file descriptors
480 * @KDBUS_HELLO_ACTIVATOR: Special-purpose connection which registers
481 * a well-know name for a process to be started
482 * when traffic arrives
483 * @KDBUS_HELLO_MONITOR: Special-purpose connection to monitor
486 enum kdbus_hello_flags {
487 KDBUS_HELLO_ACCEPT_FD = 1 << 0,
488 KDBUS_HELLO_ACTIVATOR = 1 << 1,
489 KDBUS_HELLO_MONITOR = 1 << 2,
493 * enum kdbus_attach_flags - flags for metadata attachments
494 * @KDBUS_ATTACH_TIMESTAMP: Timestamp
495 * @KDBUS_ATTACH_CREDS: Credentials
496 * @KDBUS_ATTACH_NAMES: Well-known names
497 * @KDBUS_ATTACH_COMM: The "comm" process identifier
498 * @KDBUS_ATTACH_EXE: The path of the executable
499 * @KDBUS_ATTACH_CMDLINE: The process command line
500 * @KDBUS_ATTACH_CGROUP: The croup membership
501 * @KDBUS_ATTACH_CAPS: The process capabilities
502 * @KDBUS_ATTACH_SECLABEL: The security label
503 * @KDBUS_ATTACH_AUDIT: The audit IDs
504 * @KDBUS_ATTACH_CONN_NAME: The human-readable connection name
506 enum kdbus_attach_flags {
507 KDBUS_ATTACH_TIMESTAMP = 1 << 0,
508 KDBUS_ATTACH_CREDS = 1 << 1,
509 KDBUS_ATTACH_NAMES = 1 << 2,
510 KDBUS_ATTACH_COMM = 1 << 3,
511 KDBUS_ATTACH_EXE = 1 << 4,
512 KDBUS_ATTACH_CMDLINE = 1 << 5,
513 KDBUS_ATTACH_CGROUP = 1 << 6,
514 KDBUS_ATTACH_CAPS = 1 << 7,
515 KDBUS_ATTACH_SECLABEL = 1 << 8,
516 KDBUS_ATTACH_AUDIT = 1 << 9,
517 KDBUS_ATTACH_CONN_NAME = 1 << 10,
521 * struct kdbus_cmd_hello - struct to say hello to kdbus
522 * @size: The total size of the structure
523 * @conn_flags: Connection flags (KDBUS_HELLO_*). The kernel will
524 * return its capabilities in that field.
525 * @attach_flags: Mask of metadata to attach to each message sent
527 * @bus_flags: The flags field copied verbatim from the original
528 * KDBUS_CMD_BUS_MAKE ioctl. It's intended to be useful
529 * to do negotiation of features of the payload that is
530 * transferred (kernel → userspace)
531 * @id: The ID of this connection (kernel → userspace)
532 * @bloom_size: The bloom filter size chosen by the owner
533 * (kernel → userspace)
534 * @pool_size: Size of the connection's buffer where the received
535 * messages are placed
536 * @id128: Unique 128-bit ID of the bus (kernel → userspace)
537 * @items: A list of items
539 * This struct is used with the KDBUS_CMD_HELLO ioctl.
541 struct kdbus_cmd_hello {
550 struct kdbus_item items[0];
551 } __attribute__((aligned(8)));
553 /* Flags for KDBUS_CMD_{BUS,EP,NS}_MAKE */
554 enum kdbus_make_flags {
555 KDBUS_MAKE_ACCESS_GROUP = 1 << 0,
556 KDBUS_MAKE_ACCESS_WORLD = 1 << 1,
557 KDBUS_MAKE_POLICY_OPEN = 1 << 2,
561 * struct kdbus_cmd_make - struct to make a bus, an endpoint or a namespace
562 * @size: The total size of the struct
563 * @flags: Properties for the bus/ep/ns to create
564 * @items: Items describing details
566 * This structure is used with the KDBUS_CMD_BUS_MAKE, KDBUS_CMD_EP_MAKE and
567 * KDBUS_CMD_NS_MAKE ioctls.
569 struct kdbus_cmd_make {
572 struct kdbus_item items[0];
573 } __attribute__((aligned(8)));
576 * enum kdbus_name_flags - properties of a well-known name
577 * @KDBUS_NAME_REPLACE_EXISTING: Try to replace name of other connections
578 * @KDBUS_NAME_ALLOW_REPLACEMENT: Allow the replacement of the name
579 * @KDBUS_NAME_QUEUE: Name should be queued if busy
580 * @KDBUS_NAME_IN_QUEUE: Name is queued
581 * @KDBUS_NAME_ACTIVATOR: Name is owned by a activator connection
583 enum kdbus_name_flags {
584 KDBUS_NAME_REPLACE_EXISTING = 1 << 0,
585 KDBUS_NAME_ALLOW_REPLACEMENT = 1 << 1,
586 KDBUS_NAME_QUEUE = 1 << 2,
587 KDBUS_NAME_IN_QUEUE = 1 << 3,
588 KDBUS_NAME_ACTIVATOR = 1 << 4,
592 * struct kdbus_cmd_name - struct to describe a well-known name
593 * @size: The total size of the struct
594 * @flags: Flags for a name entry (KDBUS_NAME_*)
595 * @owner_id: The current owner of the name. For requests,
596 * privileged users may set this field to
597 * (de)register names on behalf of other connections.
598 * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*)
599 * @name: The well-known name
601 * This structure is used with the KDBUS_CMD_NAME_ACQUIRE ioctl.
603 struct kdbus_cmd_name {
609 } __attribute__((aligned(8)));
612 * enum kdbus_name_list_flags - what to include into the returned list
613 * @KDBUS_NAME_LIST_UNIQUE: All active connections
614 * @KDBUS_NAME_LIST_NAMES: All known well-known names
615 * @KDBUS_NAME_LIST_ACTIVATORS: All activator connections
616 * @KDBUS_NAME_LIST_QUEUED: All queued-up names
618 enum kdbus_name_list_flags {
619 KDBUS_NAME_LIST_UNIQUE = 1 << 0,
620 KDBUS_NAME_LIST_NAMES = 1 << 1,
621 KDBUS_NAME_LIST_ACTIVATORS = 1 << 2,
622 KDBUS_NAME_LIST_QUEUED = 1 << 3,
626 * struct kdbus_cmd_name_list - request a list of name entries
627 * @flags: Flags for the query (KDBUS_NAME_LIST_*)
628 * @offset: The returned offset in the caller's pool buffer.
629 * The user must use KDBUS_CMD_FREE to free the
632 * This structure is used with the KDBUS_CMD_NAME_LIST ioctl.
634 struct kdbus_cmd_name_list {
637 } __attribute__((aligned(8)));
640 * struct kdbus_name_list - information returned by KDBUS_CMD_NAME_LIST
641 * @size: The total size of the structure
642 * @names: A list of names
644 * Note that the user is responsible for freeing the allocated memory with
645 * the KDBUS_CMD_FREE ioctl.
647 struct kdbus_name_list {
649 struct kdbus_cmd_name names[0];
653 * struct kdbus_cmd_conn_info - struct used for KDBUS_CMD_CONN_INFO ioctl
654 * @size: The total size of the struct
655 * @flags: KDBUS_ATTACH_* flags
656 * @id: The 64-bit ID of the connection. If set to zero, passing
657 * @name is required. kdbus will look up the name to
658 * determine the ID in this case.
659 * @offset: Returned offset in the caller's pool buffer where the
660 * kdbus_conn_info struct result is stored. The user must
661 * use KDBUS_CMD_FREE to free the allocated memory.
662 * @name: The optional well-known name to look up. Only needed in
665 * On success, the KDBUS_CMD_CONN_INFO ioctl will return 0 and @offset will
666 * tell the user the offset in the connection pool buffer at which to find the
667 * result in a struct kdbus_conn_info.
669 struct kdbus_cmd_conn_info {
675 } __attribute__((aligned(8)));
678 * struct kdbus_conn_info - information returned by KDBUS_CMD_CONN_INFO
679 * @size: The total size of the struct
680 * @id: The connection's 64-bit ID
681 * @flags: The connection's flags
682 * @items: A list of struct kdbus_item
684 * Note that the user is responsible for freeing the allocated memory with
685 * the KDBUS_CMD_FREE ioctl.
687 struct kdbus_conn_info {
691 struct kdbus_item items[0];
695 * struct kdbus_cmd_match - struct to add or remove matches
696 * @size: The total size of the struct
697 * @owner_id: Privileged users may (de)register matches on behalf
699 * @cookie: Userspace supplied cookie. When removing, the cookie
700 * identifies the match to remove
701 * @items: A list of items for additional information
703 * This structure is used with the KDBUS_CMD_ADD_MATCH and
704 * KDBUS_CMD_REMOVE_MATCH ioctl.
706 struct kdbus_cmd_match {
710 struct kdbus_item items[0];
711 } __attribute__((aligned(8)));
714 * struct kdbus_cmd_memfd_make - create a kdbus memfd
715 * @size: The total size of the struct
716 * @file_size: The initial file size
717 * @fd: The returned file descriptor number
718 * @__pad: Padding to ensure proper alignement
719 * @items: A list of items for additional information
721 * This structure is used with the KDBUS_CMD_MEMFD_NEW ioctl.
723 struct kdbus_cmd_memfd_make {
728 struct kdbus_item items[0];
729 } __attribute__((aligned(8)));
732 * enum kdbus_ioctl_type - Ioctl API
733 * @KDBUS_CMD_BUS_MAKE: After opening the "control" device node, this
734 * command creates a new bus with the specified
735 * name. The bus is immediately shut down and
736 * cleaned up when the opened "control" device node
738 * @KDBUS_CMD_NS_MAKE: Similar to KDBUS_CMD_BUS_MAKE, but it creates a
739 * new kdbus namespace.
740 * @KDBUS_CMD_EP_MAKE: Creates a new named special endpoint to talk to
741 * the bus. Such endpoints usually carry a more
742 * restrictive policy and grant restricted access
743 * to specific applications.
744 * @KDBUS_CMD_HELLO: By opening the bus device node a connection is
745 * created. After a HELLO the opened connection
746 * becomes an active peer on the bus.
747 * @KDBUS_CMD_BYEBYE: Disconnect a connection. If the connection's
748 * message list is empty, the calls succeeds, and
749 * the handle is rendered unusable. Otherwise,
750 * -EAGAIN is returned without any further side-
752 * @KDBUS_CMD_MSG_SEND: Send a message and pass data from userspace to
754 * @KDBUS_CMD_MSG_RECV: Receive a message from the kernel which is
755 * placed in the receiver's pool.
756 * @KDBUS_CMD_FREE: Release the allocated memory in the receiver's
758 * @KDBUS_CMD_NAME_ACQUIRE: Request a well-known bus name to associate with
759 * the connection. Well-known names are used to
760 * address a peer on the bus.
761 * @KDBUS_CMD_NAME_RELEASE: Release a well-known name the connection
763 * @KDBUS_CMD_NAME_LIST: Retrieve the list of all currently registered
764 * well-known and unique names.
765 * @KDBUS_CMD_CONN_INFO: Retrieve credentials and properties of the
766 * initial creator of the connection. The data was
767 * stored at registration time and does not
768 * necessarily represent the connected process or
769 * the actual state of the process.
770 * @KDBUS_CMD_MATCH_ADD: Install a match which broadcast messages should
771 * be delivered to the connection.
772 * @KDBUS_CMD_MATCH_REMOVE: Remove a current match for broadcast messages.
773 * @KDBUS_CMD_EP_POLICY_SET: Set the policy of an endpoint. It is used to
774 * restrict the access for endpoints created with
776 * @KDBUS_CMD_MEMFD_NEW: Return a new file descriptor which provides an
777 * anonymous shared memory file and which can be
778 * used to pass around larger chunks of data.
779 * Kdbus memfd files can be sealed, which allows
780 * the receiver to trust the data it has received.
781 * Kdbus memfd files expose only very limited
782 * operations, they can be mmap()ed, seek()ed,
783 * (p)read(v)() and (p)write(v)(); most other
784 * common file operations are not implemented.
785 * Special caution needs to be taken with
786 * read(v)()/write(v)() on a shared file; the
787 * underlying file position is always shared
788 * between all users of the file and race against
789 * each other, pread(v)()/pwrite(v)() avoid these
791 * @KDBUS_CMD_MEMFD_SIZE_GET: Return the size of the underlying file, which
792 * changes with write().
793 * @KDBUS_CMD_MEMFD_SIZE_SET: Truncate the underlying file to the specified
795 * @KDBUS_CMD_MEMFD_SEAL_GET: Return the state of the file sealing.
796 * @KDBUS_CMD_MEMFD_SEAL_SET: Seal or break a seal of the file. Only files
797 * which are not shared with other processes and
798 * which are currently not mapped can be sealed.
799 * The current process needs to be the one and
800 * single owner of the file, the sealing cannot
801 * be changed as long as the file is shared.
803 enum kdbus_ioctl_type {
804 KDBUS_CMD_BUS_MAKE = _IOW (KDBUS_IOC_MAGIC, 0x00, struct kdbus_cmd_make),
805 KDBUS_CMD_NS_MAKE = _IOR (KDBUS_IOC_MAGIC, 0x10, struct kdbus_cmd_make),
806 KDBUS_CMD_EP_MAKE = _IOW (KDBUS_IOC_MAGIC, 0x20, struct kdbus_cmd_make),
808 KDBUS_CMD_HELLO = _IOWR(KDBUS_IOC_MAGIC, 0x30, struct kdbus_cmd_hello),
809 KDBUS_CMD_BYEBYE = _IO (KDBUS_IOC_MAGIC, 0x31),
811 KDBUS_CMD_MSG_SEND = _IOW (KDBUS_IOC_MAGIC, 0x40, struct kdbus_msg),
812 KDBUS_CMD_MSG_RECV = _IOWR(KDBUS_IOC_MAGIC, 0x41, struct kdbus_cmd_recv),
813 KDBUS_CMD_FREE = _IOW (KDBUS_IOC_MAGIC, 0x42, __u64 *),
815 KDBUS_CMD_NAME_ACQUIRE = _IOWR(KDBUS_IOC_MAGIC, 0x50, struct kdbus_cmd_name),
816 KDBUS_CMD_NAME_RELEASE = _IOW (KDBUS_IOC_MAGIC, 0x51, struct kdbus_cmd_name),
817 KDBUS_CMD_NAME_LIST = _IOWR(KDBUS_IOC_MAGIC, 0x52, struct kdbus_cmd_name_list),
819 KDBUS_CMD_CONN_INFO = _IOWR(KDBUS_IOC_MAGIC, 0x60, struct kdbus_cmd_conn_info),
821 KDBUS_CMD_MATCH_ADD = _IOW (KDBUS_IOC_MAGIC, 0x70, struct kdbus_cmd_match),
822 KDBUS_CMD_MATCH_REMOVE = _IOW (KDBUS_IOC_MAGIC, 0x71, struct kdbus_cmd_match),
824 KDBUS_CMD_EP_POLICY_SET = _IOW (KDBUS_IOC_MAGIC, 0x80, struct kdbus_cmd_policy),
826 KDBUS_CMD_MEMFD_NEW = _IOWR(KDBUS_IOC_MAGIC, 0xc0, struct kdbus_cmd_memfd_make),
827 KDBUS_CMD_MEMFD_SIZE_GET = _IOR (KDBUS_IOC_MAGIC, 0xc1, __u64 *),
828 KDBUS_CMD_MEMFD_SIZE_SET = _IOW (KDBUS_IOC_MAGIC, 0xc2, __u64 *),
829 KDBUS_CMD_MEMFD_SEAL_GET = _IOR (KDBUS_IOC_MAGIC, 0xc3, int *),
830 KDBUS_CMD_MEMFD_SEAL_SET = _IO (KDBUS_IOC_MAGIC, 0xc4),
834 * errno - api error codes
835 * @E2BIG: A message contains too many records or items.
836 * @EADDRINUSE: A well-known bus name is already taken by another
838 * @EADDRNOTAVAIL: A message flagged not to activate a service, addressed
839 * a service which is not currently running.
840 * @EAGAIN: No messages are queued at the moment.
841 * @EBADF: File descriptors passed with the message are not valid.
842 * @EBADFD: A bus connection is in a corrupted state.
843 * @EBADMSG: Passed data contains a combination of conflicting or
844 * inconsistent types.
845 * @EBUSY: The user tried to say BYEBYE to a connection, but the
846 * connection had a non-empty message list.
847 * @ECONNRESET: A connection is shut down, no further operations are
849 * @ECOMM: A peer does not accept the file descriptors addressed
851 * @EDESTADDRREQ: The well-known bus name is required but missing.
852 * @EDOM: The size of data does not match the expectations. Used
853 * for the size of the bloom filter bit field.
854 * @EEXIST: A requested namespace, bus or endpoint with the same
855 * name already exists. A specific data type, which is
856 * only expected once, is provided multiple times.
857 * @EFAULT: The supplied memory could not be accessed, or the data
858 * is not properly aligned.
859 * @EINVAL: The provided data does not match its type or other
860 * expectations, like a string which is not NUL terminated,
861 * or a string length that points behind the first
862 * \0-byte in the string.
863 * @EMEDIUMTYPE: A file descriptor which is not a kdbus memfd was
864 * refused to send as KDBUS_MSG_PAYLOAD_MEMFD.
865 * @EMFILE: Too many file descriptors have been supplied with a
867 * @EMLINK: Too many requests from this connection to other peers
868 * are queued and waiting for a reply
869 * @EMSGSIZE: The supplied data is larger than the allowed maximum
871 * @ENAMETOOLONG: The requested name is larger than the allowed maximum
873 * @ENOBUFS: There is no space left for the submitted data to fit
874 * into the receiver's pool.
875 * @ENOENT: The name to query information about is currently not on
877 * @ENOMEM: Out of memory.
878 * @ENOMSG: The queue is not empty, but no message with a matching
879 * priority is currently queued.
880 * @ENOSYS: The requested functionality is not available.
881 * @ENOTSUPP: The feature negotiation failed, a not supported feature
882 * was requested, or an unknown item type was received.
883 * @ENOTTY: An unknown ioctl command was received.
884 * @ENOTUNIQ: A specific data type was addressed to a broadcast
885 * address, but only direct addresses support this kind of
887 * @ENXIO: A unique address does not exist, or an offset in the
888 * receiver's pool does not represent a queued message.
889 * @EPERM: The policy prevented an operation. The requested
890 * resource is owned by another entity.
891 * @ESHUTDOWN: A namespace or endpoint is currently shutting down;
892 * no further operations will be possible.
893 * @ESRCH: A requested well-known bus name is not found.
894 * @ETXTBSY: A kdbus memfd file cannot be sealed or the seal removed,
895 * because it is shared with other processes or still
897 * @EXFULL: The size limits in the pool are reached, no data of
898 * the size tried to submit can be queued.