]>
Commit | Line | Data |
---|---|---|
6629161f | 1 | /* |
6629161f LP |
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. | |
6 | */ | |
7 | ||
913b6d70 DM |
8 | #ifndef _KDBUS_UAPI_H_ |
9 | #define _KDBUS_UAPI_H_ | |
6629161f | 10 | |
f8c24252 | 11 | #include <linux/ioctl.h> |
6629161f | 12 | #include <linux/types.h> |
6629161f | 13 | |
dec51b29 | 14 | #define KDBUS_IOCTL_MAGIC 0x95 |
9b3848f2 | 15 | #define KDBUS_SRC_ID_KERNEL (0) |
144e9e58 | 16 | #define KDBUS_DST_ID_NAME (0) |
73842d62 | 17 | #define KDBUS_MATCH_ID_ANY (~0ULL) |
9b3848f2 | 18 | #define KDBUS_DST_ID_BROADCAST (~0ULL) |
4a3e79e1 | 19 | #define KDBUS_FLAG_KERNEL (1ULL << 63) |
9b3848f2 | 20 | |
ceceaf09 DM |
21 | /** |
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_* | |
25 | * | |
26 | * Sent from kernel to userspace when the owner or activator of | |
27 | * a well-known name changes. | |
28 | * | |
29 | * Attached to: | |
30 | * KDBUS_ITEM_ID_ADD | |
31 | * KDBUS_ITEM_ID_REMOVE | |
32 | */ | |
33 | struct kdbus_notify_id_change { | |
34 | __u64 id; | |
35 | __u64 flags; | |
36 | }; | |
37 | ||
f7d85951 KS |
38 | /** |
39 | * struct kdbus_notify_name_change - name registry change message | |
590889ac DM |
40 | * @old_id: ID and flags of former owner of a name |
41 | * @new_id: ID and flags of new owner of a name | |
a8d4cac5 | 42 | * @name: Well-known name |
f7d85951 | 43 | * |
07442eff | 44 | * Sent from kernel to userspace when the owner or activator of |
5e16c257 KS |
45 | * a well-known name changes. |
46 | * | |
47 | * Attached to: | |
f7d85951 KS |
48 | * KDBUS_ITEM_NAME_ADD |
49 | * KDBUS_ITEM_NAME_REMOVE | |
50 | * KDBUS_ITEM_NAME_CHANGE | |
f7d85951 | 51 | */ |
8bd54e89 | 52 | struct kdbus_notify_name_change { |
619d7a03 DM |
53 | struct kdbus_notify_id_change old_id; |
54 | struct kdbus_notify_id_change new_id; | |
6629161f LP |
55 | char name[0]; |
56 | }; | |
57 | ||
f7d85951 KS |
58 | /** |
59 | * struct kdbus_creds - process credentials | |
a8d4cac5 | 60 | * @uid: User ID |
705a415f LP |
61 | * @euid: Effective UID |
62 | * @suid: Saved UID | |
63 | * @fsuid: Filesystem UID | |
a8d4cac5 | 64 | * @gid: Group ID |
705a415f LP |
65 | * @egid: Effective GID |
66 | * @sgid: Saved GID | |
67 | * @fsgid: Filesystem GID | |
5e16c257 KS |
68 | * |
69 | * Attached to: | |
70 | * KDBUS_ITEM_CREDS | |
f7d85951 | 71 | */ |
6629161f | 72 | struct kdbus_creds { |
affc7fe9 DH |
73 | __u32 uid; |
74 | __u32 euid; | |
75 | __u32 suid; | |
76 | __u32 fsuid; | |
77 | __u32 gid; | |
78 | __u32 egid; | |
79 | __u32 sgid; | |
80 | __u32 fsgid; | |
705a415f LP |
81 | }; |
82 | ||
83 | /** | |
84 | * struct kdbus_pids - process identifiers | |
85 | * @pid: Process ID | |
86 | * @tid: Thread ID | |
94e15fdc | 87 | * @ppid: Parent process ID |
705a415f | 88 | * |
32802361 | 89 | * The PID and TID of a process. |
705a415f LP |
90 | * |
91 | * Attached to: | |
92 | * KDBUS_ITEM_PIDS | |
93 | */ | |
94 | struct kdbus_pids { | |
6629161f LP |
95 | __u64 pid; |
96 | __u64 tid; | |
94e15fdc | 97 | __u64 ppid; |
6629161f LP |
98 | }; |
99 | ||
5ebe2ce7 DM |
100 | /** |
101 | * struct kdbus_caps - process capabilities | |
102 | * @last_cap: Highest currently known capability bit | |
103 | * @caps: Variable number of 32-bit capabilities flags | |
104 | * | |
105 | * Contains a variable number of 32-bit capabilities flags. | |
106 | * | |
107 | * Attached to: | |
108 | * KDBUS_ITEM_CAPS | |
109 | */ | |
110 | struct kdbus_caps { | |
111 | __u32 last_cap; | |
112 | __u32 caps[0]; | |
113 | }; | |
114 | ||
c85a5a24 DM |
115 | /** |
116 | * struct kdbus_audit - audit information | |
a8d4cac5 KS |
117 | * @sessionid: The audit session ID |
118 | * @loginuid: The audit login uid | |
5e16c257 KS |
119 | * |
120 | * Attached to: | |
121 | * KDBUS_ITEM_AUDIT | |
c85a5a24 | 122 | */ |
5b7d4c1c | 123 | struct kdbus_audit { |
d108ddf1 LP |
124 | __u32 sessionid; |
125 | __u32 loginuid; | |
5b7d4c1c LP |
126 | }; |
127 | ||
c85a5a24 DM |
128 | /** |
129 | * struct kdbus_timestamp | |
486e99a3 | 130 | * @seqnum: Global per-domain message sequence number |
c85a5a24 DM |
131 | * @monotonic_ns: Monotonic timestamp, in nanoseconds |
132 | * @realtime_ns: Realtime timestamp, in nanoseconds | |
5e16c257 KS |
133 | * |
134 | * Attached to: | |
135 | * KDBUS_ITEM_TIMESTAMP | |
c85a5a24 | 136 | */ |
69aec65c | 137 | struct kdbus_timestamp { |
95970860 | 138 | __u64 seqnum; |
69aec65c LP |
139 | __u64 monotonic_ns; |
140 | __u64 realtime_ns; | |
141 | }; | |
142 | ||
c85a5a24 DM |
143 | /** |
144 | * struct kdbus_vec - I/O vector for kdbus payload items | |
e63bb33d | 145 | * @size: The size of the vector |
f8c24252 | 146 | * @address: Memory address of data buffer |
ec76ec1f | 147 | * @offset: Offset in the in-message payload memory, |
95970860 | 148 | * relative to the message head |
5e16c257 KS |
149 | * |
150 | * Attached to: | |
913b6d70 | 151 | * KDBUS_ITEM_PAYLOAD_VEC, KDBUS_ITEM_PAYLOAD_OFF |
c85a5a24 | 152 | */ |
9b3848f2 | 153 | struct kdbus_vec { |
9b3848f2 | 154 | __u64 size; |
62b3e928 KS |
155 | union { |
156 | __u64 address; | |
157 | __u64 offset; | |
158 | }; | |
9b3848f2 KS |
159 | }; |
160 | ||
18a28147 KS |
161 | /** |
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) | |
165 | */ | |
166 | struct kdbus_bloom_parameter { | |
167 | __u64 size; | |
168 | __u64 n_hash; | |
169 | }; | |
170 | ||
171 | /** | |
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 | |
175 | */ | |
176 | struct kdbus_bloom_filter { | |
177 | __u64 generation; | |
178 | __u64 data[0]; | |
179 | }; | |
180 | ||
c85a5a24 DM |
181 | /** |
182 | * struct kdbus_memfd - a kdbus memfd | |
77adde63 DH |
183 | * @start: The offset into the memfd where the segment starts |
184 | * @size: The size of the memfd segment | |
e63bb33d | 185 | * @fd: The file descriptor number |
f8c24252 | 186 | * @__pad: Padding to ensure proper alignment and size |
5e16c257 KS |
187 | * |
188 | * Attached to: | |
189 | * KDBUS_ITEM_PAYLOAD_MEMFD | |
c85a5a24 | 190 | */ |
9b3848f2 | 191 | struct kdbus_memfd { |
77adde63 | 192 | __u64 start; |
9b3848f2 KS |
193 | __u64 size; |
194 | int fd; | |
1a2a4cf2 | 195 | __u32 __pad; |
9b3848f2 | 196 | }; |
6629161f | 197 | |
65dae17a KS |
198 | /** |
199 | * struct kdbus_name - a registered well-known name with its flags | |
f9d12d44 LP |
200 | * @flags: Flags from KDBUS_NAME_* |
201 | * @name: Well-known name | |
5e16c257 KS |
202 | * |
203 | * Attached to: | |
635f9f0d | 204 | * KDBUS_ITEM_OWNED_NAME |
65dae17a KS |
205 | */ |
206 | struct kdbus_name { | |
207 | __u64 flags; | |
208 | char name[0]; | |
209 | }; | |
210 | ||
a8d4cac5 KS |
211 | /** |
212 | * struct kdbus_policy_access - policy access item | |
213 | * @type: One of KDBUS_POLICY_ACCESS_* types | |
f9d12d44 | 214 | * @access: Access to grant |
a8d4cac5 | 215 | * @id: For KDBUS_POLICY_ACCESS_USER, the uid |
95970860 | 216 | * For KDBUS_POLICY_ACCESS_GROUP, the gid |
a8d4cac5 KS |
217 | */ |
218 | struct kdbus_policy_access { | |
219 | __u64 type; /* USER, GROUP, WORLD */ | |
f7c7cd03 | 220 | __u64 access; /* OWN, TALK, SEE */ |
a8d4cac5 KS |
221 | __u64 id; /* uid, gid, 0 */ |
222 | }; | |
223 | ||
4ccbc146 KS |
224 | /** |
225 | * enum kdbus_item_type - item types to chain data in a list | |
d704fda9 DM |
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 | |
6ad9bb71 DM |
232 | * @KDBUS_ITEM_CANCEL_FD: FD used to cancel a synchronous |
233 | * operation by writing to it from | |
234 | * userspace | |
d704fda9 DM |
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 | |
241 | * kdbus_bloom_filter | |
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 | |
705a415f LP |
255 | * @KDBUS_ITEM_CREDS: Process credentials |
256 | * @KDBUS_ITEM_PIDS: Process identifiers | |
d704fda9 DM |
257 | * @KDBUS_ITEM_AUXGROUPS: Auxiliary process groups |
258 | * @KDBUS_ITEM_OWNED_NAME: A name owned by the associated | |
259 | * connection | |
260 | * @KDBUS_ITEM_TID_COMM: Thread ID "comm" identifier | |
705a415f | 261 | * (Don't trust this, see below.) |
d704fda9 | 262 | * @KDBUS_ITEM_PID_COMM: Process ID "comm" identifier |
705a415f | 263 | * (Don't trust this, see below.) |
d704fda9 | 264 | * @KDBUS_ITEM_EXE: The path of the executable |
705a415f | 265 | * (Don't trust this, see below.) |
d704fda9 | 266 | * @KDBUS_ITEM_CMDLINE: The process command line |
705a415f | 267 | * (Don't trust this, see below.) |
d704fda9 DM |
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 | |
273 | * (debugging) | |
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 | |
705a415f LP |
284 | * |
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 | |
289 | * records. | |
4ccbc146 | 290 | */ |
5e16c257 | 291 | enum kdbus_item_type { |
ea1edece | 292 | _KDBUS_ITEM_NULL, |
a8d4cac5 | 293 | _KDBUS_ITEM_USER_BASE, |
4ccbc146 KS |
294 | KDBUS_ITEM_PAYLOAD_VEC = _KDBUS_ITEM_USER_BASE, |
295 | KDBUS_ITEM_PAYLOAD_OFF, | |
296 | KDBUS_ITEM_PAYLOAD_MEMFD, | |
297 | KDBUS_ITEM_FDS, | |
6ad9bb71 | 298 | KDBUS_ITEM_CANCEL_FD, |
18a28147 KS |
299 | KDBUS_ITEM_BLOOM_PARAMETER, |
300 | KDBUS_ITEM_BLOOM_FILTER, | |
301 | KDBUS_ITEM_BLOOM_MASK, | |
4ccbc146 | 302 | KDBUS_ITEM_DST_NAME, |
5e16c257 | 303 | KDBUS_ITEM_MAKE_NAME, |
d704fda9 DM |
304 | KDBUS_ITEM_ATTACH_FLAGS_SEND, |
305 | KDBUS_ITEM_ATTACH_FLAGS_RECV, | |
635f9f0d DM |
306 | KDBUS_ITEM_ID, |
307 | KDBUS_ITEM_NAME, | |
6629161f | 308 | |
635f9f0d | 309 | /* keep these item types in sync with KDBUS_ATTACH_* flags */ |
18a28147 | 310 | _KDBUS_ITEM_ATTACH_BASE = 0x1000, |
635f9f0d | 311 | KDBUS_ITEM_TIMESTAMP = _KDBUS_ITEM_ATTACH_BASE, |
5e16c257 | 312 | KDBUS_ITEM_CREDS, |
48eaba35 | 313 | KDBUS_ITEM_PIDS, |
15aa9b20 | 314 | KDBUS_ITEM_AUXGROUPS, |
635f9f0d | 315 | KDBUS_ITEM_OWNED_NAME, |
5e16c257 | 316 | KDBUS_ITEM_TID_COMM, |
635f9f0d | 317 | KDBUS_ITEM_PID_COMM, |
5e16c257 KS |
318 | KDBUS_ITEM_EXE, |
319 | KDBUS_ITEM_CMDLINE, | |
320 | KDBUS_ITEM_CGROUP, | |
321 | KDBUS_ITEM_CAPS, | |
322 | KDBUS_ITEM_SECLABEL, | |
323 | KDBUS_ITEM_AUDIT, | |
635f9f0d | 324 | KDBUS_ITEM_CONN_DESCRIPTION, |
5e16c257 | 325 | |
18a28147 | 326 | _KDBUS_ITEM_POLICY_BASE = 0x2000, |
f7c7cd03 | 327 | KDBUS_ITEM_POLICY_ACCESS = _KDBUS_ITEM_POLICY_BASE, |
18a28147 KS |
328 | |
329 | _KDBUS_ITEM_KERNEL_BASE = 0x8000, | |
a8d4cac5 | 330 | KDBUS_ITEM_NAME_ADD = _KDBUS_ITEM_KERNEL_BASE, |
4ccbc146 KS |
331 | KDBUS_ITEM_NAME_REMOVE, |
332 | KDBUS_ITEM_NAME_CHANGE, | |
333 | KDBUS_ITEM_ID_ADD, | |
334 | KDBUS_ITEM_ID_REMOVE, | |
335 | KDBUS_ITEM_REPLY_TIMEOUT, | |
336 | KDBUS_ITEM_REPLY_DEAD, | |
6629161f LP |
337 | }; |
338 | ||
5e16c257 | 339 | /** |
c85a5a24 | 340 | * struct kdbus_item - chain of data blocks |
5e16c257 KS |
341 | * @size: Overall data record size |
342 | * @type: Kdbus_item type of data | |
343 | * @data: Generic bytes | |
344 | * @data32: Generic 32 bit array | |
345 | * @data64: Generic 64 bit array | |
346 | * @str: Generic string | |
347 | * @id: Connection ID | |
348 | * @vec: KDBUS_ITEM_PAYLOAD_VEC | |
349 | * @creds: KDBUS_ITEM_CREDS | |
350 | * @audit: KDBUS_ITEM_AUDIT | |
351 | * @timestamp: KDBUS_ITEM_TIMESTAMP | |
352 | * @name: KDBUS_ITEM_NAME | |
18a28147 KS |
353 | * @bloom_parameter: KDBUS_ITEM_BLOOM_PARAMETER |
354 | * @bloom_filter: KDBUS_ITEM_BLOOM_FILTER | |
5e16c257 KS |
355 | * @memfd: KDBUS_ITEM_PAYLOAD_MEMFD |
356 | * @name_change: KDBUS_ITEM_NAME_ADD | |
95970860 KS |
357 | * KDBUS_ITEM_NAME_REMOVE |
358 | * KDBUS_ITEM_NAME_CHANGE | |
5e16c257 | 359 | * @id_change: KDBUS_ITEM_ID_ADD |
95970860 | 360 | * KDBUS_ITEM_ID_REMOVE |
f7c7cd03 | 361 | * @policy: KDBUS_ITEM_POLICY_ACCESS |
6629161f | 362 | */ |
febfd508 | 363 | struct kdbus_item { |
a8d4cac5 KS |
364 | __u64 size; |
365 | __u64 type; | |
6629161f | 366 | union { |
6629161f | 367 | __u8 data[0]; |
b1454bf0 KS |
368 | __u32 data32[0]; |
369 | __u64 data64[0]; | |
5b7d4c1c | 370 | char str[0]; |
6629161f | 371 | |
febfd508 | 372 | __u64 id; |
6629161f | 373 | struct kdbus_vec vec; |
6629161f | 374 | struct kdbus_creds creds; |
48eaba35 | 375 | struct kdbus_pids pids; |
5b7d4c1c | 376 | struct kdbus_audit audit; |
5ebe2ce7 | 377 | struct kdbus_caps caps; |
69aec65c | 378 | struct kdbus_timestamp timestamp; |
65dae17a | 379 | struct kdbus_name name; |
18a28147 KS |
380 | struct kdbus_bloom_parameter bloom_parameter; |
381 | struct kdbus_bloom_filter bloom_filter; | |
c8150fa7 | 382 | struct kdbus_memfd memfd; |
febfd508 | 383 | int fds[0]; |
8bd54e89 KS |
384 | struct kdbus_notify_name_change name_change; |
385 | struct kdbus_notify_id_change id_change; | |
f7c7cd03 | 386 | struct kdbus_policy_access policy_access; |
6629161f LP |
387 | }; |
388 | }; | |
389 | ||
d31f486b DH |
390 | /** |
391 | * struct kdbus_item_list - A list of items | |
392 | * @size: The total size of the structure | |
393 | * @items: Array of items | |
394 | */ | |
395 | struct kdbus_item_list { | |
396 | __u64 size; | |
397 | struct kdbus_item items[0]; | |
398 | }; | |
399 | ||
5e16c257 KS |
400 | /** |
401 | * enum kdbus_msg_flags - type of message | |
94e15fdc DH |
402 | * @KDBUS_MSG_EXPECT_REPLY: Expect a reply message, used for |
403 | * method calls. The userspace-supplied | |
404 | * cookie identifies the message and the | |
405 | * respective reply carries the cookie | |
406 | * in cookie_reply | |
407 | * @KDBUS_MSG_NO_AUTO_START: Do not start a service, if the addressed | |
408 | * name is not currently active | |
d7d052b2 | 409 | * @KDBUS_MSG_SIGNAL: Treat this message as signal |
5e16c257 KS |
410 | */ |
411 | enum kdbus_msg_flags { | |
94e15fdc DH |
412 | KDBUS_MSG_EXPECT_REPLY = 1ULL << 0, |
413 | KDBUS_MSG_NO_AUTO_START = 1ULL << 1, | |
d7d052b2 | 414 | KDBUS_MSG_SIGNAL = 1ULL << 2, |
6629161f LP |
415 | }; |
416 | ||
5e16c257 KS |
417 | /** |
418 | * enum kdbus_payload_type - type of payload carried by message | |
419 | * @KDBUS_PAYLOAD_KERNEL: Kernel-generated simple message | |
81efa1da | 420 | * @KDBUS_PAYLOAD_DBUS: D-Bus marshalling "DBusDBus" |
94e15fdc DH |
421 | * |
422 | * Any payload-type is accepted. Common types will get added here once | |
423 | * established. | |
5e16c257 KS |
424 | */ |
425 | enum kdbus_payload_type { | |
9b3848f2 | 426 | KDBUS_PAYLOAD_KERNEL, |
81efa1da | 427 | KDBUS_PAYLOAD_DBUS = 0x4442757344427573ULL, |
6629161f LP |
428 | }; |
429 | ||
c85a5a24 DM |
430 | /** |
431 | * struct kdbus_msg - the representation of a kdbus message | |
432 | * @size: Total size of the message | |
94e15fdc | 433 | * @flags: Message flags (KDBUS_MSG_*), userspace → kernel |
9ff1897b | 434 | * @priority: Message queue priority value |
c85a5a24 DM |
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_*) | |
7e94edc2 | 438 | * @cookie: Userspace-supplied cookie, for the connection |
95970860 | 439 | * to identify its messages |
80a33f11 | 440 | * @timeout_ns: The time to wait for a message reply from the peer. |
95970860 KS |
441 | * If there is no reply, a kernel-generated message |
442 | * with an attached KDBUS_ITEM_REPLY_TIMEOUT item | |
03785ad0 DM |
443 | * is sent to @src_id. The timeout is expected in |
444 | * nanoseconds and as absolute CLOCK_MONOTONIC value. | |
135a4eb4 KS |
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 | |
c85a5a24 DM |
448 | * @items: A list of kdbus_items containing the message payload |
449 | */ | |
6629161f LP |
450 | struct kdbus_msg { |
451 | __u64 size; | |
452 | __u64 flags; | |
9ff1897b | 453 | __s64 priority; |
c85a5a24 DM |
454 | __u64 dst_id; |
455 | __u64 src_id; | |
456 | __u64 payload_type; | |
457 | __u64 cookie; | |
80a33f11 | 458 | union { |
80a33f11 | 459 | __u64 timeout_ns; |
135a4eb4 | 460 | __u64 cookie_reply; |
80a33f11 | 461 | }; |
febfd508 | 462 | struct kdbus_item items[0]; |
e0d48644 | 463 | } __attribute__((aligned(8))); |
6629161f | 464 | |
94e15fdc | 465 | /** |
d031efb2 | 466 | * struct kdbus_msg_info - returned message container |
94e15fdc DH |
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 | |
470 | */ | |
d031efb2 | 471 | struct kdbus_msg_info { |
94e15fdc DH |
472 | __u64 offset; |
473 | __u64 msg_size; | |
474 | __u64 return_flags; | |
475 | }; | |
476 | ||
477 | /** | |
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. | |
488 | */ | |
489 | enum kdbus_send_flags { | |
490 | KDBUS_SEND_SYNC_REPLY = 1ULL << 0, | |
491 | }; | |
492 | ||
493 | /** | |
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 | |
502 | * was given | |
503 | * @items: Additional items for this command | |
504 | */ | |
505 | struct kdbus_cmd_send { | |
506 | __u64 size; | |
507 | __u64 flags; | |
508 | __u64 kernel_flags; | |
509 | __u64 kernel_msg_flags; | |
510 | __u64 return_flags; | |
511 | __u64 msg_address; | |
d031efb2 | 512 | struct kdbus_msg_info reply; |
94e15fdc DH |
513 | struct kdbus_item items[0]; |
514 | } __attribute__((aligned(8))); | |
515 | ||
9ff1897b KS |
516 | /** |
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 | |
dec51b29 KS |
526 | * higher priority (lowest values); if not set, |
527 | * the priority value is ignored. | |
9ff1897b KS |
528 | */ |
529 | enum kdbus_recv_flags { | |
913b6d70 DM |
530 | KDBUS_RECV_PEEK = 1ULL << 0, |
531 | KDBUS_RECV_DROP = 1ULL << 1, | |
532 | KDBUS_RECV_USE_PRIORITY = 1ULL << 2, | |
9ff1897b KS |
533 | }; |
534 | ||
94e15fdc DH |
535 | /** |
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. | |
540 | */ | |
541 | enum kdbus_recv_return_flags { | |
542 | KDBUS_RECV_RETURN_INCOMPLETE_FDS = 1ULL << 0, | |
543 | }; | |
544 | ||
9ff1897b | 545 | /** |
e4ecabd0 | 546 | * struct kdbus_cmd_recv - struct to de-queue a buffered message |
94e15fdc | 547 | * @size: Overall size of this object |
bc75205c DM |
548 | * @flags: KDBUS_RECV_* flags, userspace → kernel |
549 | * @kernel_flags: Supported KDBUS_RECV_* flags, kernel → userspace | |
94e15fdc | 550 | * @return_flags: Command return flags, kernel → userspace |
9ff1897b KS |
551 | * @priority: Minimum priority of the messages to de-queue. Lowest |
552 | * values have the highest priority. | |
94e15fdc | 553 | * @dropped_msgs: In case the KDBUS_CMD_RECV ioctl returns |
705a415f LP |
554 | * -EOVERFLOW, this field will contain the number of |
555 | * broadcast messages that have been lost since the | |
556 | * last call. | |
94e15fdc DH |
557 | * @reply: Return storage for received message. |
558 | * @items: Additional items for this command. | |
9ff1897b | 559 | * |
94e15fdc | 560 | * This struct is used with the KDBUS_CMD_RECV ioctl. |
9ff1897b KS |
561 | */ |
562 | struct kdbus_cmd_recv { | |
94e15fdc | 563 | __u64 size; |
9ff1897b | 564 | __u64 flags; |
bc75205c | 565 | __u64 kernel_flags; |
94e15fdc | 566 | __u64 return_flags; |
9ff1897b | 567 | __s64 priority; |
94e15fdc | 568 | __u64 dropped_msgs; |
a9c8343e | 569 | struct kdbus_msg_info msg; |
94e15fdc | 570 | struct kdbus_item items[0]; |
9ff1897b KS |
571 | } __attribute__((aligned(8))); |
572 | ||
d663f1b1 DM |
573 | /** |
574 | * struct kdbus_cmd_free - struct to free a slice of memory in the pool | |
d31f486b | 575 | * @size: Overall size of this structure |
bc75205c | 576 | * @offset: The offset of the memory slice, as returned by other |
d663f1b1 | 577 | * ioctls |
bc75205c | 578 | * @flags: Flags for the free command, userspace → kernel |
94e15fdc | 579 | * @return_flags: Command return flags, kernel → userspace |
bc75205c | 580 | * @kernel_flags: Supported flags of the free command, userspace → kernel |
d31f486b | 581 | * @items: Additional items to modify the behavior |
d663f1b1 DM |
582 | * |
583 | * This struct is used with the KDBUS_CMD_FREE ioctl. | |
584 | */ | |
585 | struct kdbus_cmd_free { | |
d31f486b | 586 | __u64 size; |
d663f1b1 DM |
587 | __u64 offset; |
588 | __u64 flags; | |
bc75205c | 589 | __u64 kernel_flags; |
94e15fdc | 590 | __u64 return_flags; |
d31f486b | 591 | struct kdbus_item items[0]; |
d663f1b1 DM |
592 | } __attribute__((aligned(8))); |
593 | ||
5e16c257 KS |
594 | /** |
595 | * enum kdbus_policy_access_type - permissions of a policy record | |
81efa1da | 596 | * @_KDBUS_POLICY_ACCESS_NULL: Uninitialized/invalid |
5e16c257 | 597 | * @KDBUS_POLICY_ACCESS_USER: Grant access to a uid |
9bb59c29 | 598 | * @KDBUS_POLICY_ACCESS_GROUP: Grant access to gid |
5e16c257 KS |
599 | * @KDBUS_POLICY_ACCESS_WORLD: World-accessible |
600 | */ | |
601 | enum kdbus_policy_access_type { | |
86312ab8 | 602 | _KDBUS_POLICY_ACCESS_NULL, |
27eda16e KS |
603 | KDBUS_POLICY_ACCESS_USER, |
604 | KDBUS_POLICY_ACCESS_GROUP, | |
605 | KDBUS_POLICY_ACCESS_WORLD, | |
6629161f LP |
606 | }; |
607 | ||
5e16c257 KS |
608 | /** |
609 | * enum kdbus_policy_access_flags - mode flags | |
5e16c257 | 610 | * @KDBUS_POLICY_OWN: Allow to own a well-known name |
f7c7cd03 DM |
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 | |
5e16c257 KS |
615 | */ |
616 | enum kdbus_policy_type { | |
f7c7cd03 DM |
617 | KDBUS_POLICY_SEE = 0, |
618 | KDBUS_POLICY_TALK, | |
619 | KDBUS_POLICY_OWN, | |
6629161f LP |
620 | }; |
621 | ||
5e16c257 KS |
622 | /** |
623 | * enum kdbus_hello_flags - flags for struct kdbus_cmd_hello | |
f8c24252 | 624 | * @KDBUS_HELLO_ACCEPT_FD: The connection allows the reception of |
95970860 | 625 | * any passed file descriptors |
b6c631f3 | 626 | * @KDBUS_HELLO_ACTIVATOR: Special-purpose connection which registers |
95970860 KS |
627 | * a well-know name for a process to be started |
628 | * when traffic arrives | |
f7c7cd03 | 629 | * @KDBUS_HELLO_POLICY_HOLDER: Special-purpose connection which registers |
e90b8642 KS |
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 | |
94e15fdc | 633 | * connections to acquire a name, talk or discover |
e90b8642 | 634 | * a service |
b6c631f3 | 635 | * @KDBUS_HELLO_MONITOR: Special-purpose connection to monitor |
95970860 | 636 | * bus traffic |
5e16c257 KS |
637 | */ |
638 | enum kdbus_hello_flags { | |
913b6d70 | 639 | KDBUS_HELLO_ACCEPT_FD = 1ULL << 0, |
c32195e0 KS |
640 | KDBUS_HELLO_ACTIVATOR = 1ULL << 1, |
641 | KDBUS_HELLO_POLICY_HOLDER = 1ULL << 2, | |
642 | KDBUS_HELLO_MONITOR = 1ULL << 3, | |
d21a7bb1 | 643 | }; |
5b7d4c1c | 644 | |
5e16c257 KS |
645 | /** |
646 | * enum kdbus_attach_flags - flags for metadata attachments | |
635f9f0d DM |
647 | * @KDBUS_ATTACH_TIMESTAMP: Timestamp |
648 | * @KDBUS_ATTACH_CREDS: Credentials | |
705a415f | 649 | * @KDBUS_ATTACH_PIDS: PIDs |
635f9f0d DM |
650 | * @KDBUS_ATTACH_AUXGROUPS: Auxiliary groups |
651 | * @KDBUS_ATTACH_NAMES: Well-known names | |
652 | * @KDBUS_ATTACH_TID_COMM: The "comm" process identifier of the TID | |
653 | * @KDBUS_ATTACH_PID_COMM: The "comm" process identifier of the PID | |
654 | * @KDBUS_ATTACH_EXE: The path of the executable | |
655 | * @KDBUS_ATTACH_CMDLINE: The process command line | |
656 | * @KDBUS_ATTACH_CGROUP: The croup membership | |
657 | * @KDBUS_ATTACH_CAPS: The process capabilities | |
658 | * @KDBUS_ATTACH_SECLABEL: The security label | |
659 | * @KDBUS_ATTACH_AUDIT: The audit IDs | |
660 | * @KDBUS_ATTACH_CONN_DESCRIPTION: The human-readable connection name | |
661 | * @_KDBUS_ATTACH_ALL: All of the above | |
d704fda9 DM |
662 | * @_KDBUS_ATTACH_ANY: Wildcard match to enable any kind of |
663 | * metatdata. | |
5e16c257 KS |
664 | */ |
665 | enum kdbus_attach_flags { | |
913b6d70 DM |
666 | KDBUS_ATTACH_TIMESTAMP = 1ULL << 0, |
667 | KDBUS_ATTACH_CREDS = 1ULL << 1, | |
48eaba35 LP |
668 | KDBUS_ATTACH_PIDS = 1ULL << 2, |
669 | KDBUS_ATTACH_AUXGROUPS = 1ULL << 3, | |
670 | KDBUS_ATTACH_NAMES = 1ULL << 4, | |
671 | KDBUS_ATTACH_TID_COMM = 1ULL << 5, | |
672 | KDBUS_ATTACH_PID_COMM = 1ULL << 6, | |
673 | KDBUS_ATTACH_EXE = 1ULL << 7, | |
674 | KDBUS_ATTACH_CMDLINE = 1ULL << 8, | |
675 | KDBUS_ATTACH_CGROUP = 1ULL << 9, | |
676 | KDBUS_ATTACH_CAPS = 1ULL << 10, | |
677 | KDBUS_ATTACH_SECLABEL = 1ULL << 11, | |
678 | KDBUS_ATTACH_AUDIT = 1ULL << 12, | |
679 | KDBUS_ATTACH_CONN_DESCRIPTION = 1ULL << 13, | |
680 | _KDBUS_ATTACH_ALL = (1ULL << 14) - 1, | |
d704fda9 | 681 | _KDBUS_ATTACH_ANY = ~0ULL |
6629161f LP |
682 | }; |
683 | ||
c85a5a24 DM |
684 | /** |
685 | * struct kdbus_cmd_hello - struct to say hello to kdbus | |
686 | * @size: The total size of the structure | |
bc75205c DM |
687 | * @flags: Connection flags (KDBUS_HELLO_*), userspace → kernel |
688 | * @kernel_flags: Supported connection flags, kernel → userspace | |
94e15fdc | 689 | * @return_flags: Command return flags, kernel → userspace |
d704fda9 DM |
690 | * @attach_flags_send: Mask of metadata to attach to each message sent |
691 | * off by this connection (KDBUS_ATTACH_*) | |
692 | * @attach_flags_recv: Mask of metadata to attach to each message receieved | |
693 | * by the new connection (KDBUS_ATTACH_*) | |
c85a5a24 | 694 | * @bus_flags: The flags field copied verbatim from the original |
95970860 | 695 | * KDBUS_CMD_BUS_MAKE ioctl. It's intended to be useful |
c85a5a24 DM |
696 | * to do negotiation of features of the payload that is |
697 | * transferred (kernel → userspace) | |
65dae17a | 698 | * @id: The ID of this connection (kernel → userspace) |
061eab67 | 699 | * @pool_size: Size of the connection's buffer where the received |
95970860 | 700 | * messages are placed |
d31f486b DH |
701 | * @offset: Pool offset where additional items of type |
702 | * kdbus_item_list are stored. They contain information | |
703 | * about the bus and the newly created connection. | |
704 | * @items_size: Copy of item_list.size stored in @offset. | |
c85a5a24 | 705 | * @id128: Unique 128-bit ID of the bus (kernel → userspace) |
a8d4cac5 | 706 | * @items: A list of items |
c85a5a24 | 707 | * |
9ff1897b | 708 | * This struct is used with the KDBUS_CMD_HELLO ioctl. |
c85a5a24 | 709 | */ |
6629161f | 710 | struct kdbus_cmd_hello { |
a2cef833 | 711 | __u64 size; |
bc75205c DM |
712 | __u64 flags; |
713 | __u64 kernel_flags; | |
94e15fdc | 714 | __u64 return_flags; |
d704fda9 DM |
715 | __u64 attach_flags_send; |
716 | __u64 attach_flags_recv; | |
c85a5a24 DM |
717 | __u64 bus_flags; |
718 | __u64 id; | |
c85a5a24 | 719 | __u64 pool_size; |
d31f486b DH |
720 | __u64 offset; |
721 | __u64 items_size; | |
c85a5a24 | 722 | __u8 id128[16]; |
febfd508 | 723 | struct kdbus_item items[0]; |
e0d48644 | 724 | } __attribute__((aligned(8))); |
799e7ea8 | 725 | |
f7c7cd03 DM |
726 | /** |
727 | * enum kdbus_make_flags - Flags for KDBUS_CMD_{BUS,EP,NS}_MAKE | |
705a415f LP |
728 | * @KDBUS_MAKE_ACCESS_GROUP: Make the bus or endpoint node group-accessible |
729 | * @KDBUS_MAKE_ACCESS_WORLD: Make the bus or endpoint node world-accessible | |
f7c7cd03 | 730 | */ |
5e16c257 | 731 | enum kdbus_make_flags { |
913b6d70 DM |
732 | KDBUS_MAKE_ACCESS_GROUP = 1ULL << 0, |
733 | KDBUS_MAKE_ACCESS_WORLD = 1ULL << 1, | |
799e7ea8 KS |
734 | }; |
735 | ||
c85a5a24 | 736 | /** |
486e99a3 | 737 | * struct kdbus_cmd_make - struct to make a bus, an endpoint or a domain |
c85a5a24 | 738 | * @size: The total size of the struct |
bc75205c DM |
739 | * @flags: Properties for the bus/ep/domain to create, |
740 | * userspace → kernel | |
741 | * @kernel_flags: Supported flags for the used command, kernel → userspace | |
94e15fdc | 742 | * @return_flags: Command return flags, kernel → userspace |
816a3f9e | 743 | * @items: Items describing details |
c85a5a24 | 744 | * |
63cc4c31 DM |
745 | * This structure is used with the KDBUS_CMD_BUS_MAKE and |
746 | * KDBUS_CMD_ENDPOINT_MAKE ioctls. | |
c85a5a24 | 747 | */ |
816a3f9e | 748 | struct kdbus_cmd_make { |
5b7d4c1c | 749 | __u64 size; |
c85a5a24 | 750 | __u64 flags; |
bc75205c | 751 | __u64 kernel_flags; |
94e15fdc | 752 | __u64 return_flags; |
febfd508 | 753 | struct kdbus_item items[0]; |
e0d48644 | 754 | } __attribute__((aligned(8))); |
6629161f | 755 | |
4ccbc146 KS |
756 | /** |
757 | * enum kdbus_name_flags - properties of a well-known name | |
758 | * @KDBUS_NAME_REPLACE_EXISTING: Try to replace name of other connections | |
4ccbc146 | 759 | * @KDBUS_NAME_ALLOW_REPLACEMENT: Allow the replacement of the name |
e599ba01 | 760 | * @KDBUS_NAME_QUEUE: Name should be queued if busy |
4ccbc146 | 761 | * @KDBUS_NAME_IN_QUEUE: Name is queued |
07442eff | 762 | * @KDBUS_NAME_ACTIVATOR: Name is owned by a activator connection |
4ccbc146 | 763 | */ |
5e16c257 | 764 | enum kdbus_name_flags { |
913b6d70 DM |
765 | KDBUS_NAME_REPLACE_EXISTING = 1ULL << 0, |
766 | KDBUS_NAME_ALLOW_REPLACEMENT = 1ULL << 1, | |
767 | KDBUS_NAME_QUEUE = 1ULL << 2, | |
768 | KDBUS_NAME_IN_QUEUE = 1ULL << 3, | |
769 | KDBUS_NAME_ACTIVATOR = 1ULL << 4, | |
6629161f LP |
770 | }; |
771 | ||
c85a5a24 DM |
772 | /** |
773 | * struct kdbus_cmd_name - struct to describe a well-known name | |
774 | * @size: The total size of the struct | |
bc75205c DM |
775 | * @flags: Flags for a name entry (KDBUS_NAME_*), |
776 | * userspace → kernel, kernel → userspace | |
777 | * @kernel_flags: Supported flags for a name entry, kernel → userspace | |
94e15fdc | 778 | * @return_flags: Command return flags, kernel → userspace |
f8c24252 DM |
779 | * @items: Item list, containing the well-known name as |
780 | * KDBUS_ITEM_NAME | |
c85a5a24 DM |
781 | * |
782 | * This structure is used with the KDBUS_CMD_NAME_ACQUIRE ioctl. | |
c85a5a24 | 783 | */ |
6629161f LP |
784 | struct kdbus_cmd_name { |
785 | __u64 size; | |
9b3848f2 | 786 | __u64 flags; |
bc75205c | 787 | __u64 kernel_flags; |
94e15fdc | 788 | __u64 return_flags; |
bc75205c DM |
789 | struct kdbus_item items[0]; |
790 | } __attribute__((aligned(8))); | |
791 | ||
792 | /** | |
793 | * struct kdbus_name_info - struct to describe a well-known name | |
794 | * @size: The total size of the struct | |
bc75205c DM |
795 | * @conn_flags: The flags of the owning connection (KDBUS_HELLO_*) |
796 | * @owner_id: The current owner of the name | |
797 | * @items: Item list, containing the well-known name as | |
635f9f0d | 798 | * KDBUS_ITEM_OWNED_NAME |
bc75205c DM |
799 | * |
800 | * This structure is used as return struct for the KDBUS_CMD_NAME_LIST ioctl. | |
801 | */ | |
802 | struct kdbus_name_info { | |
803 | __u64 size; | |
5b7d4c1c | 804 | __u64 conn_flags; |
bc75205c | 805 | __u64 owner_id; |
f8c24252 | 806 | struct kdbus_item items[0]; |
e0d48644 | 807 | } __attribute__((aligned(8))); |
6629161f | 808 | |
94e15fdc DH |
809 | /** |
810 | * struct kdbus_name_list - information returned by KDBUS_CMD_NAME_LIST | |
811 | * @size: The total size of the structure | |
812 | * @names: A list of names | |
813 | * | |
814 | * Note that the user is responsible for freeing the allocated memory with | |
815 | * the KDBUS_CMD_FREE ioctl. | |
816 | */ | |
817 | struct kdbus_name_list { | |
818 | __u64 size; | |
819 | struct kdbus_name_info names[0]; | |
820 | }; | |
821 | ||
4ccbc146 KS |
822 | /** |
823 | * enum kdbus_name_list_flags - what to include into the returned list | |
824 | * @KDBUS_NAME_LIST_UNIQUE: All active connections | |
825 | * @KDBUS_NAME_LIST_NAMES: All known well-known names | |
07442eff | 826 | * @KDBUS_NAME_LIST_ACTIVATORS: All activator connections |
4ccbc146 KS |
827 | * @KDBUS_NAME_LIST_QUEUED: All queued-up names |
828 | */ | |
5e16c257 | 829 | enum kdbus_name_list_flags { |
913b6d70 DM |
830 | KDBUS_NAME_LIST_UNIQUE = 1ULL << 0, |
831 | KDBUS_NAME_LIST_NAMES = 1ULL << 1, | |
832 | KDBUS_NAME_LIST_ACTIVATORS = 1ULL << 2, | |
833 | KDBUS_NAME_LIST_QUEUED = 1ULL << 3, | |
29db7881 KS |
834 | }; |
835 | ||
c85a5a24 DM |
836 | /** |
837 | * struct kdbus_cmd_name_list - request a list of name entries | |
bc75205c | 838 | * @flags: Flags for the query (KDBUS_NAME_LIST_*), |
705a415f | 839 | * userspace → kernel |
bc75205c | 840 | * @kernel_flags: Supported flags for queries, kernel → userspace |
94e15fdc | 841 | * @return_flags: Command return flags, kernel → userspace |
e63bb33d KS |
842 | * @offset: The returned offset in the caller's pool buffer. |
843 | * The user must use KDBUS_CMD_FREE to free the | |
844 | * allocated memory. | |
6ad9bb71 | 845 | * @list_size: Returned size of list in bytes |
32802361 | 846 | * @size: Output buffer to report size of data at @offset. |
6ad9bb71 | 847 | * @items: Items for the command. Reserved for future use. |
ceceaf09 | 848 | * |
c85a5a24 | 849 | * This structure is used with the KDBUS_CMD_NAME_LIST ioctl. |
c85a5a24 | 850 | */ |
1d0e3c98 | 851 | struct kdbus_cmd_name_list { |
94e15fdc | 852 | __u64 size; |
29db7881 | 853 | __u64 flags; |
bc75205c | 854 | __u64 kernel_flags; |
94e15fdc | 855 | __u64 return_flags; |
c85a5a24 | 856 | __u64 offset; |
94e15fdc DH |
857 | __u64 list_size; |
858 | struct kdbus_item items[0]; | |
e0d48644 | 859 | } __attribute__((aligned(8))); |
6629161f | 860 | |
c85a5a24 | 861 | /** |
94e15fdc DH |
862 | * struct kdbus_info - information returned by KDBUS_CMD_*_INFO |
863 | * @size: The total size of the struct | |
864 | * @id: The connection's or bus' 64-bit ID | |
865 | * @flags: The connection's or bus' flags | |
866 | * @items: A list of struct kdbus_item | |
c85a5a24 DM |
867 | * |
868 | * Note that the user is responsible for freeing the allocated memory with | |
869 | * the KDBUS_CMD_FREE ioctl. | |
870 | */ | |
94e15fdc | 871 | struct kdbus_info { |
1d0e3c98 | 872 | __u64 size; |
94e15fdc DH |
873 | __u64 id; |
874 | __u64 flags; | |
875 | struct kdbus_item items[0]; | |
6629161f LP |
876 | }; |
877 | ||
c85a5a24 | 878 | /** |
a1783d61 | 879 | * struct kdbus_cmd_info - struct used for KDBUS_CMD_CONN_INFO ioctl |
e63bb33d | 880 | * @size: The total size of the struct |
bc75205c DM |
881 | * @flags: KDBUS_ATTACH_* flags, userspace → kernel |
882 | * @kernel_flags: Supported KDBUS_ATTACH_* flags, kernel → userspace | |
94e15fdc | 883 | * @return_flags: Command return flags, kernel → userspace |
e63bb33d | 884 | * @id: The 64-bit ID of the connection. If set to zero, passing |
95970860 KS |
885 | * @name is required. kdbus will look up the name to |
886 | * determine the ID in this case. | |
e63bb33d | 887 | * @offset: Returned offset in the caller's pool buffer where the |
a1783d61 | 888 | * kdbus_info struct result is stored. The user must |
95970860 | 889 | * use KDBUS_CMD_FREE to free the allocated memory. |
32802361 | 890 | * @info_size: Output buffer to report size of data at @offset. |
5ebe2ce7 DM |
891 | * @items: The optional item list, containing the |
892 | * well-known name to look up as a KDBUS_ITEM_NAME. | |
893 | * Only needed in case @id is zero. | |
c85a5a24 DM |
894 | * |
895 | * On success, the KDBUS_CMD_CONN_INFO ioctl will return 0 and @offset will | |
896 | * tell the user the offset in the connection pool buffer at which to find the | |
a1783d61 | 897 | * result in a struct kdbus_info. |
c85a5a24 | 898 | */ |
a1783d61 | 899 | struct kdbus_cmd_info { |
1d0e3c98 | 900 | __u64 size; |
e63bb33d | 901 | __u64 flags; |
bc75205c | 902 | __u64 kernel_flags; |
94e15fdc | 903 | __u64 return_flags; |
e63bb33d KS |
904 | __u64 id; |
905 | __u64 offset; | |
32802361 | 906 | __u64 info_size; |
581fe6c8 | 907 | struct kdbus_item items[0]; |
e0d48644 | 908 | } __attribute__((aligned(8))); |
1d0e3c98 | 909 | |
18a28147 | 910 | /** |
088b5110 | 911 | * struct kdbus_cmd_update - update flags of a connection |
18a28147 | 912 | * @size: The total size of the struct |
bc75205c DM |
913 | * @flags: Flags for the update command, userspace → kernel |
914 | * @kernel_flags: Supported flags for this command, kernel → userspace | |
94e15fdc | 915 | * @return_flags: Command return flags, kernel → userspace |
18a28147 KS |
916 | * @items: A list of struct kdbus_item |
917 | * | |
918 | * This struct is used with the KDBUS_CMD_CONN_UPDATE ioctl. | |
919 | */ | |
088b5110 | 920 | struct kdbus_cmd_update { |
18a28147 | 921 | __u64 size; |
d663f1b1 | 922 | __u64 flags; |
bc75205c | 923 | __u64 kernel_flags; |
94e15fdc | 924 | __u64 return_flags; |
18a28147 KS |
925 | struct kdbus_item items[0]; |
926 | } __attribute__((aligned(8))); | |
927 | ||
995a1063 DM |
928 | /** |
929 | * enum kdbus_cmd_match_flags - flags to control the KDBUS_CMD_MATCH_ADD ioctl | |
930 | * @KDBUS_MATCH_REPLACE: If entries with the supplied cookie already | |
931 | * exists, remove them before installing the new | |
932 | * matches. | |
933 | */ | |
934 | enum kdbus_cmd_match_flags { | |
935 | KDBUS_MATCH_REPLACE = 1ULL << 0, | |
936 | }; | |
937 | ||
c85a5a24 DM |
938 | /** |
939 | * struct kdbus_cmd_match - struct to add or remove matches | |
e63bb33d | 940 | * @size: The total size of the struct |
5e16c257 | 941 | * @cookie: Userspace supplied cookie. When removing, the cookie |
95970860 | 942 | * identifies the match to remove |
bc75205c DM |
943 | * @flags: Flags for match command (KDBUS_MATCH_*), |
944 | * userspace → kernel | |
945 | * @kernel_flags: Supported flags of the used command, kernel → userspace | |
94e15fdc | 946 | * @return_flags: Command return flags, kernel → userspace |
e63bb33d | 947 | * @items: A list of items for additional information |
c85a5a24 | 948 | * |
5ebe2ce7 DM |
949 | * This structure is used with the KDBUS_CMD_MATCH_ADD and |
950 | * KDBUS_CMD_MATCH_REMOVE ioctl. | |
c85a5a24 | 951 | */ |
6629161f LP |
952 | struct kdbus_cmd_match { |
953 | __u64 size; | |
e63bb33d | 954 | __u64 cookie; |
995a1063 | 955 | __u64 flags; |
bc75205c | 956 | __u64 kernel_flags; |
94e15fdc | 957 | __u64 return_flags; |
febfd508 | 958 | struct kdbus_item items[0]; |
e0d48644 | 959 | } __attribute__((aligned(8))); |
6629161f | 960 | |
5e16c257 | 961 | /** |
635f9f0d | 962 | * Ioctl API |
705a415f LP |
963 | * KDBUS_CMD_BUS_MAKE: After opening the "control" node, this command |
964 | * creates a new bus with the specified | |
95970860 | 965 | * name. The bus is immediately shut down and |
705a415f LP |
966 | * cleaned up when the opened file descriptor is |
967 | * closed. | |
635f9f0d | 968 | * KDBUS_CMD_ENDPOINT_MAKE: Creates a new named special endpoint to talk to |
95970860 KS |
969 | * the bus. Such endpoints usually carry a more |
970 | * restrictive policy and grant restricted access | |
971 | * to specific applications. | |
705a415f | 972 | * KDBUS_CMD_HELLO: By opening the bus node, a connection is |
95970860 KS |
973 | * created. After a HELLO the opened connection |
974 | * becomes an active peer on the bus. | |
635f9f0d | 975 | * KDBUS_CMD_BYEBYE: Disconnect a connection. If there are no |
913b6d70 DM |
976 | * messages queued up in the connection's pool, |
977 | * the call succeeds, and the handle is rendered | |
978 | * unusable. Otherwise, -EBUSY is returned without | |
979 | * any further side-effects. | |
94e15fdc | 980 | * KDBUS_CMD_SEND: Send a message and pass data from userspace to |
95970860 | 981 | * the kernel. |
94e15fdc | 982 | * KDBUS_CMD_RECV: Receive a message from the kernel which is |
95970860 | 983 | * placed in the receiver's pool. |
635f9f0d | 984 | * KDBUS_CMD_FREE: Release the allocated memory in the receiver's |
95970860 | 985 | * pool. |
635f9f0d | 986 | * KDBUS_CMD_NAME_ACQUIRE: Request a well-known bus name to associate with |
95970860 KS |
987 | * the connection. Well-known names are used to |
988 | * address a peer on the bus. | |
635f9f0d | 989 | * KDBUS_CMD_NAME_RELEASE: Release a well-known name the connection |
95970860 | 990 | * currently owns. |
635f9f0d | 991 | * KDBUS_CMD_NAME_LIST: Retrieve the list of all currently registered |
95970860 | 992 | * well-known and unique names. |
635f9f0d | 993 | * KDBUS_CMD_CONN_INFO: Retrieve credentials and properties of the |
95970860 KS |
994 | * initial creator of the connection. The data was |
995 | * stored at registration time and does not | |
996 | * necessarily represent the connected process or | |
997 | * the actual state of the process. | |
635f9f0d | 998 | * KDBUS_CMD_CONN_UPDATE: Update the properties of a connection. Used to |
dec51b29 KS |
999 | * update the metadata subscription mask and |
1000 | * policy. | |
635f9f0d | 1001 | * KDBUS_CMD_BUS_CREATOR_INFO: Retrieve information of the creator of the bus |
a1783d61 | 1002 | * a connection is attached to. |
635f9f0d | 1003 | * KDBUS_CMD_ENDPOINT_UPDATE: Update the properties of a custom enpoint. Used |
dec51b29 | 1004 | * to update the policy. |
6ad9bb71 | 1005 | * KDBUS_CMD_MATCH_ADD: Install a match which broadcast messages should |
95970860 | 1006 | * be delivered to the connection. |
635f9f0d DM |
1007 | * KDBUS_CMD_MATCH_REMOVE: Remove a current match for broadcast messages. |
1008 | */ | |
d031efb2 KS |
1009 | enum kdbus_ioctl_type { |
1010 | KDBUS_CMD_BUS_MAKE = _IOW(KDBUS_IOCTL_MAGIC, 0x00, | |
1011 | struct kdbus_cmd_make), | |
1012 | KDBUS_CMD_ENDPOINT_MAKE = _IOW(KDBUS_IOCTL_MAGIC, 0x10, | |
1013 | struct kdbus_cmd_make), | |
635f9f0d | 1014 | |
d031efb2 KS |
1015 | KDBUS_CMD_HELLO = _IOWR(KDBUS_IOCTL_MAGIC, 0x20, |
1016 | struct kdbus_cmd_hello), | |
1017 | KDBUS_CMD_BYEBYE = _IO(KDBUS_IOCTL_MAGIC, 0x21), | |
635f9f0d | 1018 | |
d031efb2 KS |
1019 | KDBUS_CMD_SEND = _IOWR(KDBUS_IOCTL_MAGIC, 0x30, |
1020 | struct kdbus_cmd_send), | |
1021 | KDBUS_CMD_RECV = _IOWR(KDBUS_IOCTL_MAGIC, 0x31, | |
1022 | struct kdbus_cmd_recv), | |
1023 | KDBUS_CMD_FREE = _IOW(KDBUS_IOCTL_MAGIC, 0x32, | |
1024 | struct kdbus_cmd_free), | |
635f9f0d | 1025 | |
d031efb2 KS |
1026 | KDBUS_CMD_NAME_ACQUIRE = _IOWR(KDBUS_IOCTL_MAGIC, 0x40, |
1027 | struct kdbus_cmd_name), | |
1028 | KDBUS_CMD_NAME_RELEASE = _IOW(KDBUS_IOCTL_MAGIC, 0x41, | |
1029 | struct kdbus_cmd_name), | |
1030 | KDBUS_CMD_NAME_LIST = _IOWR(KDBUS_IOCTL_MAGIC, 0x42, | |
1031 | struct kdbus_cmd_name_list), | |
635f9f0d | 1032 | |
d031efb2 KS |
1033 | KDBUS_CMD_CONN_INFO = _IOWR(KDBUS_IOCTL_MAGIC, 0x50, |
1034 | struct kdbus_cmd_info), | |
1035 | KDBUS_CMD_CONN_UPDATE = _IOW(KDBUS_IOCTL_MAGIC, 0x51, | |
1036 | struct kdbus_cmd_update), | |
1037 | KDBUS_CMD_BUS_CREATOR_INFO = _IOWR(KDBUS_IOCTL_MAGIC, 0x52, | |
1038 | struct kdbus_cmd_info), | |
635f9f0d | 1039 | |
d031efb2 KS |
1040 | KDBUS_CMD_ENDPOINT_UPDATE = _IOW(KDBUS_IOCTL_MAGIC, 0x61, |
1041 | struct kdbus_cmd_update), | |
635f9f0d | 1042 | |
d031efb2 KS |
1043 | KDBUS_CMD_MATCH_ADD = _IOW(KDBUS_IOCTL_MAGIC, 0x70, |
1044 | struct kdbus_cmd_match), | |
1045 | KDBUS_CMD_MATCH_REMOVE = _IOW(KDBUS_IOCTL_MAGIC, 0x71, | |
1046 | struct kdbus_cmd_match), | |
1047 | }; | |
5e16c257 | 1048 | |
913b6d70 | 1049 | #endif /* _KDBUS_UAPI_H_ */ |