xen: Fix XSM build following c/s 92942fd
PATCH 1/1 xen: Fix XSM build following c/s 92942fd
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Daniel De Graaf <[email protected]>
Is this actually an appropraite fix? Software relying on -ENOSYS for Xen feature detection is going to break when running under an XSM hypervisor.
--- xen/xsm/flask/hooks.c | 1 - 1 file changed, 1 deletion(-)
xen/xsm/flask/hooks.c +0 -1
@@ -1421,7 +1421,6 @@ static int flask_shadow_control(struct domain *d, uint32_t op)break ;case XEN_DOMCTL_SHADOW_OP_ENABLE :case XEN_DOMCTL_SHADOW_OP_ENABLE_TEST : -case XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE :case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION :case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION : perm =SHADOW__ENABLE ;
Signature · 1 line
2.1.4
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 17:21, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>
I'm sorry for the breakage / not noticing.
Quoted 8 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Daniel De Graaf <[email protected]>Is this actually an appropraite fix? Software relying on
-ENOSYSfor Xen feature detection is going to break when running under an XSM hypervisor.
That's a valid concern, and it's certainly not nice for XSM to need tweaking here at all. Perhaps ...
xen/xsm/flask/hooks.c static int flask_shadow_control(struct domain *d, uint32_t op) · line 1426
Quoted 10 lines
xen/xsm/flask/hooks.c +0
-1@@ -1421,7 +1421,6 @@ static int flask_shadow_control(struct domain *d, uint32_t op)break ;case XEN_DOMCTL_SHADOW_OP_ENABLE :case XEN_DOMCTL_SHADOW_OP_ENABLE_TEST : -case XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE :case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION :case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION : perm =SHADOW__ENABLE ;
... rather than just removing the case it should be moved to a separate case yielding -ENOSYS or -EOPNOTSUPP (right now shadow_domctl() returns -EINVAL anyway afaics)? (This of course would mean that we can't completely suppress the XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE #define in public/domctl.h. We could limit it to __XEN__ though.)
Jan
Quoted 15 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 17:21, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>I'm sorry for the breakage / not noticing.
Quoted 8 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Daniel De Graaf <[email protected]>Is this actually an appropraite fix? Software relying on
-ENOSYSfor Xen feature detection is going to break when running under an XSM hypervisor.That's a valid concern, and it's certainly not nice for XSM to need tweaking here at all. Perhaps ...
Quoted 16 lines
xen/xsm/flask/hooks.c static int flask_shadow_control(struct domain *d, uint32_t op) · line 1426
Quoted 10 lines
xen/xsm/flask/hooks.c +0
-1@@ -1421,7 +1421,6 @@ static int flask_shadow_control(struct domain *d, uint32_t op)break ;case XEN_DOMCTL_SHADOW_OP_ENABLE :case XEN_DOMCTL_SHADOW_OP_ENABLE_TEST : -case XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE :case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION :case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION : perm =SHADOW__ENABLE ;... rather than just removing the case it should be moved to a separate case yielding
-ENOSYSor-EOPNOTSUPP(right nowshadow_domctl()returns-EINVALanyway afaics)? (This of course would mean that we can't completely suppress theXEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE#define inpublic/domctl.h. We could limit it to__XEN__though.)
The problem this creates is that we gain two locations prescribing the authoritative set of supported actions, which is one too many.
The first question is whether blanket -EPERMs are ok. This is the current behaviour, and as such, this patch should probably be taken in this form. (i.e. fix the build and maintain the status quo).
If blanket -EPERMs are not ok, we are going to need some longer work to make the XSM checks finer grained, and after the primary -ENOSYS checks.
~Andrew
Quoted 35 lines
Quoted 1 line
Quoted 1 line · On 10.02.16 at 11:39, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 17:21, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>I'm sorry for the breakage / not noticing.
Quoted 6 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Daniel De Graaf <[email protected]>Quoted 8 lines
Quoted 2 lines
Is this actually an appropraite fix? Software relying on
-ENOSYSfor Xen feature detection is going to break when running under an XSM hypervisor.That's a valid concern, and it's certainly not nice for XSM to need tweaking here at all. Perhaps ...
xen/xsm/flask/hooks.c static int flask_shadow_control(struct domain *d,
Quoted 3 lines
xen/xsm/flask/hooks.c +0
-0@@ -1421,7 +1421,6 @@ static int flask_shadow_control(struct domain *d,
uint32_top)Quoted 7 lines
xen/xsm/flask/hooks.c static int flask_shadow_control(struct domain *d, uint32_t op) · line 1426
Quoted 7 lines
xen/xsm/flask/hooks.c +0
-1break ;case XEN_DOMCTL_SHADOW_OP_ENABLE :case XEN_DOMCTL_SHADOW_OP_ENABLE_TEST : -case XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE :case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION :case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION : perm =SHADOW__ENABLE ;Quoted 6 lines
... rather than just removing the case it should be moved to a separate case yielding
-ENOSYSor-EOPNOTSUPP(right nowshadow_domctl()returns-EINVALanyway afaics)? (This of course would mean that we can't completely suppress theXEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE#define inpublic/domctl.h. We could limit it to__XEN__though.)
Quoted 6 lines
The problem this creates is that we gain two locations prescribing the authoritative set of supported actions, which is one too many.
The first question is whether blanket -EPERMs are ok. This is the current behaviour, and as such, this patch should probably be taken in this form. (i.e. fix the build and maintain the status quo).
I'm fine with that, and I think I'm not going to wait for Daniel's ack in this obvious case.
Quoted 2 lines
If blanket -EPERMs are not ok, we are going to need some longer work to make the XSM checks finer grained, and after the primary
-ENOSYSchecks.
Daniel?
Jan
Quoted 38 lines · Jan Beulich
Quoted 38 lines
Quoted 1 line
Quoted 1 line · On 10.02.16 at 11:39, <[email protected]> wrote:
Quoted 10 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 17:21, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>I'm sorry for the breakage / not noticing.
Quoted 6 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Daniel De Graaf <[email protected]>Quoted 8 lines
Quoted 2 lines
Is this actually an appropraite fix? Software relying on
-ENOSYSfor Xen feature detection is going to break when running under an XSM hypervisor.That's a valid concern, and it's certainly not nice for XSM to need tweaking here at all. Perhaps ...
xen/xsm/flask/hooks.c static int flask_shadow_control(struct domain *d,
Quoted 3 lines
xen/xsm/flask/hooks.c +0
-0@@ -1421,7 +1421,6 @@ static int flask_shadow_control(struct domain *d,
uint32_top)Quoted 7 lines
xen/xsm/flask/hooks.c static int flask_shadow_control(struct domain *d, uint32_t op) · line 1426
Quoted 7 lines
xen/xsm/flask/hooks.c +0
-1break ;case XEN_DOMCTL_SHADOW_OP_ENABLE :case XEN_DOMCTL_SHADOW_OP_ENABLE_TEST : -case XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE :case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION :case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION : perm =SHADOW__ENABLE ;Quoted 6 lines
... rather than just removing the case it should be moved to a separate case yielding
-ENOSYSor-EOPNOTSUPP(right nowshadow_domctl()returns-EINVALanyway afaics)? (This of course would mean that we can't completely suppress theXEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE#define inpublic/domctl.h. We could limit it to__XEN__though.)The problem this creates is that we gain two locations prescribing the authoritative set of supported actions, which is one too many.
Quoted 6 lines
Quoted 3 lines
The first question is whether blanket -EPERMs are ok. This is the current behaviour, and as such, this patch should probably be taken in this form. (i.e. fix the build and maintain the status quo).
I'm fine with that, and I think I'm not going to wait for Daniel's ack in this obvious case.
That's fine; it seems an obvious fix anyway.
Quoted 5 lines
Quoted 3 lines
If blanket -EPERMs are not ok, we are going to need some longer work to make the XSM checks finer grained, and after the primary
-ENOSYSchecks.Daniel?
The blanket -EPERM is there to catch adding new sub-operations that would otherwise be allowed without any access check. The same is true for most of the other switch statements in flask/hooks.c, although they tend to also have an error message.
The alternatives to the -EPERM return that I can think of are:
1. Change the default -EPERM to a return 0. This requires being more careful when adding sub-operations to ensure that they are protected by access control.
2. Change the default -EPERM to -ENOSYS. This feels like a layering violation to me, but it would make the error correct.
3. Break the xsm_shadow_control hook into 3 hooks, one per permission, and invoke them before taking actions instead of a blanket per-op.
4. Do -ENOSYS checking prior to XSM checking.
Any of them work, it really depends on what would be easiest to maintain and provides the sanest interface. I don't have a real preference for any of them over the current situation.
Signature · 2 lines
Daniel De Graaf National Security Agency
Quoted 73 lines · Daniel De Graaf
Quoted 41 lines · Jan Beulich
Quoted 41 lines
Quoted 1 line
Quoted 1 line · On 10.02.16 at 11:39, <[email protected]> wrote:
Quoted 14 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 17:21, <[email protected]> wrote:
Signed-off-by Andrew Cooper <[email protected]>I'm sorry for the breakage / not noticing.
Quoted 10 lines
---
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Ian Campbell <[email protected]>
CC: Daniel De Graaf <[email protected]>Is this actually an appropraite fix? Software relying on
-ENOSYSfor Xen
feature detection is going to break when running under an XSM hypervisor.Quoted 7 lines
That's a valid concern, and it's certainly not nice for XSM to need tweaking here at all. Perhaps ...
xen/xsm/flask/hooks.c static int flask_shadow_control(struct · line 1421
Quoted 4 lines
xen/xsm/flask/hooks.c +0
-0@@ -1421,7 +1421,6 @@ static int flask_shadow_control(struct domain *d,
uint32_top)Quoted 7 lines
Quoted 7 lines
xen/xsm/flask/hooks.c +0
-1break ;case XEN_DOMCTL_SHADOW_OP_ENABLE :case XEN_DOMCTL_SHADOW_OP_ENABLE_TEST : -case XEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE :case XEN_DOMCTL_SHADOW_OP_GET_ALLOCATION :case XEN_DOMCTL_SHADOW_OP_SET_ALLOCATION :perm = SHADOW__ENABLE;Quoted 6 lines
... rather than just removing the case it should be moved to a separate case yielding
-ENOSYSor-EOPNOTSUPP(right nowshadow_domctl()returns-EINVALanyway afaics)? (This of course would mean that we can't completely suppress theXEN_DOMCTL_SHADOW_OP_ENABLE_TRANSLATE#define inpublic/domctl.h. We could limit it to__XEN__though.)The problem this creates is that we gain two locations prescribing the authoritative set of supported actions, which is one too many.
Quoted 6 lines
Quoted 3 lines
The first question is whether blanket -EPERMs are ok. This is the current behaviour, and as such, this patch should probably be taken in this form. (i.e. fix the build and maintain the status quo).
I'm fine with that, and I think I'm not going to wait for Daniel's ack in this obvious case.
That's fine; it seems an obvious fix anyway.
Quoted 6 lines
Quoted 4 lines
If blanket -EPERMs are not ok, we are going to need some longer work to make the XSM checks finer grained, and after the primary
-ENOSYSchecks.Daniel?
The blanket
-EPERMis there to catch adding new sub-operations that would otherwise be allowed without any access check. The same is true for most of the other switch statements inflask/hooks.c, although they tend to also have an error message.The alternatives to the
-EPERMreturn that I can think of are:
1. Change the default-EPERMto a return 0. This requires being more careful when adding sub-operations to ensure that they are protected by access control.
2. Change the default-EPERMto-ENOSYS. This feels like a layering violation to me, but it would make the error correct.
3. Break thexsm_shadow_controlhook into 3 hooks, one per permission, and invoke them before taking actions instead of a blanket per-op.
4. Do-ENOSYSchecking prior to XSM checking.
Quoted 4 lines
Any of them work, it really depends on what would be easiest to maintain and provides the sanest interface. I don't have a real preference for any of them over the current situation.
Hmm - none of these are ideal. 2 is a layering violation, and all the others lead to the same increased risk of accidentally missing the check on certain subops paths.
In particular, the -ENOSYS checking becomes harder when we have nested decode functions (e.g. arch_domctl() called from the default case in do_domctl())
~Andrew