Skip to contentSkip to conversation

hvm/altp2m: Clarify the proper way to extend the altp2m interface

PATCH Superseded George Dunlap 5 participants 15 messages Jul 10, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hvm/altp2m: Clarify the proper way to extend the altp2m interface

The altp2m functionality was originally envisioned to be used in several different configurations, one of which was a single in-guest agent that had full operational control of altp2m. This required the single hypercall to be an HVMOP, which is the only type of hypercall an HVM guest is allowed to make.

Exposing the altp2m functionality to the guest was controversial at the time, but was ultimately accepted. The fact that altp2m is an HVMOP rather than a DOMCTL has caused some problems, however, for those moving forward trying to extend the interface: Extending the interface even for the 'external' use case now means extending an HVMOP, which implicitly extends the surface of attack for the 'internal' use case as well. The result has been that every addition to this interface has also been controversial.

Settle the controversy once and for all by documenting 1) the purpose of the altp2m interface, and 2) how to extend it. In particular:

* Specify that the fully in-guest agent is a target use case

* Specify that all extensions to altp2m functionality should be subops of the HVMOP hypercall

* Specify that new subops should be disabled in ALTP2M_mixed mode by default, unless specifically evaluated as being useful for the 'internal' use case.

Hopefully this will allow the altp2m interface to be developed further without unnecessary controversy.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Konrad Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Tamas K Lengyel <[email protected]>
CC: Lars Kurth <[email protected]>

As far as I can tell there are three possible solutions to this controversy:

A. Remove the 'internal' functionality as a target by converting the current HVMOP into a DOMCTL.

B. Have two hypercalls -- an HVMOP which contains functionality expected to be used by the 'internal' agent, and a DOMCTL for functionality which is expected to be used only be the 'internal' agent.

C. Agree to add all new subops to the current hypercall (HVMOP), even if we're not sure if they should be exposed to the guest.

I think A is a terrible idea. Having a single in-guest agent is a reasonable design choice, and apparently it was even implemented at some point; we should make it straightforward for someone in the future to pick up the work if they want to.

I think B is also a terrible idea. The people extending it at the moment are primarily concerned with the 'external' use case. There is nobody around to represent whether new functionality should end up in the HVMOP or the DOMCTL, which means that by default it will end up in the DOMCTL. If it is discovered, afterwards, that the new operations *would* be safe and useful for the 'internal' use case, then we will have to duplicate them inside the HVMOP.

It just makes more sense to have all the altp2m operations in a single place, and a simple way to control whether they're available to the 'internal' use case or not. As such, I am proposing 'C'. I know Jan considers this "badness", and objects to the continual "extension" of the "badness", but I disagree, and I strongly object to the other two options.

Disabling new subops for the 'internal' use case by default means that we can add new subops without worrying about making the 'internal' use case less secure; but if in the future someone makes the case that they are safe and necessary, we can enable them without having code duplication.

In any case need to come to an agreement once and for all so that Tamas and Razvan can do their work without continual arguments over a mode they're not using.

---
 xen/arch/x86/hvm/hvm.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
