libxl: assigned a default ssid_label (XSM label) to guests
PATCH 1/1 libxl: assigned a default ssid_label (XSM label) to guests
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
This change required moving the call to domain_create_info_setdefault to be before the ssid_label is translated into ssidref, which also moves it before some other stuff which consumes things from c_info, which is correct since setdefault should always be called first. Apart from the SSID handling there should be no functional change (since setdefault doesn't actually act on anything which that other stuff uses).
There is no need to set exec_ssid_label since the default is to leave the domain using the ssid_label after build.
I haven't done anything with the device model ssid.
--- docs/man/xl.cfg.pod.5 | 4 +++- tools/libxl/libxl_create.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)
docs/man/xl.cfg.pod.5 +3 -1
@@ -437,7 +437,9 @@ UUID will be generated. =item B<seclabel="LABEL"> -Assign an XSM security label to this domain. +Assign an XSM security label to this domain. By default a domain is +assigned the label B<system_u:system_r:domU_t>, which is defined in +the default policy. =item B<init_seclabel="LABEL">
tools/libxl/libxl_create.c +8 -3
@@ -42,6 +42,11 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc,libxl_defbool_setdefault (&c_info->run_hotplug_scripts, true);libxl_defbool_setdefault (&c_info->driver_domain, false); +if (!c_info->ssid_label) { + c_info->ssid_label =libxl__strdup (NOGC ,"system_u:system_r:domU_t" ); +LOG (INFO ,"Using default ssid_label: %s" , c_info->ssid_label); + } +return 0 ; }
@@ -802,6 +807,9 @@ static void initiate_domain_create(libxl__egc *egc, domid =0 ; + ret =libxl__domain_create_info_setdefault (gc, &d_config->c_info); +if (ret) goto error_out; +if (d_config->c_info.ssid_label) {char *s = d_config->c_info.ssid_label; ret = libxl_flask_context_to_sid(ctx, s, strlen(s),
@@ -887,9 +895,6 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } - ret =libxl__domain_create_info_setdefault (gc, &d_config->c_info); -if (ret) goto error_out; - ret =libxl__domain_make (gc, d_config, &domid, &state->config);if (ret) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"cannot make domain: %d" , ret);
Signature · 1 line
1.7.10.4
Hi Ian,
Quoted 2 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
So you rule out the possibility to run an unlabelled domain? This is possible if the policy explicitly authorized it. That's a significant change in the libxl behavior.
IHMO, having a default policy doesn't mean libxl should set a default ssid to make XSM transparent to the user.
The explicit ssid makes clear that the guest is using a ssid foo and if it's not provided then it will fail to boot.
Setting a default value may hide a bigger issue and take the wrong policy the user forgot to set up an ssid.
Quoted 10 lines
This change required moving the call to
domain_create_info_setdefaultto be before thessid_labelis translated into ssidref, which also moves it before some other stuff which consumes things fromc_info, which is correct since setdefault should always be called first. Apart from the SSID handling there should be no functional change (since setdefault doesn't actually act on anything which that other stuff uses).There is no need to set
exec_ssid_labelsince the default is to leave the domain using thessid_labelafter build.
By setting a ssid label, libxl will print a new warning on Xen not built with XSM which will confuse the user:
libxl: warning: libxl_create.c:813:initiate_domain_create: XSM Disabled:init_seclabel not supported
Quoted 16 lines
I haven't done anything with the device model ssid.
Signed-off-by Ian Campbell <[email protected]>Cc Daniel De Graaf <[email protected]>--- docs/man/xl.cfg.pod.5 | 4 +++- tools/libxl/libxl_create.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)docs/man/xl.cfg.pod.5 +0
-0
docs/man/xl.cfg.pod.5 UUID will be generated. · line 442
Quoted 7 lines
docs/man/xl.cfg.pod.5 +3
-1@@ -437,7 +437,9 @@ UUID will be generated. =item B<seclabel="LABEL"> -Assign an XSM security label to this domain. +Assign an XSM security label to this domain. By default a domain is +assigned the label B<system_u:system_r:domU_t>, which is defined in +the default policy.
It's not easy to know that seclabel will be stored in ssid_label.
It would be good to have this explanation into the toolstack API.
Regards,
Signature · 1 line
Julien Grall
Quoted 9 lines · Julien Grall
Hi Ian,
Quoted 2 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
So you rule out the possibility to run an unlabelled domain? This is possible if the policy explicitly authorized it. That's a significant change in the libxl behavior.
I didn't realise this was a possibility, wouldn't such a domain be system_u:system_r:unlabeled_t> or something?
Note that this won't override a label which is just '' (i.e. an empty string rather than NULL). I don't know if that results in the behaviour you want.
When this was discussed before (in a conversation Wei started, but which I can't find, maybe it was IRC rather than email) it seemed that consensus was that by default things should Just Work as if XSM weren't disabled, which is what I've implemented here.
Quoted 8 lines
IHMO, having a default policy doesn't mean libxl should set a default ssid to make XSM transparent to the user.
The explicit ssid makes clear that the guest is using a ssid foo and if it's not provided then it will fail to boot.
Setting a default value may hide a bigger issue and take the wrong policy the user forgot to set up an ssid.
Does domU_t really have so many privileges that this is an issue? I'd expect it to be almost totally privilegeless apart from things which any domU needs.
The benefits of XSM seem to mainly apply to the various service domains.
Daniel, do you have an opinion here?
Quoted 9 lines
Quoted 9 lines
This change required moving the call to
domain_create_info_setdefaultto be before thessid_labelis translated into ssidref, which also moves it before some other stuff which consumes things fromc_info, which is correct since setdefault should always be called first. Apart from the SSID handling there should be no functional change (since setdefault doesn't actually act on anything which that other stuff uses).
Quoted 8 lines
Quoted 2 lines
There is no need to set
exec_ssid_labelsince the default is to leave the domain using thessid_labelafter build.By setting a ssid label, libxl will print a new warning on Xen not built with XSM which will confuse the user:
libxl: warning: libxl_create.c:813:initiate_domain_create: XSM Disabled:
init_seclabelnot supported
Ah, I didn't try that case. I'll see if I can work out a way to suppress that warning.
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Julien Grall
Hi Ian,
Quoted 2 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
Quoted 6 lines
Quoted 3 lines
So you rule out the possibility to run an unlabelled domain? This is possible if the policy explicitly authorized it. That's a significant change in the libxl behavior.
I didn't realise this was a possibility, wouldn't such a domain be system_u:system_r:unlabeled_t> or something?
I'm not sure how unlabeled works. I will let Daniel answer to this.
Quoted 3 lines
Note that this won't override a label which is just '' (i.e. an empty string rather than NULL). I don't know if that results in the behaviour you want.
IIRC, NULL means unlabeled. '' would be translated as an invalid ssid and throw an error.
Regards,
Signature · 1 line
Julien Grall
Quoted 7 lines · Ian Campbell
Quoted 6 lines · Julien Grall
Hi Ian,
Quoted 2 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
Quoted 6 lines
Quoted 3 lines
So you rule out the possibility to run an unlabelled domain? This is possible if the policy explicitly authorized it. That's a significant change in the libxl behavior.
I didn't realise this was a possibility, wouldn't such a domain be system_u:system_r:unlabeled_t> or something?
Yes. FLASK resolves any numeric SID value that is unused (including zero) to the unlabeled sid (defined in tools/flask/policy/policy/initial_sids to be system_u:system_r:unlabeled_t). Because this could be the result of an error (in the hypervisor, toolstack, etc), the use of unlabled_t for real objects is discouraged in SELinux and XSM/FLASK.
Quoted 8 lines
Note that this won't override a label which is just '' (i.e. an empty string rather than NULL). I don't know if that results in the behaviour you want.
When this was discussed before (in a conversation Wei started, but which I can't find, maybe it was IRC rather than email) it seemed that consensus was that by default things should Just Work as if XSM weren't disabled, which is what I've implemented here.
I agree that this is a useful feature. It is possible to extend the initial_sids list with new entries that are used by the toolstack instead of by the hypervisor, which could be used to define SECINITSID_DOMU as the default label for a domU created by a toolstack without a label. This is better than hard-coding a string that may not be valid in a given security policy, and it can be associated with a label that better reflects how the policy wishes to treat domains with an "incomplete" configuration file.
The header file defining these SIDs is buried in the hypervisor source tree (xen/xsm/flask/include/flask.h) and is only generated during a build with XSM enabled. It may be simpler to define the value in a shared header and add a BUILD_BUG_ON somewhere in the flask code to check for mismatches.
Quoted 9 lines
Quoted 8 lines
IHMO, having a default policy doesn't mean libxl should set a default ssid to make XSM transparent to the user.
The explicit ssid makes clear that the guest is using a ssid foo and if it's not provided then it will fail to boot.
Setting a default value may hide a bigger issue and take the wrong policy the user forgot to set up an ssid.
Quoted 7 lines
Does
domU_treally have so many privileges that this is an issue? I'd expect it to be almost totally privilegeless apart from things which any domU needs.The benefits of XSM seem to mainly apply to the various service domains.
Daniel, do you have an opinion here?
In the example policy, domU_t should have the same level of access as a normal domain (i.e. not device model stubdom) has with XSM disabled.
The only real difference is that the example policy does not allow any domain to act as a device model to domU_t; it uses domHVM_t and dm_dom_t for this. If you want to use configurations with device model stubdoms that also do not assign labels in the configuration, this distinction will need to be removed.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
This change required moving the call to
domain_create_info_setdefaultto be before thessid_labelis translated into ssidref, which also moves it before some other stuff which consumes things fromc_info, which is correct since setdefault should always be called first. Apart from the SSID handling there should be no functional change (since setdefault doesn't actually act on anything which that other stuff uses).There is no need to set
exec_ssid_labelsince the default is to leave the domain using thessid_labelafter build.
Quoted 8 lines
Quoted 5 lines
By setting a ssid label, libxl will print a new warning on Xen not built with XSM which will confuse the user:
libxl: warning: libxl_create.c:813:initiate_domain_create: XSM Disabled:
init_seclabelnot supportedAh, I didn't try that case. I'll see if I can work out a way to suppress that warning.
I would be fine with removing that warning completely; someone trying to use XSM without it enabled will likely be able to figure out the problem without this error, likely by noticing the "-" labels in xl list -v/-Z.
------------->8-----------------
Example patch adding SECINITSID_DOMU, for testing/reference.
---
tools/flask/policy/policy/initial_sids +1 -0
@@ -12,3 +12,4 @@ sid irq gen_context(system_u:object_r:irq_t,s0) sid iomem gen_context(system_u:object_r:iomem_t,s0) sid ioport gen_context(system_u:object_r:ioport_t,s0) sid device gen_context(system_u:object_r:device_t,s0) +sid domU gen_context(system_u:system_r:domU_t,s0)
tools/libxl/libxl_create.c +2 -0
@@ -815,6 +815,8 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } } + }else { + d_config->c_info.ssidref =11 ;/* SECINITSID_DOMU */ }if (d_config->b_info.exec_ssid_label) {
xen/xsm/flask/policy/initial_sids +1 -0
@@ -13,4 +13,5 @@ sid ioport sid iomem sid irq sid device +sid domU # FLASK
Quoted 12 lines · Daniel De Graaf
Quoted 11 lines · Ian Campbell
Quoted 9 lines · Julien Grall
Hi Ian,
Quoted 2 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
So you rule out the possibility to run an unlabelled domain? This is possible if the policy explicitly authorized it. That's a significant change in the libxl behavior.
Quoted 8 lines
Quoted 2 lines
I didn't realise this was a possibility, wouldn't such a domain be system_u:system_r:unlabeled_t> or something?
Yes. FLASK resolves any numeric SID value that is unused (including zero) to the unlabeled sid (defined in
tools/flask/policy/policy/initial_sidsto be system_u:system_r:unlabeled_t). Because this could be the result of an error (in the hypervisor, toolstack, etc), the use ofunlabled_tfor real objects is discouraged in SELinux and XSM/FLASK.
OK, so I think this rules out using unlabelled_t as a default.
Quoted 9 lines
Quoted 8 lines
Note that this won't override a label which is just '' (i.e. an empty string rather than NULL). I don't know if that results in the behaviour you want.
When this was discussed before (in a conversation Wei started, but which I can't find, maybe it was IRC rather than email) it seemed that consensus was that by default things should Just Work as if XSM weren't disabled, which is what I've implemented here.
Quoted 7 lines
I agree that this is a useful feature. It is possible to extend the
initial_sidslist with new entries that are used by the toolstack instead of by the hypervisor, which could be used to defineSECINITSID_DOMUas the default label for a domU created by a toolstack without a label. This is better than hard-coding a string that may not be valid in a given security policy, and it can be associated with a label that better reflects how the policy wishes to treat domains with an "incomplete" configuration file.
That sounds good.
Quoted 1 line
From the PoV of the code in libxl this would be done by writing ssidref
as a literal number rather than translating a string (judging from your example patch). That works for me.
While looking into this I noticed the existing code is
if (ssid_label)
ssid_ref = translate(ssid_label)
So my first patch has another issue which is that it will override a users attempt to use ssid_ref themselves (which they are entitled to do).
Is ssidref==0 "unused"? i.e. could we use it to differentiate whether the field had been filled in by the user or not? If not is there some other number? Or should we reserve one using the same technique you suggest here for domU?
Quoted 4 lines
The header file defining these SIDs is buried in the hypervisor source tree (
xen/xsm/flask/include/flask.h) and is only generated during a build with XSM enabled. It may be simpler to define the value in a shared header and add aBUILD_BUG_ONsomewhere in the flask code to check for mismatches.
I was about to ask about this. Short of a pretty serious change to the build a BUILD_BUG_ON seems like a reasonable approach.
Quoted 17 lines
Quoted 9 lines
Quoted 8 lines
IHMO, having a default policy doesn't mean libxl should set a default ssid to make XSM transparent to the user.
The explicit ssid makes clear that the guest is using a ssid foo and if it's not provided then it will fail to boot.
Setting a default value may hide a bigger issue and take the wrong policy the user forgot to set up an ssid.
Quoted 7 lines
Does
domU_treally have so many privileges that this is an issue? I'd expect it to be almost totally privilegeless apart from things which any domU needs.The benefits of XSM seem to mainly apply to the various service domains.
Daniel, do you have an opinion here?
Quoted 8 lines
In the example policy,
domU_tshould have the same level of access as a normal domain (i.e. not device model stubdom) has with XSM disabled.The only real difference is that the example policy does not allow any domain to act as a device model to
domU_t; it usesdomHVM_tanddm_dom_tfor this. If you want to use configurations with device model stubdoms that also do not assign labels in the configuration, this distinction will need to be removed.
I'd be inclined to go the other way and either have a default ssid for the DM or to fail if one isn't given (the latter would probably happen anyway due to enforcement?).
Sounds like the default ssidref should be either ~= domU_t of domHVM_t depending on the type of domain? (domU_t is really domPV_t?)
Quoted 18 lines
Quoted 18 lines
Quoted 17 lines
Quoted 11 lines
This change required moving the call to
domain_create_info_setdefaultto be before thessid_labelis translated into ssidref, which also moves it before some other stuff which consumes things fromc_info, which is correct since setdefault should always be called first. Apart from the SSID handling there should be no functional change (since setdefault doesn't actually act on anything which that other stuff uses).There is no need to set
exec_ssid_labelsince the default is to leave the domain using thessid_labelafter build.By setting a ssid label, libxl will print a new warning on Xen not built with XSM which will confuse the user:
libxl: warning: libxl_create.c:813:initiate_domain_create: XSM Disabled:
init_seclabelnot supported
Quoted 6 lines
Quoted 2 lines
Ah, I didn't try that case. I'll see if I can work out a way to suppress that warning.
I would be fine with removing that warning completely; someone trying to use XSM without it enabled will likely be able to figure out the problem without this error, likely by noticing the "-" labels in xl list -v/-Z.
Actually, I think using an SSID as the defaulted thing will remove this message anyway (not sure if it causes another later, I'll check).
Quoted 37 lines
------------->8-----------------
Example patch addingSECINITSID_DOMU, for testing/reference.---
tools/flask/policy/policy/initial_sids +1
-0@@ -12,3 +12,4 @@ sid irq gen_context(system_u:object_r:irq_t,s0) sid iomem gen_context(system_u:object_r:iomem_t,s0) sid ioport gen_context(system_u:object_r:ioport_t,s0) sid device gen_context(system_u:object_r:device_t,s0) +sid domU gen_context(system_u:system_r:domU_t,s0)tools/libxl/libxl_create.c +2
-0@@ -815,6 +815,8 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } } + }else { + d_config->c_info.ssidref =11 ;/* SECINITSID_DOMU */ }if (d_config->b_info.exec_ssid_label) {xen/xsm/flask/policy/initial_sids +1
-0@@ -13,4 +13,5 @@ sid ioport sid iomem sid irq sid device +sid domU # FLASK
Quoted 51 lines · Ian Campbell
Quoted 12 lines · Daniel De Graaf
Quoted 11 lines · Ian Campbell
Quoted 9 lines · Julien Grall
Hi Ian,
Quoted 2 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
So you rule out the possibility to run an unlabelled domain? This is possible if the policy explicitly authorized it. That's a significant change in the libxl behavior.
Quoted 8 lines
Quoted 2 lines
I didn't realise this was a possibility, wouldn't such a domain be system_u:system_r:unlabeled_t> or something?
Yes. FLASK resolves any numeric SID value that is unused (including zero) to the unlabeled sid (defined in
tools/flask/policy/policy/initial_sidsto be system_u:system_r:unlabeled_t). Because this could be the result of an error (in the hypervisor, toolstack, etc), the use ofunlabled_tfor real objects is discouraged in SELinux and XSM/FLASK.OK, so I think this rules out using
unlabelled_tas a default.Quoted 9 lines
Quoted 8 lines
Note that this won't override a label which is just '' (i.e. an empty string rather than NULL). I don't know if that results in the behaviour you want.
When this was discussed before (in a conversation Wei started, but which I can't find, maybe it was IRC rather than email) it seemed that consensus was that by default things should Just Work as if XSM weren't disabled, which is what I've implemented here.
Quoted 7 lines
I agree that this is a useful feature. It is possible to extend the
initial_sidslist with new entries that are used by the toolstack instead of by the hypervisor, which could be used to defineSECINITSID_DOMUas the default label for a domU created by a toolstack without a label. This is better than hard-coding a string that may not be valid in a given security policy, and it can be associated with a label that better reflects how the policy wishes to treat domains with an "incomplete" configuration file.That sounds good.
Quoted 1 line
From the PoV of the code in libxl this would be done by writing ssidref
as a literal number rather than translating a string (judging from your example patch). That works for me.
While looking into this I noticed the existing code is
if (ssid_label)
ssid_ref=translate(ssid_label)
Quoted 8 lines
So my first patch has another issue which is that it will override a users attempt to use
ssid_refthemselves (which they are entitled to do).Is ssidref==0 "unused"? i.e. could we use it to differentiate whether the field had been filled in by the user or not? If not is there some other number? Or should we reserve one using the same technique you suggest here for domU?
Yes, a value of zero is "not populated"; no valid context resolves to a SID of zero (including unlabeled_t, which is properly 5 or so).
Quoted 34 lines
Quoted 4 lines
The header file defining these SIDs is buried in the hypervisor source tree (
xen/xsm/flask/include/flask.h) and is only generated during a build with XSM enabled. It may be simpler to define the value in a shared header and add aBUILD_BUG_ONsomewhere in the flask code to check for mismatches.I was about to ask about this. Short of a pretty serious change to the build a
BUILD_BUG_ONseems like a reasonable approach.Quoted 17 lines
Quoted 9 lines
Quoted 8 lines
IHMO, having a default policy doesn't mean libxl should set a default ssid to make XSM transparent to the user.
The explicit ssid makes clear that the guest is using a ssid foo and if it's not provided then it will fail to boot.
Setting a default value may hide a bigger issue and take the wrong policy the user forgot to set up an ssid.
Quoted 7 lines
Does
domU_treally have so many privileges that this is an issue? I'd expect it to be almost totally privilegeless apart from things which any domU needs.The benefits of XSM seem to mainly apply to the various service domains.
Daniel, do you have an opinion here?
Quoted 8 lines
In the example policy,
domU_tshould have the same level of access as a normal domain (i.e. not device model stubdom) has with XSM disabled.The only real difference is that the example policy does not allow any domain to act as a device model to
domU_t; it usesdomHVM_tanddm_dom_tfor this. If you want to use configurations with device model stubdoms that also do not assign labels in the configuration, this distinction will need to be removed.
Quoted 3 lines
I'd be inclined to go the other way and either have a default ssid for the DM or to fail if one isn't given (the latter would probably happen anyway due to enforcement?).
Yes, it would probably fail at xc_domain_set_target in enforcing mode.
Quoted 2 lines
Sounds like the default ssidref should be either ~=
domU_tofdomHVM_tdepending on the type of domain? (domU_tis reallydomPV_t?)
The domU_t type also works for HVM domains with the device model in dom0.
Looking at the problem again, I think a second initial SID for the device model would be preferable, removing domHVM_t completely. There are already other example types in the policy for domains that do not use a device model (isolated_domU_t is probably the best example), and the result more closely matches the permissions used in the hypervisor without XSM enabled.
Signature · 2 lines
Daniel De Graaf National Security Agency
Quoted 9 lines · Daniel De Graaf
Quoted 3 lines
I'd be inclined to go the other way and either have a default ssid for the DM or to fail if one isn't given (the latter would probably happen anyway due to enforcement?).
Yes, it would probably fail at
xc_domain_set_targetin enforcing mode.Quoted 2 lines
Sounds like the default ssidref should be either ~=
domU_tofdomHVM_tdepending on the type of domain? (domU_tis reallydomPV_t?)
Quoted 7 lines
The
domU_ttype also works for HVM domains with the device model in dom0.Looking at the problem again, I think a second initial SID for the device model would be preferable, removing
domHVM_tcompletely. There are already other example types in the policy for domains that do not use a device model (isolated_domU_tis probably the best example), and the result more closely matches the permissions used in the hypervisor without XSM enabled.
I'm aroundabout half sure what you are proposing here, but I trust it makes sense ;-).
I think for now I will investigate using a default ssid for all domains, which AIUI from above will work out of the box with PV guests and HVM ones which have qemu in dom0.
For the stubdom case I think I'll leave it to you to change the default policy, at which point I'll be happy to extend things to a default ssid for stubdom too.
Ian.
Quoted 7 lines · Ian Campbell
Quoted 4 lines
The header file defining these SIDs is buried in the hypervisor source tree (
xen/xsm/flask/include/flask.h) and is only generated during a build with XSM enabled. It may be simpler to define the value in a shared header and add aBUILD_BUG_ONsomewhere in the flask code to check for mismatches.I was about to ask about this. Short of a pretty serious change to the build a
BUILD_BUG_ONseems like a reasonable approach.
To what extent is a user's customized (e.g. potentially clean room implemented) policy required to match what goes on here? I suspect the answer is "fully" and that any custom policy must therefore use exactly the policy/security_classes and policy/initial_sids as was used when Xen was built.
If this coupling already exists then I see no particular harm in extending it to the tools as well, although I think I might see about making the header available for checking even in non-xsm builds (since I don't really want to add an xsm compile time option to the tools, nor to rely on the xsm builds catching errors for non-xsm usage).
BTW, I seem to have two of each of security_classes and initial_sids in my tree, one in tools/flask/policy/policy/ and the other in xen/xsm/flask/policy/ and they appear to differ.
The xen initial_sids appears to be derived from the tools one, whereas security_classes looks different.
Ian.
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Ian Campbell
Quoted 4 lines
The header file defining these SIDs is buried in the hypervisor source tree (
xen/xsm/flask/include/flask.h) and is only generated during a build with XSM enabled. It may be simpler to define the value in a shared header and add aBUILD_BUG_ONsomewhere in the flask code to check for mismatches.
Quoted 8 lines
Quoted 2 lines
I was about to ask about this. Short of a pretty serious change to the build a
BUILD_BUG_ONseems like a reasonable approach.To what extent is a user's customized (e.g. potentially clean room implemented) policy required to match what goes on here? I suspect the answer is "fully" and that any custom policy must therefore use exactly the policy/security_classes and policy/initial_sids as was used when Xen was built.
When rewriting the security policy, xen/xsm/flask/policy/initial_sids is expected to remain unchanged, while tools/flask/policy/policy/initial_sids can be modified to suit the types defined in the rewritten policy. This applies to all the files split between the two directories.
Quoted 6 lines
If this coupling already exists then I see no particular harm in extending it to the tools as well, although I think I might see about making the header available for checking even in non-xsm builds (since I don't really want to add an xsm compile time option to the tools, nor to rely on the xsm builds catching errors for non-xsm usage).
Quoted 6 lines
BTW, I seem to have two of each of
security_classesandinitial_sidsin my tree, one intools/flask/policy/policy/and the other in xen/xsm/flask/policy/ and they appear to differ.The xen
initial_sidsappears to be derived from the tools one, whereassecurity_classeslooks different.
The security_classes and access_vectors in the local policy (tools/...) are intended to be used by components outside the hypervisor that do not implement their own security policy. The current example policy defines a class for xenstore permissions, but since xenstore does not actually use this, it is just an example.
Signature · 2 lines
Daniel De Graaf National Security Agency
Quoted 16 lines · Daniel De Graaf
Quoted 6 lines · Ian Campbell
Quoted 5 lines · Ian Campbell
Quoted 4 lines
The header file defining these SIDs is buried in the hypervisor source tree (
xen/xsm/flask/include/flask.h) and is only generated during a build with XSM enabled. It may be simpler to define the value in a shared header and add aBUILD_BUG_ONsomewhere in the flask code to check for mismatches.Quoted 8 lines
Quoted 2 lines
I was about to ask about this. Short of a pretty serious change to the build a
BUILD_BUG_ONseems like a reasonable approach.To what extent is a user's customized (e.g. potentially clean room implemented) policy required to match what goes on here? I suspect the answer is "fully" and that any custom policy must therefore use exactly the policy/security_classes and policy/initial_sids as was used when Xen was built.
Quoted 4 lines
When rewriting the security policy, xen/xsm/flask/policy/initial_sids is expected to remain unchanged, while
tools/flask/policy/policy/initial_sidscan be modified to suit the types defined in the rewritten policy. This applies to all the files split between the two directories.
Makes sense.
Quoted 1 line
From the PoV of this series I think I just need to expose
xen/xsm/flask/policy/initial_sids (via mkflask.sh to generate a header) to the tools.
I'll arrange for that to happen in v2.
Thanks,
Ian.
Quoted 44 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
This change required moving the call to
domain_create_info_setdefaultto be before thessid_labelis translated into ssidref, which also moves it before some other stuff which consumes things fromc_info, which is correct since setdefault should always be called first. Apart from the SSID handling there should be no functional change (since setdefault doesn't actually act on anything which that other stuff uses).There is no need to set
exec_ssid_labelsince the default is to leave the domain using thessid_labelafter build.I haven't done anything with the device model ssid.
Signed-off-by Ian Campbell <[email protected]>Cc Daniel De Graaf <[email protected]>--- docs/man/xl.cfg.pod.5 | 4 +++- tools/libxl/libxl_create.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)docs/man/xl.cfg.pod.5 +3
-1@@ -437,7 +437,9 @@ UUID will be generated. =item B<seclabel="LABEL"> -Assign an XSM security label to this domain. +Assign an XSM security label to this domain. By default a domain is +assigned the label B<system_u:system_r:domU_t>, which is defined in +the default policy. =item B<init_seclabel="LABEL">tools/libxl/libxl_create.c +0
-0
tools/libxl/libxl_create.c int libxl__domain_create_info_setdefault(libxl__gc *gc, · line 47
Quoted 6 lines
tools/libxl/libxl_create.c +3
-0@@ -42,6 +42,11 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc,libxl_defbool_setdefault (&c_info->run_hotplug_scripts, true);libxl_defbool_setdefault (&c_info->driver_domain, false); +if (!c_info->ssid_label) { + c_info->ssid_label =libxl__strdup (NOGC ,"system_u:system_r:domU_t" ); +LOG (INFO ,"Using default ssid_label: %s" , c_info->ssid_label);
I don't think this is right. For one, the label you hardcoded here is defined in the policy we ship. It doesn't necessarily exist in the policy that is loaded by system admin.
Another thing, as Julien said, is that this generates a warning in Xen that is not compiled with XSM support.
By definition if you don't label a domain, it should be labeled as "unlabeled". We already do the right thing.
Wei.
Quoted 27 lines
tools/libxl/libxl_create.c +5
-3+ } +return 0 ; }@@ -802,6 +807,9 @@ static void initiate_domain_create(libxl__egc *egc, domid =0 ; + ret =libxl__domain_create_info_setdefault (gc, &d_config->c_info); +if (ret) goto error_out; +if (d_config->c_info.ssid_label) {char *s = d_config->c_info.ssid_label; ret = libxl_flask_context_to_sid(ctx, s, strlen(s),@@ -887,9 +895,6 @@ static void initiate_domain_create(libxl__egc *egc, goto error_out; } - ret =libxl__domain_create_info_setdefault (gc, &d_config->c_info); -if (ret) goto error_out; - ret =libxl__domain_make (gc, d_config, &domid, &state->config);if (ret) {LIBXL__LOG (ctx,LIBXL__LOG_ERROR ,"cannot make domain: %d" , ret);Signature · 1 line
1.7.10.4
Quoted 48 lines · Wei Liu
Quoted 47 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
This change required moving the call to
domain_create_info_setdefaultto be before thessid_labelis translated into ssidref, which also moves it before some other stuff which consumes things fromc_info, which is correct since setdefault should always be called first. Apart from the SSID handling there should be no functional change (since setdefault doesn't actually act on anything which that other stuff uses).There is no need to set
exec_ssid_labelsince the default is to leave the domain using thessid_labelafter build.I haven't done anything with the device model ssid.
Signed-off-by Ian Campbell <[email protected]>Cc Daniel De Graaf <[email protected]>--- docs/man/xl.cfg.pod.5 | 4 +++- tools/libxl/libxl_create.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)docs/man/xl.cfg.pod.5 +3
-1@@ -437,7 +437,9 @@ UUID will be generated. =item B<seclabel="LABEL"> -Assign an XSM security label to this domain. +Assign an XSM security label to this domain. By default a domain is +assigned the label B<system_u:system_r:domU_t>, which is defined in +the default policy. =item B<init_seclabel="LABEL">tools/libxl/libxl_create.c +0
-0@@ -42,6 +42,11 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc,libxl_defbool_setdefault (&c_info->run_hotplug_scripts, true);libxl_defbool_setdefault (&c_info->driver_domain, false);
Quoted 7 lines
tools/libxl/libxl_create.c int libxl__domain_create_info_setdefault(libxl__gc *gc, · line 47
Quoted 3 lines
tools/libxl/libxl_create.c +3
-0+if (!c_info->ssid_label) { + c_info->ssid_label =libxl__strdup (NOGC ,"system_u:system_r:domU_t" ); +LOG (INFO ,"Using default ssid_label: %s" , c_info->ssid_label);I don't think this is right. For one, the label you hardcoded here is defined in the policy we ship. It doesn't necessarily exist in the policy that is loaded by system admin.
Personally I think that's fine, you either use the default, or you make sure your custom policy has a domU_t role (a very reasonable thing to have) or you specify something custom for every domain.
Quoted 5 lines
Another thing, as Julien said, is that this generates a warning in Xen that is not compiled with XSM support.
By definition if you don't label a domain, it should be labeled as "unlabeled". We already do the right thing.
So how come osstest is failing? What should we do instead?
Ian.
Quoted 61 lines · Ian Campbell
Quoted 48 lines · Wei Liu
Quoted 47 lines · Ian Campbell
system_u:system_r:domU_t is defined in the default policy and makes as much sense as anything for a default.
This change required moving the call to
domain_create_info_setdefaultto be before thessid_labelis translated into ssidref, which also moves it before some other stuff which consumes things fromc_info, which is correct since setdefault should always be called first. Apart from the SSID handling there should be no functional change (since setdefault doesn't actually act on anything which that other stuff uses).There is no need to set
exec_ssid_labelsince the default is to leave the domain using thessid_labelafter build.I haven't done anything with the device model ssid.
Signed-off-by Ian Campbell <[email protected]>Cc Daniel De Graaf <[email protected]>--- docs/man/xl.cfg.pod.5 | 4 +++- tools/libxl/libxl_create.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)docs/man/xl.cfg.pod.5 +3
-1@@ -437,7 +437,9 @@ UUID will be generated. =item B<seclabel="LABEL"> -Assign an XSM security label to this domain. +Assign an XSM security label to this domain. By default a domain is +assigned the label B<system_u:system_r:domU_t>, which is defined in +the default policy. =item B<init_seclabel="LABEL">tools/libxl/libxl_create.c +0
-0@@ -42,6 +42,11 @@ int libxl__domain_create_info_setdefault(libxl__gc *gc,libxl_defbool_setdefault (&c_info->run_hotplug_scripts, true);libxl_defbool_setdefault (&c_info->driver_domain, false);Quoted 7 lines
tools/libxl/libxl_create.c int libxl__domain_create_info_setdefault(libxl__gc *gc, · line 47
Quoted 3 lines
tools/libxl/libxl_create.c +3
-0+if (!c_info->ssid_label) { + c_info->ssid_label =libxl__strdup (NOGC ,"system_u:system_r:domU_t" ); +LOG (INFO ,"Using default ssid_label: %s" , c_info->ssid_label);I don't think this is right. For one, the label you hardcoded here is defined in the policy we ship. It doesn't necessarily exist in the policy that is loaded by system admin.
Personally I think that's fine, you either use the default, or you make sure your custom policy has a
domU_trole (a very reasonable thing to have) or you specify something custom for every domain.
Quoted 8 lines
Quoted 5 lines
Another thing, as Julien said, is that this generates a warning in Xen that is not compiled with XSM support.
By definition if you don't label a domain, it should be labeled as "unlabeled". We already do the right thing.
So how come osstest is failing? What should we do instead?
AIUI current policy doesn't allow unlabeled domain to do certain things. Maybe we can figure out a way to tune the policy to give certain permissions to unlabeled domain.
This would need input from Daniel to know if it is achievable.
Wei.
Quoted 1 line
Ian.
Quoted 6 lines · Wei Liu
Quoted 2 lines
So how come osstest is failing? What should we do instead?
AIUI current policy doesn't allow unlabeled domain to do certain things. Maybe we can figure out a way to tune the policy to give certain permissions to unlabeled domain.
What about adding a seclabel entry in the domain configuration file?
Regards,
Signature · 1 line
Julien Grall
Quoted 9 lines · Julien Grall
Quoted 6 lines · Wei Liu
Quoted 2 lines
So how come osstest is failing? What should we do instead?
AIUI current policy doesn't allow unlabeled domain to do certain things. Maybe we can figure out a way to tune the policy to give certain permissions to unlabeled domain.
What about adding a seclabel entry in the domain configuration file?
I think Ian J has argued against that, but I will let him speak for himself in case I'm misremembering.
Ian.