1 | #ifndef _host_security_server_ |
2 | #define _host_security_server_ |
3 | |
4 | /* Module host_security */ |
5 | |
6 | #include <string.h> |
7 | #include <mach/ndr.h> |
8 | #include <mach/boolean.h> |
9 | #include <mach/kern_return.h> |
10 | #include <mach/notify.h> |
11 | #include <mach/mach_types.h> |
12 | #include <mach/message.h> |
13 | #include <mach/mig_errors.h> |
14 | #include <mach/port.h> |
15 | |
16 | /* BEGIN MIG_STRNCPY_ZEROFILL CODE */ |
17 | |
18 | #if defined(__has_include) |
19 | #if __has_include(<mach/mig_strncpy_zerofill_support.h>) |
20 | #ifndef USING_MIG_STRNCPY_ZEROFILL |
21 | #define USING_MIG_STRNCPY_ZEROFILL |
22 | #endif |
23 | #ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ |
24 | #define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ |
25 | #ifdef __cplusplus |
26 | extern "C" { |
27 | #endif |
28 | extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); |
29 | #ifdef __cplusplus |
30 | } |
31 | #endif |
32 | #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ |
33 | #endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */ |
34 | #endif /* __has_include */ |
35 | |
36 | /* END MIG_STRNCPY_ZEROFILL CODE */ |
37 | |
38 | |
39 | #ifdef AUTOTEST |
40 | #ifndef FUNCTION_PTR_T |
41 | #define FUNCTION_PTR_T |
42 | typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); |
43 | typedef struct { |
44 | char *name; |
45 | function_ptr_t function; |
46 | } function_table_entry; |
47 | typedef function_table_entry *function_table_t; |
48 | #endif /* FUNCTION_PTR_T */ |
49 | #endif /* AUTOTEST */ |
50 | |
51 | #ifndef host_security_MSG_COUNT |
52 | #define host_security_MSG_COUNT 2 |
53 | #endif /* host_security_MSG_COUNT */ |
54 | |
55 | #include <mach/std_types.h> |
56 | #include <mach/mig.h> |
57 | #include <ipc/ipc_voucher.h> |
58 | #include <kern/ipc_kobject.h> |
59 | #include <kern/ipc_tt.h> |
60 | #include <kern/ipc_host.h> |
61 | #include <kern/ipc_sync.h> |
62 | #include <kern/ledger.h> |
63 | #include <kern/processor.h> |
64 | #include <kern/sync_lock.h> |
65 | #include <kern/sync_sema.h> |
66 | #include <vm/memory_object.h> |
67 | #include <vm/vm_map.h> |
68 | #include <kern/ipc_mig.h> |
69 | #include <mach/mig.h> |
70 | #include <mach/mach_types.h> |
71 | |
72 | #ifdef __BeforeMigServerHeader |
73 | __BeforeMigServerHeader |
74 | #endif /* __BeforeMigServerHeader */ |
75 | |
76 | |
77 | /* Routine host_security_create_task_token */ |
78 | #ifdef mig_external |
79 | mig_external |
80 | #else |
81 | extern |
82 | #endif /* mig_external */ |
83 | kern_return_t host_security_create_task_token |
84 | ( |
85 | host_security_t host_security, |
86 | task_t parent_task, |
87 | security_token_t sec_token, |
88 | audit_token_t audit_token, |
89 | host_t host, |
90 | ledger_array_t ledgers, |
91 | mach_msg_type_number_t ledgersCnt, |
92 | boolean_t inherit_memory, |
93 | task_t *child_task |
94 | ); |
95 | |
96 | /* Routine host_security_set_task_token */ |
97 | #ifdef mig_external |
98 | mig_external |
99 | #else |
100 | extern |
101 | #endif /* mig_external */ |
102 | kern_return_t host_security_set_task_token |
103 | ( |
104 | host_security_t host_security, |
105 | task_t target_task, |
106 | security_token_t sec_token, |
107 | audit_token_t audit_token, |
108 | host_t host |
109 | ); |
110 | |
111 | #ifdef mig_external |
112 | mig_external |
113 | #else |
114 | extern |
115 | #endif /* mig_external */ |
116 | boolean_t host_security_server( |
117 | mach_msg_header_t *InHeadP, |
118 | mach_msg_header_t *OutHeadP); |
119 | |
120 | #ifdef mig_external |
121 | mig_external |
122 | #else |
123 | extern |
124 | #endif /* mig_external */ |
125 | mig_routine_t host_security_server_routine( |
126 | mach_msg_header_t *InHeadP); |
127 | |
128 | |
129 | /* Description of this subsystem, for use in direct RPC */ |
130 | extern const struct host_security_subsystem { |
131 | mig_server_routine_t server; /* Server routine */ |
132 | mach_msg_id_t start; /* Min routine number */ |
133 | mach_msg_id_t end; /* Max routine number + 1 */ |
134 | unsigned int maxsize; /* Max msg size */ |
135 | vm_address_t reserved; /* Reserved */ |
136 | struct routine_descriptor /*Array of routine descriptors */ |
137 | routine[2]; |
138 | } host_security_subsystem; |
139 | |
140 | /* typedefs for all requests */ |
141 | |
142 | #ifndef __Request__host_security_subsystem__defined |
143 | #define __Request__host_security_subsystem__defined |
144 | |
145 | #ifdef __MigPackStructs |
146 | #pragma pack(4) |
147 | #endif |
148 | typedef struct { |
149 | mach_msg_header_t Head; |
150 | /* start of the kernel processed data */ |
151 | mach_msg_body_t msgh_body; |
152 | mach_msg_port_descriptor_t parent_task; |
153 | mach_msg_port_descriptor_t host; |
154 | mach_msg_ool_ports_descriptor_t ledgers; |
155 | /* end of the kernel processed data */ |
156 | NDR_record_t NDR; |
157 | security_token_t sec_token; |
158 | audit_token_t audit_token; |
159 | mach_msg_type_number_t ledgersCnt; |
160 | boolean_t inherit_memory; |
161 | } __Request__host_security_create_task_token_t __attribute__((unused)); |
162 | #ifdef __MigPackStructs |
163 | #pragma pack() |
164 | #endif |
165 | |
166 | #ifdef __MigPackStructs |
167 | #pragma pack(4) |
168 | #endif |
169 | typedef struct { |
170 | mach_msg_header_t Head; |
171 | /* start of the kernel processed data */ |
172 | mach_msg_body_t msgh_body; |
173 | mach_msg_port_descriptor_t target_task; |
174 | mach_msg_port_descriptor_t host; |
175 | /* end of the kernel processed data */ |
176 | NDR_record_t NDR; |
177 | security_token_t sec_token; |
178 | audit_token_t audit_token; |
179 | } __Request__host_security_set_task_token_t __attribute__((unused)); |
180 | #ifdef __MigPackStructs |
181 | #pragma pack() |
182 | #endif |
183 | #endif /* !__Request__host_security_subsystem__defined */ |
184 | |
185 | |
186 | /* union of all requests */ |
187 | |
188 | #ifndef __RequestUnion__host_security_subsystem__defined |
189 | #define __RequestUnion__host_security_subsystem__defined |
190 | union __RequestUnion__host_security_subsystem { |
191 | __Request__host_security_create_task_token_t Request_host_security_create_task_token; |
192 | __Request__host_security_set_task_token_t Request_host_security_set_task_token; |
193 | }; |
194 | #endif /* __RequestUnion__host_security_subsystem__defined */ |
195 | /* typedefs for all replies */ |
196 | |
197 | #ifndef __Reply__host_security_subsystem__defined |
198 | #define __Reply__host_security_subsystem__defined |
199 | |
200 | #ifdef __MigPackStructs |
201 | #pragma pack(4) |
202 | #endif |
203 | typedef struct { |
204 | mach_msg_header_t Head; |
205 | /* start of the kernel processed data */ |
206 | mach_msg_body_t msgh_body; |
207 | mach_msg_port_descriptor_t child_task; |
208 | /* end of the kernel processed data */ |
209 | } __Reply__host_security_create_task_token_t __attribute__((unused)); |
210 | #ifdef __MigPackStructs |
211 | #pragma pack() |
212 | #endif |
213 | |
214 | #ifdef __MigPackStructs |
215 | #pragma pack(4) |
216 | #endif |
217 | typedef struct { |
218 | mach_msg_header_t Head; |
219 | NDR_record_t NDR; |
220 | kern_return_t RetCode; |
221 | } __Reply__host_security_set_task_token_t __attribute__((unused)); |
222 | #ifdef __MigPackStructs |
223 | #pragma pack() |
224 | #endif |
225 | #endif /* !__Reply__host_security_subsystem__defined */ |
226 | |
227 | |
228 | /* union of all replies */ |
229 | |
230 | #ifndef __ReplyUnion__host_security_subsystem__defined |
231 | #define __ReplyUnion__host_security_subsystem__defined |
232 | union __ReplyUnion__host_security_subsystem { |
233 | __Reply__host_security_create_task_token_t Reply_host_security_create_task_token; |
234 | __Reply__host_security_set_task_token_t Reply_host_security_set_task_token; |
235 | }; |
236 | #endif /* __RequestUnion__host_security_subsystem__defined */ |
237 | |
238 | #ifndef subsystem_to_name_map_host_security |
239 | #define subsystem_to_name_map_host_security \ |
240 | { "host_security_create_task_token", 600 },\ |
241 | { "host_security_set_task_token", 601 } |
242 | #endif |
243 | |
244 | #ifdef __AfterMigServerHeader |
245 | __AfterMigServerHeader |
246 | #endif /* __AfterMigServerHeader */ |
247 | |
248 | #endif /* _host_security_server_ */ |
249 | |