xen/arch/x86/hvm/hvm.c +28 -0
index e022f5ab0e..90a4be5e86 100644
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
+ *   as modifying altp2m entires).
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.
+ *
+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs.  But in order
+ * to properly enable the 'internal' use case, as well as to avoid
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.
+ *
+ * New subops which may not be suitable for the 'internal' use case
+ * should be disabled in the "XEN_ALTP2M_mixed" case in
+ * xsm_hvm_altp2mhvm_op().
+ */
 static int do_altp2m_op(
     XEN_GUEST_HANDLE_PARAM(void) arg)
 {
Signature · 7 lines
2.18.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw
Quoted 5 lines · George Dunlap

The altp2m functionality was originally envisioned to be used in several different configurations, one of which was a single in-guest agent that had full operational control of altp2m. This required the single hypercall to be an HVMOP, which is the only type of hypercall an HVM guest is allowed to make.

That's not true. HVM guests can use a bunch of hypercalls, like GNTTABOP, XENMEM, PHYSDEVOP...

Quoted 15 lines
xen/arch/x86/hvm/hvm.c +7 -0
index e022f5ab0e..90a4be5e86 100644
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *

xen/arch/x86/hvm/hvm.c static int hvmop_get_param( · line 4479

Quoted 10 lines
xen/arch/x86/hvm/hvm.c +10 -0
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
+ *   as modifying altp2m entires).
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.

Shouldn't you use the existing HVM_PARAM_ALTP2M values in the enumeration above instead of introducing a new nomenclature?

Roger.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 9 lines · Roger Pau Monné
Quoted 5 lines · George Dunlap

The altp2m functionality was originally envisioned to be used in several different configurations, one of which was a single in-guest agent that had full operational control of altp2m. This required the single hypercall to be an HVMOP, which is the only type of hypercall an HVM guest is allowed to make.

That's not true. HVM guests can use a bunch of hypercalls, like GNTTABOP, XENMEM, PHYSDEVOP...

But it can't maken DOMCTLs, which would be the other natural fit. I'll see if I can capture that accurately.

Quoted 21 lines
Quoted 21 lines
xen/arch/x86/hvm/hvm.c +12 -0
index e022f5ab0e..90a4be5e86 100644
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
Quoted 8 lines

xen/arch/x86/hvm/hvm.c static int hvmop_get_param( · line 4479

Quoted 5 lines
xen/arch/x86/hvm/hvm.c +5 -0
+ *   as modifying altp2m entires).
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.

Shouldn't you use the existing HVM_PARAM_ALTP2M values in the enumeration above instead of introducing a new nomenclature?

I did think about that. The problem is that 'mixed' is basically the wrong label. Or rather, it covers two different use cases: A more fully empowered guest agent coordinating with an external agent, and a solo guest agent doing everything itself.

Replacing 'coordinated' with 'limited' might make sense though.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
In reply to George Dunlap
Quoted 46 lines · George Dunlap

The altp2m functionality was originally envisioned to be used in several different configurations, one of which was a single in-guest agent that had full operational control of altp2m. This required the single hypercall to be an HVMOP, which is the only type of hypercall an HVM guest is allowed to make.

Exposing the altp2m functionality to the guest was controversial at the time, but was ultimately accepted. The fact that altp2m is an HVMOP rather than a DOMCTL has caused some problems, however, for those moving forward trying to extend the interface: Extending the interface even for the 'external' use case now means extending an HVMOP, which implicitly extends the surface of attack for the 'internal' use case as well. The result has been that every addition to this interface has also been controversial.

Settle the controversy once and for all by documenting 1) the purpose of the altp2m interface, and 2) how to extend it. In particular:

* Specify that the fully in-guest agent is a target use case

* Specify that all extensions to altp2m functionality should be subops of the HVMOP hypercall

* Specify that new subops should be disabled in ALTP2M_mixed mode by default, unless specifically evaluated as being useful for the 'internal' use case.

Hopefully this will allow the altp2m interface to be developed further without unnecessary controversy.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Konrad Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Tamas K Lengyel <[email protected]>
CC: Lars Kurth <[email protected]>

As far as I can tell there are three possible solutions to this controversy:

Quoted 7 lines

A. Remove the 'internal' functionality as a target by converting the current HVMOP into a DOMCTL.

B. Have two hypercalls -- an HVMOP which contains functionality expected to be used by the 'internal' agent, and a DOMCTL for functionality which is expected to be used only be the 'internal' agent.

The second "internal" should be "external".

Quoted 30 lines

C. Agree to add all new subops to the current hypercall (HVMOP), even if we're not sure if they should be exposed to the guest.

I think A is a terrible idea. Having a single in-guest agent is a reasonable design choice, and apparently it was even implemented at some point; we should make it straightforward for someone in the future to pick up the work if they want to.

I think B is also a terrible idea. The people extending it at the moment are primarily concerned with the 'external' use case. There is nobody around to represent whether new functionality should end up in the HVMOP or the DOMCTL, which means that by default it will end up in the DOMCTL. If it is discovered, afterwards, that the new operations *would* be safe and useful for the 'internal' use case, then we will have to duplicate them inside the HVMOP.

