Skip to contentSkip to conversation

xen: Fix XSM build following c/s 92942fd

PATCH In review Andrew Cooper 3 participants 6 messages Feb 9, 2016 – Feb 17, 2016

lore
Share & tools
lore
#0 lore raw

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
index 9b7de30..f63c3e2 100644
@@ -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
#1 lore raw
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 17:21, <[email protected]> wrote:

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 -ENOSYS for 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

#2 lore raw
Quoted 15 lines · Jan Beulich
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 09.02.16 at 17:21, <[email protected]> wrote:

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 -ENOSYS for 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 -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.)

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

#3 lore raw
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:

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 -ENOSYS for 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_t op)

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 -1
         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;
Quoted 6 lines

... 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.)

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 -ENOSYS checks.

Daniel?

Jan

#4 lore raw
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:

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 -ENOSYS for 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_t op)

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 -1
          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;
Quoted 6 lines

... 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.)

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 -ENOSYS checks.

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
#5 lore raw
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:

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 -ENOSYS for 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_t op)

Quoted 7 lines
Quoted 7 lines
xen/xsm/flask/hooks.c +0 -1
          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;
Quoted 6 lines

... 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.)

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 -ENOSYS checks.

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.

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