migrate_domain_out(dom0_t, domU_t)
domain_self_comms(domU_t)
+# Allow the hypervisor to build domains of type domU_t
+xen_build_domain(domU_t)
+
# Device model for domU_t. You can define distinct types for device models for
# domains of other types, or add more make_device_model lines for this type.
declare_domain(dm_dom_t)
#include <conditional.h>
#include "private.h"
+#ifdef CONFIG_X86
+#include <asm/pv/shim.h>
+#else
+#define pv_shim false
+#endif
+
static uint32_t domain_sid(const struct domain *dom)
{
struct domain_security_struct *dsec = dom->ssid;
if ( !dsec )
return -ENOMEM;
+ /* Set as unlabeled then change as appropriate. */
+ dsec->sid = SECINITSID_UNLABELED;
+
switch ( d->domain_id )
{
case DOMID_IDLE:
dsec->sid = SECINITSID_DOMIO;
break;
default:
- dsec->sid = SECINITSID_UNLABELED;
+ if ( domain_sid(current->domain) == SECINITSID_XENBOOT )
+ {
+ if ( d->is_privileged )
+ dsec->sid = SECINITSID_DOM0;
+ else if ( pv_shim )
+ dsec->sid = SECINITSID_DOMU;
+ }
}
dsec->self_sid = dsec->sid;
struct domain_security_struct *dsec = d->ssid;
static int dom0_created = 0;
- if ( is_idle_domain(current->domain) && !dom0_created )
+ /*
+ * If the null label is passed, then use the label from security context
+ * allocation. NB: if the label from the allocated security context is also
+ * null, the security server will use unlabeled_t for the domain.
+ */
+ if ( ssidref == 0 )
+ ssidref = dsec->sid;
+
+ /*
+ * First check if the current domain is allowed to create the target domain
+ * type before making changes to the current state.
+ */
+ rc = avc_current_has_perm(ssidref, SECCLASS_DOMAIN, DOMAIN__CREATE, NULL);
+ if ( rc )
+ return rc;
+
+ /*
+ * The dom0_t label is expressed as a singleton label in the base policy.
+ * This cannot be enforced by the security server, therefore it will be
+ * enforced here.
+ */
+ if ( ssidref == SECINITSID_DOM0 )
{
- dsec->sid = SECINITSID_DOM0;
- dom0_created = 1;
+ if ( !dom0_created )
+ dom0_created = 1;
+ else
+ return -EINVAL;
}
- else
- {
- rc = avc_current_has_perm(ssidref, SECCLASS_DOMAIN,
- DOMAIN__CREATE, NULL);
- if ( rc )
- return rc;
- dsec->sid = ssidref;
- }
+ dsec->sid = ssidref;
dsec->self_sid = dsec->sid;
rc = security_transition_sid(dsec->sid, dsec->sid, SECCLASS_DOMAIN,