It just makes more sense to have all the altp2m operations in a single place, and a simple way to control whether they're available to the 'internal' use case or not. As such, I am proposing 'C'. I know Jan considers this "badness", and objects to the continual "extension" of the "badness", but I disagree, and I strongly object to the other two options.

Disabling new subops for the 'internal' use case by default means that we can add new subops without worrying about making the 'internal' use case less secure; but if in the future someone makes the case that they are safe and necessary, we can enable them without having code duplication.

Quoted 3 lines

In any case need to come to an agreement once and for all so that Tamas and Razvan can do their work without continual arguments over a mode they're not using.

Yes this is important.

Quoted 25 lines
---
 xen/arch/x86/hvm/hvm.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
xen/arch/x86/hvm/hvm.c +13 -0
index e022f5ab0e..90a4be5e86 100644
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
+ *   as modifying altp2m entires).

xen/arch/x86/hvm/hvm.c static int hvmop_get_param( · line 4485

Quoted 10 lines
xen/arch/x86/hvm/hvm.c +10 -0
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.
+ *
+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs.  But in order
+ * to properly enable the 'internal' use case, as well as to avoid
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.

I don't understand this argument. There is no risk of code duplication / fragmentation if the implementation is contained within a function. Should we choose to split one HVMOP into a DOMCTL and a HVMOP, there is now two entries to the internal function, each of which with proper checks, but they will call the same internal function eventually.

I admit I haven't followed the discussion closely.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw

Wei Liu writes ("Re: [PATCH] hvm/altp2m: Clarify the proper way to extend the altp2m interface"):

Quoted 7 lines · George Dunlap
Quoted 5 lines

+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs. But in order
+ * to properly enable the 'internal' use case, as well as to avoid
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.

Quoted 7 lines

I don't understand this argument. There is no risk of code duplication / fragmentation if the implementation is contained within a function. Should we choose to split one HVMOP into a DOMCTL and a HVMOP, there is now two entries to the internal function, each of which with proper checks, but they will call the same internal function eventually.

I admit I haven't followed the discussion closely.

"each of which with proper checks". You end up doing some of the parameter validation twice. That is very undesirable indeed.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 14 lines · Ian Jackson

Wei Liu writes ("Re: [PATCH] hvm/altp2m: Clarify the proper way to extend the altp2m interface"):

Quoted 13 lines · George Dunlap
Quoted 5 lines

+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs. But in order
+ * to properly enable the 'internal' use case, as well as to avoid
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.

I don't understand this argument. There is no risk of code duplication / fragmentation if the implementation is contained within a function. Should we choose to split one HVMOP into a DOMCTL and a HVMOP, there is now two entries to the internal function, each of which with proper checks, but they will call the same internal function eventually.

Quoted 4 lines
Quoted 1 line

I admit I haven't followed the discussion closely.

"each of which with proper checks". You end up doing some of the parameter validation twice. That is very undesirable indeed.

Fair enough.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
In reply to George Dunlap
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 10.07.18 at 11:33, <[email protected]> wrote:

As far as I can tell there are three possible solutions to this controversy:

A. Remove the 'internal' functionality as a target by converting the current HVMOP into a DOMCTL.

B. Have two hypercalls -- an HVMOP which contains functionality expected to be used by the 'internal' agent, and a DOMCTL for functionality which is expected to be used only be the 'internal' agent.

C. Agree to add all new subops to the current hypercall (HVMOP), even if we're not sure if they should be exposed to the guest.

I think A is a terrible idea. Having a single in-guest agent is a reasonable design choice, and apparently it was even implemented at some point; we should make it straightforward for someone in the future to pick up the work if they want to.

Quoted 7 lines

I think B is also a terrible idea. The people extending it at the moment are primarily concerned with the 'external' use case. There is nobody around to represent whether new functionality should end up in the HVMOP or the DOMCTL, which means that by default it will end up in the DOMCTL. If it is discovered, afterwards, that the new operations *would* be safe and useful for the 'internal' use case, then we will have to duplicate them inside the HVMOP.

They'd have to be _moved_ to HVMOP, not duplicated.

Quoted 6 lines

It just makes more sense to have all the altp2m operations in a single place, and a simple way to control whether they're available to the 'internal' use case or not. As such, I am proposing 'C'. I know Jan considers this "badness", and objects to the continual "extension" of the "badness", but I disagree, and I strongly object to the other two options.

There's one aspect that I've apparently forgotten about over time: At least the mode is a per-domain property, so as long as the wider exposure in mixed mode only affects guest security (but not Xen's or that of other guests) this ongoing widening of exposure is perhaps indeed not a problem. Question is whether all presently available code has been audited for not allowing to compromise anything other than the guest itself. But that's fine as long as altp2m altogether is not (security) supported.

Quoted 24 lines
xen/arch/x86/hvm/hvm.c +18 -0
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
+ *   as modifying altp2m entires).
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.
+ *

xen/arch/x86/hvm/hvm.c static int hvmop_get_param( · line 4490

Quoted 10 lines
xen/arch/x86/hvm/hvm.c +10 -0
+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs.  But in order
+ * to properly enable the 'internal' use case, as well as to avoid
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.
+ *
+ * New subops which may not be suitable for the 'internal' use case
+ * should be disabled in the "XEN_ALTP2M_mixed" case in
+ * xsm_hvm_altp2mhvm_op().
+ */

To me this last statement sort of implies (due to the lack of any black or white listing in xsm_hvm_altp2mhvm_op()'s XEN_ALTP2M_mixed handling) that all current ops are considered safe for internal use, which I highly doubt.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#7 lore raw
Quoted 28 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 10.07.18 at 11:33, <[email protected]> wrote:

As far as I can tell there are three possible solutions to this controversy:

A. Remove the 'internal' functionality as a target by converting the current HVMOP into a DOMCTL.

B. Have two hypercalls -- an HVMOP which contains functionality expected to be used by the 'internal' agent, and a DOMCTL for functionality which is expected to be used only be the 'internal' agent.

C. Agree to add all new subops to the current hypercall (HVMOP), even if we're not sure if they should be exposed to the guest.

I think A is a terrible idea. Having a single in-guest agent is a reasonable design choice, and apparently it was even implemented at some point; we should make it straightforward for someone in the future to pick up the work if they want to.

Quoted 7 lines

I think B is also a terrible idea. The people extending it at the moment are primarily concerned with the 'external' use case. There is nobody around to represent whether new functionality should end up in the HVMOP or the DOMCTL, which means that by default it will end up in the DOMCTL. If it is discovered, afterwards, that the new operations *would* be safe and useful for the 'internal' use case, then we will have to duplicate them inside the HVMOP.

Quoted 1 line

They'd have to be _moved_ to HVMOP, not duplicated.

I'd assumed we would want to be backwards compatible with existing dom0 agents.

The dual hypercall solution would indeed be less terrible if there weren't interface duplication. But I still think it's a poor interface to have half the operations be DOMCTLs and half be HVMOPs, and occasionally moving between the two.

Quoted 7 lines
Quoted 6 lines

It just makes more sense to have all the altp2m operations in a single place, and a simple way to control whether they're available to the 'internal' use case or not. As such, I am proposing 'C'. I know Jan considers this "badness", and objects to the continual "extension" of the "badness", but I disagree, and I strongly object to the other two options.

Quoted 8 lines

There's one aspect that I've apparently forgotten about over time: At least the mode is a per-domain property, so as long as the wider exposure in mixed mode only affects guest security (but not Xen's or that of other guests) this ongoing widening of exposure is perhaps indeed not a problem. Question is whether all presently available code has been audited for not allowing to compromise anything other than the guest itself. But that's fine as long as altp2m altogether is not (security) supported.

Right, I think making a case that the current code is reasonably safe is a prerequisite for being declared security supported. But that was always the case.

Quoted 31 lines
Quoted 31 lines
xen/arch/x86/hvm/hvm.c +25 -0
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
+ *   as modifying altp2m entires).
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.
+ *
+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs.  But in order
+ * to properly enable the 'internal' use case, as well as to avoid
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.
+ *
+ * New subops which may not be suitable for the 'internal' use case
Quoted 8 lines

xen/arch/x86/hvm/hvm.c static int hvmop_get_param( · line 4490

Quoted 3 lines
xen/arch/x86/hvm/hvm.c +3 -0
+ * should be disabled in the "XEN_ALTP2M_mixed" case in
+ * xsm_hvm_altp2mhvm_op().
+ */

To me this last statement sort of implies (due to the lack of any black or white listing in xsm_hvm_altp2mhvm_op()'s XEN_ALTP2M_mixed handling) that all current ops are considered safe for internal use, which I highly doubt.

Given a blacklist (or an invitation to make one), someone might indeed infer that the items not blacklisted had been evaluated and deemed safe to use. We have two possible solutions:

1. Go through and make such an evaluation, blacklisting everything we don't think is necessary / safe

2. Write a comment saying that the interface hasn't been evaluated.

Or 2a: Include a comment saying the 'internal' interface hasn't been evaluated for safety, and don't bother blacklisting new ops until such an evaluation has been made.

Preferences?

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw

George Dunlap writes ("Re: [PATCH] hvm/altp2m: Clarify the proper way to extend the altp2m interface"):

Quoted 4 lines · Jan Beulich

Or 2a: Include a comment saying the 'internal' interface hasn't been evaluated for safety, and don't bother blacklisting new ops until such an evaluation has been made.

We should have a way of remembering the design intent, even if it hasn't been audited.

SUPPORT.md can deal with the possible problem of people thinking the non-blacklisted items are fully ready for use.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#9 lore raw
Quoted 11 lines · Ian Jackson

George Dunlap writes ("Re: [PATCH] hvm/altp2m: Clarify the proper way to extend the altp2m interface"):

Quoted 4 lines · Jan Beulich

Or 2a: Include a comment saying the 'internal' interface hasn't been evaluated for safety, and don't bother blacklisting new ops until such an evaluation has been made.

We should have a way of remembering the design intent, even if it hasn't been audited.

SUPPORT.md can deal with the possible problem of people thinking the non-blacklisted items are fully ready for use.

I think SUPPORT.md should primarily be for end users to determine whether they should use an interface or not. A technical discussion about exactly to what degree an interface has (or hasn't) been vetted is more towards a developer who may be looking to get things into a supported state, and so should probably be in the code somewhere.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#10 lore raw

George Dunlap writes ("Re: [PATCH] hvm/altp2m: Clarify the proper way to extend the altp2m interface"):

Quoted 12 lines · Ian Jackson
Quoted 5 lines

We should have a way of remembering the design intent, even if it hasn't been audited.

SUPPORT.md can deal with the possible problem of people thinking the non-blacklisted items are fully ready for use.

I think SUPPORT.md should primarily be for end users to determine whether they should use an interface or not. A technical discussion about exactly to what degree an interface has (or hasn't) been vetted is more towards a developer who may be looking to get things into a supported state, and so should probably be in the code somewhere.

I agree with that. But currently I think none of it has been audited. If there is any question of doubt we can leave a comment in one place referenceing the SUPPORT.md status and saying `one reason is that none of this stuff has been audited'.

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#11 lore raw
Quoted 14 lines · Ian Jackson

George Dunlap writes ("Re: [PATCH] hvm/altp2m: Clarify the proper way to extend the altp2m interface"):

Quoted 12 lines · Ian Jackson
Quoted 5 lines

We should have a way of remembering the design intent, even if it hasn't been audited.

SUPPORT.md can deal with the possible problem of people thinking the non-blacklisted items are fully ready for use.

I think SUPPORT.md should primarily be for end users to determine whether they should use an interface or not. A technical discussion about exactly to what degree an interface has (or hasn't) been vetted is more towards a developer who may be looking to get things into a supported state, and so should probably be in the code somewhere.

Quoted 4 lines

I agree with that. But currently I think none of it has been audited. If there is any question of doubt we can leave a comment in one place referenceing the SUPPORT.md status and saying `one reason is that none of this stuff has been audited'.

I would assume that for the original interface, the authors at least did some thinking about whether exposing each bit was safe or not (whether this rises to the level of 'audit' is a different question). But in the mean time, other extensions have been made, which have generally not been thought about so much.

OTOH, someone picking up this use case will want to do their own analysis of all the code anyway; so maybe making the distinction between "was in the original design" and "was added later" isn't worth the effort.

Basically -- I suggested the idea of a blacklist for new subops as something to make Jan less worried about security creep. If he wants it, let's have it. Otherwise, let's not bother.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#12 lore raw
In reply to George Dunlap
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 10.07.18 at 12:30, <[email protected]> wrote:
Quoted 28 lines · Jan Beulich
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 10.07.18 at 11:33, <[email protected]> wrote:

As far as I can tell there are three possible solutions to this controversy:

A. Remove the 'internal' functionality as a target by converting the current HVMOP into a DOMCTL.

B. Have two hypercalls -- an HVMOP which contains functionality expected to be used by the 'internal' agent, and a DOMCTL for functionality which is expected to be used only be the 'internal' agent.

C. Agree to add all new subops to the current hypercall (HVMOP), even if we're not sure if they should be exposed to the guest.

I think A is a terrible idea. Having a single in-guest agent is a reasonable design choice, and apparently it was even implemented at some point; we should make it straightforward for someone in the future to pick up the work if they want to.

I think B is also a terrible idea. The people extending it at the moment are primarily concerned with the 'external' use case. There is nobody around to represent whether new functionality should end up in the HVMOP or the DOMCTL, which means that by default it will end up in the DOMCTL. If it is discovered, afterwards, that the new operations *would* be safe and useful for the 'internal' use case, then we will have to duplicate them inside the HVMOP.

Quoted 4 lines
Quoted 1 line

They'd have to be _moved_ to HVMOP, not duplicated.

I'd assumed we would want to be backwards compatible with existing dom0 agents.

No domctl should ever be considered stable, and no dom0 agent should call them without going through the libxc wrapper.

Quoted 43 lines
Quoted 31 lines
Quoted 31 lines
xen/arch/x86/hvm/hvm.c +25 -0
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
+ *   as modifying altp2m entires).
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.
+ *
+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs.  But in order
+ * to properly enable the 'internal' use case, as well as to avoid
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.
+ *
+ * New subops which may not be suitable for the 'internal' use case
Quoted 8 lines

xen/arch/x86/hvm/hvm.c static int hvmop_get_param( · line 4490

Quoted 3 lines
xen/arch/x86/hvm/hvm.c +3 -0
+ * should be disabled in the "XEN_ALTP2M_mixed" case in
+ * xsm_hvm_altp2mhvm_op().
+ */

To me this last statement sort of implies (due to the lack of any black or white listing in xsm_hvm_altp2mhvm_op()'s XEN_ALTP2M_mixed handling) that all current ops are considered safe for internal use, which I highly doubt.

Given a blacklist (or an invitation to make one), someone might indeed infer that the items not blacklisted had been evaluated and deemed safe to use. We have two possible solutions:

Quoted 8 lines

1. Go through and make such an evaluation, blacklisting everything we don't think is necessary / safe

2. Write a comment saying that the interface hasn't been evaluated.

Or 2a: Include a comment saying the 'internal' interface hasn't been evaluated for safety, and don't bother blacklisting new ops until such an evaluation has been made.

I see no value in a black list if only future things would be added to it. I'm okay with 2a, but I think 1 would make easier the future job of auditing the whole lot for supportability.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#13 lore raw
Quoted 30 lines · Jan Beulich
Quoted 30 lines
Quoted 1 line
Quoted 1 line · On 10.07.18 at 12:30, <[email protected]> wrote:
Quoted 28 lines · Jan Beulich
Quoted 27 lines
Quoted 1 line
Quoted 1 line · On 10.07.18 at 11:33, <[email protected]> wrote:

As far as I can tell there are three possible solutions to this controversy:

A. Remove the 'internal' functionality as a target by converting the current HVMOP into a DOMCTL.

B. Have two hypercalls -- an HVMOP which contains functionality expected to be used by the 'internal' agent, and a DOMCTL for functionality which is expected to be used only be the 'internal' agent.

C. Agree to add all new subops to the current hypercall (HVMOP), even if we're not sure if they should be exposed to the guest.

I think A is a terrible idea. Having a single in-guest agent is a reasonable design choice, and apparently it was even implemented at some point; we should make it straightforward for someone in the future to pick up the work if they want to.

I think B is also a terrible idea. The people extending it at the moment are primarily concerned with the 'external' use case. There is nobody around to represent whether new functionality should end up in the HVMOP or the DOMCTL, which means that by default it will end up in the DOMCTL. If it is discovered, afterwards, that the new operations *would* be safe and useful for the 'internal' use case, then we will have to duplicate them inside the HVMOP.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

They'd have to be _moved_ to HVMOP, not duplicated.

I'd assumed we would want to be backwards compatible with existing dom0 agents.

No domctl should ever be considered stable, and no dom0 agent should call them without going through the libxc wrapper.

Naturally; but we shouldn't change them for no reason, and I was envisioning an agent designed to compile against several versions of Xen looking like this:

#if XEN_INTERFACE < nnn
domctl_altp2m_op(blah blah blah);
#else
hvmop_altp2m_op(blah blah blah);
#endif

But again, if the exact hypercall were switched behind the scenes in libxc, that would make this option siginificantly less bad.

I'm not a fan of having two different hypercalls for this, but if you posted a similar patch documenting that as the way forward I wouldn't argue against it. (I remember Andy not being a fan either, but I don't know what his concerns were.)

Quoted 49 lines
Quoted 49 lines
Quoted 32 lines
Quoted 32 lines
xen/arch/x86/hvm/hvm.c +25 -0
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
+ *   as modifying altp2m entires).
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.
+ *
+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs.  But in order
+ * to properly enable the 'internal' use case, as well as to avoid
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.
+ *
+ * New subops which may not be suitable for the 'internal' use case
Quoted 8 lines

xen/arch/x86/hvm/hvm.c static int hvmop_get_param( · line 4490

Quoted 3 lines
xen/arch/x86/hvm/hvm.c +3 -0
+ * should be disabled in the "XEN_ALTP2M_mixed" case in
+ * xsm_hvm_altp2mhvm_op().
+ */

To me this last statement sort of implies (due to the lack of any black or white listing in xsm_hvm_altp2mhvm_op()'s XEN_ALTP2M_mixed handling) that all current ops are considered safe for internal use, which I highly doubt.

Given a blacklist (or an invitation to make one), someone might indeed infer that the items not blacklisted had been evaluated and deemed safe to use. We have two possible solutions:

1. Go through and make such an evaluation, blacklisting everything we don't think is necessary / safe

2. Write a comment saying that the interface hasn't been evaluated.

Quoted 7 lines
Quoted 3 lines

Or 2a: Include a comment saying the 'internal' interface hasn't been evaluated for safety, and don't bother blacklisting new ops until such an evaluation has been made.

I see no value in a black list if only future things would be added to it. I'm okay with 2a, but I think 1 would make easier the future job of auditing the whole lot for supportability.

The issue with 1 is who's going to do it. It really requires someone who wants to use the interface -- or at least someone who has a good understanding of how the previous user actually used the interface.

I don't think it's a good use of my time; given that you're not a fan of the whole idea in the first place, you're probably not a good candidate; and I expect Tamas and Razvan aren't terribly interested either.

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#14 lore raw
In reply to George Dunlap

Forgot to CC BitDefender

Quoted 120 lines · George Dunlap

The altp2m functionality was originally envisioned to be used in several different configurations, one of which was a single in-guest agent that had full operational control of altp2m. This required the single hypercall to be an HVMOP, which is the only type of hypercall an HVM guest is allowed to make.

Exposing the altp2m functionality to the guest was controversial at the time, but was ultimately accepted. The fact that altp2m is an HVMOP rather than a DOMCTL has caused some problems, however, for those moving forward trying to extend the interface: Extending the interface even for the 'external' use case now means extending an HVMOP, which implicitly extends the surface of attack for the 'internal' use case as well. The result has been that every addition to this interface has also been controversial.

Settle the controversy once and for all by documenting 1) the purpose of the altp2m interface, and 2) how to extend it. In particular:

* Specify that the fully in-guest agent is a target use case

* Specify that all extensions to altp2m functionality should be subops of the HVMOP hypercall

* Specify that new subops should be disabled in ALTP2M_mixed mode by default, unless specifically evaluated as being useful for the 'internal' use case.

Hopefully this will allow the altp2m interface to be developed further without unnecessary controversy.

---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Konrad Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Tamas K Lengyel <[email protected]>
CC: Lars Kurth <[email protected]>

As far as I can tell there are three possible solutions to this controversy:

A. Remove the 'internal' functionality as a target by converting the current HVMOP into a DOMCTL.

B. Have two hypercalls -- an HVMOP which contains functionality expected to be used by the 'internal' agent, and a DOMCTL for functionality which is expected to be used only be the 'internal' agent.

C. Agree to add all new subops to the current hypercall (HVMOP), even if we're not sure if they should be exposed to the guest.

I think A is a terrible idea. Having a single in-guest agent is a reasonable design choice, and apparently it was even implemented at some point; we should make it straightforward for someone in the future to pick up the work if they want to.

I think B is also a terrible idea. The people extending it at the moment are primarily concerned with the 'external' use case. There is nobody around to represent whether new functionality should end up in the HVMOP or the DOMCTL, which means that by default it will end up in the DOMCTL. If it is discovered, afterwards, that the new operations *would* be safe and useful for the 'internal' use case, then we will have to duplicate them inside the HVMOP.

It just makes more sense to have all the altp2m operations in a single place, and a simple way to control whether they're available to the 'internal' use case or not. As such, I am proposing 'C'. I know Jan considers this "badness", and objects to the continual "extension" of the "badness", but I disagree, and I strongly object to the other two options.

Disabling new subops for the 'internal' use case by default means that we can add new subops without worrying about making the 'internal' use case less secure; but if in the future someone makes the case that they are safe and necessary, we can enable them without having code duplication.

In any case need to come to an agreement once and for all so that Tamas and Razvan can do their work without continual arguments over a mode they're not using.

---
 xen/arch/x86/hvm/hvm.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
xen/arch/x86/hvm/hvm.c +21 -0
index e022f5ab0e..90a4be5e86 100644
@@ -4460,6 +4460,34 @@ static int hvmop_get_param(
     return rc;
 }
 
+/*
+ * altp2m operations are envisioned as being used in several different 
+ * modes:
+ * 
+ * - external: All control and decisions are made by an external agent
+ *   running domain 0.
+ *
+ * - internal: altp2m operations are used exclusively by an in-guest agent
+ *   to protect itself from the guest kernel and in-guest attackers.  
+ * 
+ * - coordinated: An in-guest agent handles #VE and VMFUNCs locally,
+ *   but makes requests of an external entity for bigger changes (such
+ *   as modifying altp2m entires).
+ *
+ * This corresponds to the three values for HVM_PARAM_ALTP2M
+ * (external, mixed, limited). All three models have advantages and
+ * disadvantages.
+ *
+ * Normally hypercalls made by a program in domain 0 in order to
+ * control a guest would be DOMCTLs rather than HVMOPs.  But in order
+ * to properly enable the 'internal' use case, as well as to avoid

xen/arch/x86/hvm/hvm.c static int hvmop_get_param( · line 4493

Quoted 10 lines
xen/arch/x86/hvm/hvm.c +7 -0
+ * fragmentation, all altp2m subops should come under this single
+ * HVMOP.
+ *
+ * New subops which may not be suitable for the 'internal' use case
+ * should be disabled in the "XEN_ALTP2M_mixed" case in
+ * xsm_hvm_altp2mhvm_op().
+ */
 static int do_altp2m_op(
     XEN_GUEST_HANDLE_PARAM(void) arg)
 {

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel