Lines Matching defs:task

108  *		Initialize a task's IPC state.
118 task_t task,
132 space->is_task = task;
142 itk_lock_init(task);
143 task->itk_self = kport;
144 task->itk_nself = nport;
145 task->itk_sself = ipc_port_make_send(kport);
146 task->itk_space = space;
150 mac_task_label_associate(parent, task, &parent->maclabel,
151 &task->maclabel, &kport->ip_label);
153 mac_task_label_associate_kernel(task, &task->maclabel, &kport->ip_label);
160 task->exc_actions[i].port = IP_NULL;
165 task->itk_host = port;
167 task->itk_bootstrap = IP_NULL;
168 task->itk_seatbelt = IP_NULL;
169 task->itk_gssd = IP_NULL;
170 task->itk_task_access = IP_NULL;
173 task->itk_registered[i] = IP_NULL;
181 task->itk_registered[i] =
187 task->exc_actions[i].port =
189 task->exc_actions[i].flavor =
191 task->exc_actions[i].behavior =
193 task->exc_actions[i].privileged =
196 task->itk_host =
199 task->itk_bootstrap =
202 task->itk_seatbelt =
205 task->itk_gssd =
208 task->itk_task_access =
218 * Enable a task for IPC access.
225 task_t task)
230 itk_lock(task);
231 kport = task->itk_self;
233 ipc_kobject_set(kport, (ipc_kobject_t) task, IKOT_TASK);
234 nport = task->itk_nself;
236 ipc_kobject_set(nport, (ipc_kobject_t) task, IKOT_TASK_NAME);
237 itk_unlock(task);
243 * Disable IPC access to a task.
250 task_t task)
255 itk_lock(task);
256 kport = task->itk_self;
259 nport = task->itk_nself;
262 itk_unlock(task);
268 * Clean up and destroy a task's IPC state.
270 * Nothing locked. The task must be suspended.
271 * (Or the current thread must be in the task.)
276 task_t task)
282 itk_lock(task);
283 kport = task->itk_self;
286 /* the task is already terminated (can this happen?) */
287 itk_unlock(task);
290 task->itk_self = IP_NULL;
292 nport = task->itk_nself;
294 task->itk_nself = IP_NULL;
296 itk_unlock(task);
300 if (IP_VALID(task->itk_sself))
301 ipc_port_release_send(task->itk_sself);
304 if (IP_VALID(task->exc_actions[i].port)) {
305 ipc_port_release_send(task->exc_actions[i].port);
309 if (IP_VALID(task->itk_host))
310 ipc_port_release_send(task->itk_host);
312 if (IP_VALID(task->itk_bootstrap))
313 ipc_port_release_send(task->itk_bootstrap);
315 if (IP_VALID(task->itk_seatbelt))
316 ipc_port_release_send(task->itk_seatbelt);
318 if (IP_VALID(task->itk_gssd))
319 ipc_port_release_send(task->itk_gssd);
321 if (IP_VALID(task->itk_task_access))
322 ipc_port_release_send(task->itk_task_access);
325 if (IP_VALID(task->itk_registered[i]))
326 ipc_port_release_send(task->itk_registered[i]);
332 itk_lock_destroy(task);
338 * Reset a task's IPC state to protect it when
340 * task name port can remain the same - since
343 * Nothing locked. The task must be suspended.
344 * (Or the current thread must be in the task.)
349 task_t task)
360 itk_lock(task);
362 old_kport = task->itk_self;
365 /* the task is already terminated (can this happen?) */
366 itk_unlock(task);
371 task->itk_self = new_kport;
372 old_sself = task->itk_sself;
373 task->itk_sself = ipc_port_make_send(new_kport);
375 ipc_kobject_set(new_kport, (ipc_kobject_t) task, IKOT_TASK);
378 if (!task->exc_actions[i].privileged) {
379 old_exc_actions[i] = task->exc_actions[i].port;
380 task->exc_actions[i].port = IP_NULL;
386 itk_unlock(task);
487 * its task enters an elevated security context.
555 * that only works for the current task.
558 * for the task's user-visible self port.
565 register task_t task)
569 assert(task == current_task());
571 itk_lock(task);
572 assert(task->itk_self != IP_NULL);
574 if ((port = task->itk_sself) == task->itk_self) {
584 itk_unlock(task);
633 * Give the caller send rights for his own task port.
645 task_t task = current_task();
649 sright = retrieve_task_self_fast(task);
650 name = ipc_port_copyout_send(sright, task->itk_space);
670 task_t task = thread->task;
675 name = ipc_port_copyout_send(sright, task->itk_space);
813 * Clones a send right for one of the task's
819 * KERN_INVALID_ARGUMENT The task is null.
820 * KERN_FAILURE The task/space is dead.
826 task_t task,
832 if (task == TASK_NULL)
835 itk_lock(task);
836 if (task->itk_self == IP_NULL) {
837 itk_unlock(task);
843 port = ipc_port_copy_send(task->itk_sself);
847 port = ipc_port_make_send(task->itk_nself);
851 port = ipc_port_copy_send(task->itk_host);
855 port = ipc_port_copy_send(task->itk_bootstrap);
859 port = ipc_port_copy_send(task->itk_seatbelt);
863 port = ipc_port_copy_send(task->itk_task_access);
867 itk_unlock(task);
870 itk_unlock(task);
879 * Changes one of the task's special ports,
886 * KERN_INVALID_ARGUMENT The task is null.
887 * KERN_FAILURE The task/space is dead.
894 task_t task,
901 if (task == TASK_NULL)
906 whichp = &task->itk_sself;
910 whichp = &task->itk_host;
914 whichp = &task->itk_bootstrap;
918 whichp = &task->itk_seatbelt;
922 whichp = &task->itk_task_access;
929 itk_lock(task);
930 if (task->itk_self == IP_NULL) {
931 itk_unlock(task);
935 /* do not allow overwrite of seatbelt or task access ports */
938 itk_unlock(task);
943 if (mac_task_check_service(current_task(), task, "set_special_port")) {
944 itk_unlock(task);
951 itk_unlock(task);
962 * Stash a handful of port send rights in the task.
973 * KERN_INVALID_ARGUMENT The task is null.
974 * KERN_INVALID_ARGUMENT The task is dead.
980 task_t task,
987 if ((task == TASK_NULL) ||
1000 itk_lock(task);
1001 if (task->itk_self == IP_NULL) {
1002 itk_unlock(task);
1014 old = task->itk_registered[i];
1015 task->itk_registered[i] = ports[i];
1019 itk_unlock(task);
1046 * KERN_INVALID_ARGUMENT The task is null.
1047 * KERN_INVALID_ARGUMENT The task is dead.
1053 task_t task,
1062 if (task == TASK_NULL)
1071 itk_lock(task);
1072 if (task->itk_self == IP_NULL) {
1073 itk_unlock(task);
1083 * is wired, we won't fault while holding the task lock.
1087 ports[i] = ipc_port_copy_send(task->itk_registered[i]);
1089 itk_unlock(task);
1100 * task. Used by several routines that try to convert from a
1101 * task port to a reference on some task related object.
1111 task_t task;
1118 task = (task_t) port->ip_kobject;
1119 assert(task != TASK_NULL);
1125 if (task_lock_try(task)) {
1127 return(task);
1140 * Convert from a port to a task.
1141 * Doesn't consume the port ref; produces a task ref,
1150 task_t task = TASK_NULL;
1157 task = (task_t)port->ip_kobject;
1158 assert(task != TASK_NULL);
1160 task_reference_internal(task);
1166 return (task);
1172 * Convert from a port to a task name.
1173 * Doesn't consume the port ref; produces a task name ref,
1182 task_name_t task = TASK_NULL;
1190 task = (task_name_t)port->ip_kobject;
1191 assert(task != TASK_NAME_NULL);
1193 task_reference_internal(task);
1199 return (task);
1216 task_t task;
1218 task = convert_port_to_locked_task(port);
1220 if (task == TASK_NULL)
1223 if (!task->active) {
1224 task_unlock(task);
1228 space = task->itk_space;
1230 task_unlock(task);
1248 task_t task;
1251 task = convert_port_to_locked_task(port);
1253 if (task == TASK_NULL)
1256 if (!task->active) {
1257 task_unlock(task);
1261 map = task->map;
1263 task_unlock(task);
1337 task_t task = TASK_NULL;
1346 task = convert_port_to_task(kern_port);
1351 return task;
1357 * Convert from a task to a port.
1358 * Consumes a task ref; produces a naked send right
1366 task_t task)
1370 itk_lock(task);
1371 if (task->itk_self != IP_NULL)
1372 port = ipc_port_make_send(task->itk_self);
1375 itk_unlock(task);
1377 task_deallocate(task);
1384 * Convert from a task name ref to a port.
1385 * Consumes a task name ref; produces a naked send right
1457 * Sets the thread/task exception port, flavor and
1545 task_t task,
1555 if (task == TASK_NULL)
1574 itk_lock(task);
1576 if (task->itk_self == IP_NULL) {
1577 itk_unlock(task);
1584 old_port[i] = task->exc_actions[i].port;
1585 task->exc_actions[i].port =
1587 task->exc_actions[i].behavior = new_behavior;
1588 task->exc_actions[i].flavor = new_flavor;
1589 task->exc_actions[i].privileged = privileged;
1595 itk_unlock(task);
1610 * Sets the thread/task exception port, flavor and
1732 task_t task,
1747 if (task == TASK_NULL)
1766 itk_lock(task);
1768 if (task->itk_self == IP_NULL) {
1769 itk_unlock(task);
1783 if ( task->exc_actions[i].port == ports[j] &&
1784 task->exc_actions[i].behavior == behaviors[j] &&
1785 task->exc_actions[i].flavor == flavors[j] ) {
1793 ports[j] = ipc_port_copy_send(task->exc_actions[i].port);
1794 behaviors[j] = task->exc_actions[i].behavior;
1795 flavors[j] = task->exc_actions[i].flavor;
1799 old_port[i] = task->exc_actions[i].port;
1800 task->exc_actions[i].port = ipc_port_copy_send(new_port);
1801 task->exc_actions[i].behavior = new_behavior;
1802 task->exc_actions[i].flavor = new_flavor;
1803 task->exc_actions[i].privileged = privileged;
1811 itk_unlock(task);
1828 * Clones a send right for each of the thread/task's exception
1908 task_t task,
1918 if (task == TASK_NULL)
1924 itk_lock(task);
1926 if (task->itk_self == IP_NULL) {
1927 itk_unlock(task);
1941 if ( task->exc_actions[i].port == ports[j] &&
1942 task->exc_actions[i].behavior == behaviors[j] &&
1943 task->exc_actions[i].flavor == flavors[j] ) {
1951 ports[j] = ipc_port_copy_send(task->exc_actions[i].port);
1952 behaviors[j] = task->exc_actions[i].behavior;
1953 flavors[j] = task->exc_actions[i].flavor;
1961 itk_unlock(task);