for (i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT; i++) {
realhost.exc_actions[i].port = IP_NULL;
+ realhost.exc_actions[i].label = NULL;
+ /* The mac framework is not yet initialized, so we defer
+ * initializing the labels to later, when they are set
+ * for the first time. */
}/* for */
/*
host_self_trap(
__unused struct host_self_trap_args *args)
{
+ task_t self = current_task();
ipc_port_t sright;
mach_port_name_t name;
- sright = ipc_port_copy_send(current_task()->itk_host);
+ itk_lock(self);
+ sright = ipc_port_copy_send(self->itk_host);
+ itk_unlock(self);
name = ipc_port_copyout_send(sright, current_space());
return name;
}
host_t host = HOST_NULL;
if (IP_VALID(port)) {
- ip_lock(port);
- if (ip_active(port) &&
- ((ip_kotype(port) == IKOT_HOST) ||
- (ip_kotype(port) == IKOT_HOST_PRIV)
- ))
+ if (ip_kotype(port) == IKOT_HOST ||
+ ip_kotype(port) == IKOT_HOST_PRIV) {
host = (host_t) port->ip_kobject;
- ip_unlock(port);
+ assert(ip_active(port));
+ }
}
-
return host;
}
exception_behavior_t new_behavior,
thread_state_flavor_t new_flavor)
{
- register int i;
+ int i;
ipc_port_t old_port[EXC_TYPES_COUNT];
if (host_priv == HOST_PRIV_NULL) {
host_lock(host_priv);
for (i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT; i++) {
- if (exception_mask & (1 << i)) {
+#if CONFIG_MACF
+ if (host_priv->exc_actions[i].label == NULL) {
+ // Lazy initialization (see ipc_port_init).
+ mac_exc_action_label_init(host_priv->exc_actions + i);
+ }
+#endif
+
+ if ((exception_mask & (1 << i))
+#if CONFIG_MACF
+ && mac_exc_action_label_update(current_task(), host_priv->exc_actions + i) == 0
+#endif
+ ) {
old_port[i] = host_priv->exc_actions[i].port;
+
host_priv->exc_actions[i].port =
ipc_port_copy_send(new_port);
host_priv->exc_actions[i].behavior = new_behavior;
host_priv->exc_actions[i].flavor = new_flavor;
- } else
+ } else {
old_port[i] = IP_NULL;
+ }
}/* for */
/*
count = 0;
for (i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT; i++) {
+#if CONFIG_MACF
+ if (host_priv->exc_actions[i].label == NULL) {
+ // Lazy initialization (see ipc_port_init).
+ mac_exc_action_label_init(host_priv->exc_actions + i);
+ }
+#endif
+
if (exception_mask & (1 << i)) {
for (j = 0; j < count; j++) {
/*
assert(EXC_TYPES_COUNT > FIRST_EXCEPTION);
for (count=0, i = FIRST_EXCEPTION; i < EXC_TYPES_COUNT && count < *CountCnt; i++) {
- if (exception_mask & (1 << i)) {
+#if CONFIG_MACF
+ if (host_priv->exc_actions[i].label == NULL) {
+ // Lazy initialization (see ipc_port_init).
+ mac_exc_action_label_init(host_priv->exc_actions + i);
+ }
+#endif
+
+ if ((exception_mask & (1 << i))
+#if CONFIG_MACF
+ && mac_exc_action_label_update(current_task(), host_priv->exc_actions + i) == 0
+#endif
+ ) {
for (j = 0; j < count; j++) {
/*
* search for an identical entry, if found