Skip to contentSkip to conversation

xen/xsm: Introduce new boot parameter xsm

PATCH In review Xin Li 6 participants 22 messages Jun 29, 2018 – Aug 17, 2018

lore
Share & tools
lore

Xin Li

author
#0 lore raw

PATCH 1/2 xen/xsm: Introduce new boot parameter xsm

Introduce new boot parameter xsm to choose which xsm module is enabled, and set default to dummy.

---
CC: Daniel De Graaf <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Ming Lu <[email protected]>

---
 docs/misc/xen-command-line.markdown | 13 ++++++++++
 xen/xsm/xsm_core.c                  | 39 ++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 1 deletion(-)
docs/misc/xen-command-line.markdown +13 -0
index 075e5ea159..7c689b8225 100644
@@ -865,6 +865,19 @@ hardware domain is architecture dependent.
 Note that specifying zero as domU value means zero, while for dom0 it means
 to use the default.
 
+### xsm
+> `= dummy | silo | flask`
+
+> Default: `dummy`
+
+Specify which XSM module should be enabled.  This option is only available if
+the hypervisor was compiled with XSM support.
+
+* `dummy`: this is the default choice.  No special restriction will be applied.
+  it's also used when XSM is compiled out.
+* `flask`: this is the policy based access control.  To choose this, the
+  separated option in kconfig must also be enabled.
+
 ### flask
 > `= permissive | enforcing | late | disabled`
 
xen/xsm/xsm_core.c +38 -1
index cddcf7aa51..e002200578 100644
@@ -31,6 +31,30 @@
 
 struct xsm_operations *xsm_ops;
 
+enum xsm_bootparam {
+    XSM_BOOTPARAM_DUMMY,
+    XSM_BOOTPARAM_FLASK,
+    XSM_BOOTPARAM_INVALID,
+};
+
+enum xsm_bootparam __read_mostly xsm_bootparam = XSM_BOOTPARAM_DUMMY;
+
+static int __init parse_xsm_param(const char *s)
+{
+    if ( !strcmp(s, "dummy") )
+        xsm_bootparam = XSM_BOOTPARAM_DUMMY;
+#ifdef CONFIG_XSM_FLASK
+    else if ( !strcmp(s, "flask") )
+        xsm_bootparam = XSM_BOOTPARAM_FLASK;
+#endif
+    else
+        xsm_bootparam = XSM_BOOTPARAM_INVALID;
+
+    return 0;
+}
+
+custom_param("xsm", parse_xsm_param);
+
 static inline int verify(struct xsm_operations *ops)
 {
     /* verify the security_operations structure exists */
@@ -57,7 +81,20 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size)
     }
 
     xsm_ops = &dummy_xsm_ops;
-    flask_init(policy_buffer, policy_size);
+
+    switch ( xsm_bootparam )
+    {
+    case XSM_BOOTPARAM_DUMMY:
+        /* empty */
+        break;
+
+    case XSM_BOOTPARAM_FLASK:
+        flask_init(policy_buffer, policy_size);
+        break;
+
+    default:
+        printk("XSM: Invalid value for xsm= boot parameter.\n");
+    }
 
     return 0;
 }
Signature · 7 lines
2.18.0


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

PATCH 2/2 xen/xsm: Add new SILO mode for XSM

When SILO is enabled, there would be no page-sharing between unprivileged VMs (no grant tables or event channels).

---
CC: Daniel De Graaf <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Ming Lu <[email protected]>

---
 docs/misc/xen-command-line.markdown |   3 +
 xen/common/Kconfig                  |  11 +++
 xen/include/xsm/xsm.h               |   6 ++
 xen/xsm/Makefile                    |   1 +
 xen/xsm/silo.c                      | 106 ++++++++++++++++++++++++++++
 xen/xsm/xsm_core.c                  |   9 +++
 6 files changed, 136 insertions(+)
 create mode 100644 xen/xsm/silo.c
docs/misc/xen-command-line.markdown +3 -0
index 7c689b8225..454de11c3d 100644
@@ -877,6 +877,9 @@ the hypervisor was compiled with XSM support.
   it's also used when XSM is compiled out.
 * `flask`: this is the policy based access control.  To choose this, the
   separated option in kconfig must also be enabled.
+* `silo`: this will deny any unmediated communication channels between
+  unprivileged VMs.  To choose this, the separated option in kconfig must also
+  be enabled.
 
 ### flask
 > `= permissive | enforcing | late | disabled`
xen/common/Kconfig +11 -0
index 068c3206a1..f3f8e5afbc 100644
@@ -143,6 +143,17 @@ config XSM_FLASK_POLICY
 
 	  If unsure, say Y.
 
+config XSM_SILO
+	def_bool y
+	prompt "SILO support"
+	depends on XSM
+	---help---
+	  Enables SILO as the access control mechanism used by the XSM framework.
+	  This will deny any unmediated communication channels between unprivileged
+	  VMs.
+
+	  If unsure, say Y.
+
 config LATE_HWDOM
 	bool "Dedicated hardware domain"
 	default n
xen/include/xsm/xsm.h +6 -0
index 70e7a6849f..11518e5bd6 100644
@@ -733,6 +733,12 @@ extern const unsigned char xsm_init_flask_policy[];
 extern const unsigned int xsm_init_flask_policy_size;
 #endif
 
+#ifdef CONFIG_XSM_SILO
+extern void silo_init(void);
+#else
+static inline void silo_init(void) {}
+#endif
+
 #else /* CONFIG_XSM */
 
 #include <xsm/dummy.h>
xen/xsm/Makefile +1 -0
index 8bb4a24f09..e4d581e065 100644
@@ -1,5 +1,6 @@
 obj-y += xsm_core.o
 obj-$(CONFIG_XSM) += xsm_policy.o
 obj-$(CONFIG_XSM) += dummy.o
+obj-$(CONFIG_XSM_SILO) += silo.o
 
 subdir-$(CONFIG_XSM_FLASK) += flask
xen/xsm/silo.c new file +106 -0

106 lines not on this page · raw message

xen/xsm/xsm_core.c +9 -0
index e002200578..7842f6dd44 100644
@@ -34,6 +34,7 @@ struct xsm_operations *xsm_ops;
 enum xsm_bootparam {
     XSM_BOOTPARAM_DUMMY,
     XSM_BOOTPARAM_FLASK,
+    XSM_BOOTPARAM_SILO,
     XSM_BOOTPARAM_INVALID,
 };
 
@@ -46,6 +47,10 @@ static int __init parse_xsm_param(const char *s)
 #ifdef CONFIG_XSM_FLASK
     else if ( !strcmp(s, "flask") )
         xsm_bootparam = XSM_BOOTPARAM_FLASK;
+#endif
+#ifdef CONFIG_XSM_SILO
+    else if ( !strcmp(s, "silo") )
+        xsm_bootparam = XSM_BOOTPARAM_SILO;
 #endif
     else
         xsm_bootparam = XSM_BOOTPARAM_INVALID;
@@ -92,6 +97,10 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size)
         flask_init(policy_buffer, policy_size);
         break;
 
+    case XSM_BOOTPARAM_SILO:
+        silo_init();
+        break;
+
     default:
         printk("XSM: Invalid value for xsm= boot parameter.\n");
     }
Signature · 7 lines
2.18.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#15 lore raw
In reply to Xin Li
Quoted 4 lines · Xin Li

Introduce new boot parameter xsm to choose which xsm module is enabled, and set default to dummy.

As a note for other reviewers, this series is based on top of my XSM Kconfig cleanup.

As for this patch, its almost there.  Just a few minor issues.

Quoted 22 lines

---
CC: Daniel De Graaf <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Ming Lu <[email protected]>

---
 docs/misc/xen-command-line.markdown | 13 ++++++++++
 xen/xsm/xsm_core.c                  | 39 ++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 1 deletion(-)
docs/misc/xen-command-line.markdown +0 -0
index 075e5ea159..7c689b8225 100644

docs/misc/xen-command-line.markdown hardware domain is architecture dependent. · line 869

Quoted 5 lines
docs/misc/xen-command-line.markdown +2 -0
@@ -865,6 +865,19 @@ hardware domain is architecture dependent.
 Note that specifying zero as domU value means zero, while for dom0 it means
 to use the default.
 
+### xsm
+> `= dummy | silo | flask`

This should be just "dummy | flask" in this patch, and extended with silo in the next path.  Also, options in this file should be sorted alphabetically, so ### xsm should be near the end, rather than beside flask.

Quoted 19 lines
docs/misc/xen-command-line.markdown +11 -0
+
+> Default: `dummy`
+
+Specify which XSM module should be enabled.  This option is only available if
+the hypervisor was compiled with XSM support.
+
+* `dummy`: this is the default choice.  No special restriction will be applied.
+  it's also used when XSM is compiled out.
+* `flask`: this is the policy based access control.  To choose this, the
+  separated option in kconfig must also be enabled.
+
 ### flask
 > `= permissive | enforcing | late | disabled`
 
xen/xsm/xsm_core.c +0 -0
index cddcf7aa51..e002200578 100644

xen/xsm/xsm_core.c line 37

Quoted 7 lines
xen/xsm/xsm_core.c +4 -0
@@ -31,6 +31,30 @@
 
 struct xsm_operations *xsm_ops;
 
+enum xsm_bootparam {
+    XSM_BOOTPARAM_DUMMY,
+    XSM_BOOTPARAM_FLASK,
+    XSM_BOOTPARAM_INVALID,

I'd drop INVALID (See below for the parsing aspect), as it actually falls back to DUMMY.

xen/xsm/xsm_core.c line 40

Quoted 3 lines
xen/xsm/xsm_core.c +3 -0
+};
+
+enum xsm_bootparam __read_mostly xsm_bootparam = XSM_BOOTPARAM_DUMMY;

This should be __initdata rather than __read_mostly.  It is safe to be discarded after boot.

xen/xsm/xsm_core.c line 43

Quoted 3 lines
xen/xsm/xsm_core.c +3 -0
+
+static int __init parse_xsm_param(const char *s)
+{

int rc = 0;

xen/xsm/xsm_core.c line 53

Quoted 10 lines
xen/xsm/xsm_core.c +10 -0
+    if ( !strcmp(s, "dummy") )
+        xsm_bootparam = XSM_BOOTPARAM_DUMMY;
+#ifdef CONFIG_XSM_FLASK
+    else if ( !strcmp(s, "flask") )
+        xsm_bootparam = XSM_BOOTPARAM_FLASK;
+#endif
+    else
+        xsm_bootparam = XSM_BOOTPARAM_INVALID;
+
+    return 0;

else
    rc = -EINVAL;

return rc;

As a result, the core command line infrastructure will inform the user if they passed an unrecognised option.

~Andrew

Quoted 19 lines
xen/xsm/xsm_core.c +11 -1
+}
+
+custom_param("xsm", parse_xsm_param);
+
 static inline int verify(struct xsm_operations *ops)
 {
     /* verify the security_operations structure exists */
@@ -57,7 +81,20 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size)
     }
 
     xsm_ops = &dummy_xsm_ops;
-    flask_init(policy_buffer, policy_size);
+
+    switch ( xsm_bootparam )
+    {
+    case XSM_BOOTPARAM_DUMMY:
+        /* empty */
+        break;
+

xen/xsm/xsm_core.c static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) · line 100

Quoted 10 lines
xen/xsm/xsm_core.c +7 -0
+    case XSM_BOOTPARAM_FLASK:
+        flask_init(policy_buffer, policy_size);
+        break;
+
+    default:
+        printk("XSM: Invalid value for xsm= boot parameter.\n");
+    }
 
     return 0;
 }

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

#2 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

In reply to Xin Li

xen/xsm/silo.c line 85

Quoted 3 lines · Xin Li
xen/xsm/silo.c new file +3 -0
+void __init silo_init(void)
+{
+    printk("Initialising XSM SILO mode");

You need a newline at the end of printk here.

Otherwise, everything else looks in order.

~Andrew

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

#16 lore raw
In reply to Andrew Cooper
Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:47, <[email protected]> wrote:

docs/misc/xen-command-line.markdown hardware domain is architecture dependent. · line 869

Quoted 8 lines · Xin Li
docs/misc/xen-command-line.markdown +2 -0
@@ -865,6 +865,19 @@ hardware domain is architecture dependent.
 Note that specifying zero as domU value means zero, while for dom0 it means
 to use the default.
 
+### xsm
+> `= dummy | silo | flask`

This should be just "dummy | flask" in this patch, and extended with silo in the next path. Also, options in this file should be sorted alphabetically, so ### xsm should be near the end, rather than beside flask.

Quoted 9 lines

docs/misc/xen-command-line.markdown hardware domain is architecture dependent.

Quoted 9 lines
docs/misc/xen-command-line.markdown +9 -0
+
+> Default: `dummy`
+
+Specify which XSM module should be enabled.  This option is only available if
+the hypervisor was compiled with XSM support.
+
+* `dummy`: this is the default choice.  No special restriction will be applied.
+  it's also used when XSM is compiled out.
+enum xsm_bootparam __read_mostly xsm_bootparam = XSM_BOOTPARAM_DUMMY;

So why "dummy" instead of "none" (or one of the boolean false strings)?

Quoted 2 lines

This should be __initdata rather than __read_mostly. It is safe to be discarded after boot.

And static.

Quoted 21 lines

docs/misc/xen-command-line.markdown hardware domain is architecture dependent. · line 880

Quoted 2 lines
docs/misc/xen-command-line.markdown +2 -0
+static int __init parse_xsm_param(const char *s)
+{

int rc = 0;

docs/misc/xen-command-line.markdown hardware domain is architecture dependent.

Quoted 10 lines
docs/misc/xen-command-line.markdown +10 -0
+    if ( !strcmp(s, "dummy") )
+        xsm_bootparam = XSM_BOOTPARAM_DUMMY;
+#ifdef CONFIG_XSM_FLASK
+    else if ( !strcmp(s, "flask") )
+        xsm_bootparam = XSM_BOOTPARAM_FLASK;
+#endif
+    else
+        xsm_bootparam = XSM_BOOTPARAM_INVALID;
+
+    return 0;

else

    rc = -EINVAL;

return rc;

Quoted 8 lines

As a result, the core command line infrastructure will inform the user if they passed an unrecognised option.

~Andrew

docs/misc/xen-command-line.markdown

Quoted 3 lines
docs/misc/xen-command-line.markdown +3 -0
+}
+
+custom_param("xsm", parse_xsm_param);

Please avoid the blank line above here - in the majority of similar cases, we have the custom_param() immediately follow the parsing function.

Quoted 10 lines

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) · line 88

Quoted 10 lines
docs/misc/xen-command-line.markdown +5 -1
@@ -57,7 +81,20 @@ static int __init xsm_core_init(const void *policy_buffer, size_t policy_size)
     }
 
     xsm_ops = &dummy_xsm_ops;
-    flask_init(policy_buffer, policy_size);
+
+    switch ( xsm_bootparam )
+    {
+    case XSM_BOOTPARAM_DUMMY:
+        /* empty */

I'm not sure of the value of this comment.

Quoted 9 lines

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void *policy_buffer, size_t policy_size) · line 97

Quoted 9 lines
docs/misc/xen-command-line.markdown +9 -0
+        break;
+
+    case XSM_BOOTPARAM_FLASK:
+        flask_init(policy_buffer, policy_size);
+        break;
+
+    default:
+        printk("XSM: Invalid value for xsm= boot parameter.\n");
+    }

Please don't omit the "break;" here.

Jan

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

#4 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

In reply to Xin Li
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:28, <[email protected]> wrote:

When SILO is enabled, there would be no page-sharing between unprivileged VMs (no grant tables or event channels).

What is the relation between page sharing and event channels?

Quoted 6 lines
xen/common/Kconfig +0 -0
@@ -143,6 +143,17 @@ config XSM_FLASK_POLICY
 
 	  If unsure, say Y.
 

xen/common/Kconfig config XSM_FLASK_POLICY · line 155

Quoted 10 lines
xen/common/Kconfig +10 -0
+config XSM_SILO
+	def_bool y
+	prompt "SILO support"
+	depends on XSM
+	---help---
+	  Enables SILO as the access control mechanism used by the XSM framework.
+	  This will deny any unmediated communication channels between unprivileged
+	  VMs.
+
+	  If unsure, say Y.

It would be helpful to clarify here that this is not the default mode of operation. In fact, another Kconfig (choice) might be useful to have to select the built-in default. In fact "deny any" suggests that this is what is going to happen regardless of command line options. At the very least I think this wants to be "This will allow to deny any ..." or "In this mode, any ... will by denied".

Andrew, the chosen name here may underline the relevance of my comment regarding XSM_FLASK vs just FLASK, albeit things are unclear/ambiguous if I also take into account the code further down. The descriptions above make it sound as if this was an override to whatever access control mechanism was in place (dummy or flask currently). Code below suggests though that this is meant to be a clone of dummy, with just some minimal adjustments. I guess it's rather the description that needs adjustment, but the alternative of being a global override even in FLASK mode certainly exists.

Furthermore it is unclear here what an "unmediated communication channel" is, and what "mediated communication channels" (if any) are still available in this new mode.

Quoted 23 lines
xen/xsm/silo.c new file +20 -0
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * xsm/silo.c
+ *
+ * SILO module for XSM(Xen Security Modules)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2018 Citrix Systems Ltd.
+ */

xen/xsm/silo.c line 30

Quoted 10 lines
xen/xsm/silo.c new file +10 -0
+
+#include <xen/sched.h>
+#include <xsm/xsm.h>
+
+struct xsm_operations silo_xsm_ops;
+
+/*
+ * check if inter-domain communication is allowed
+ * return true when pass check
+ */

Uppercase first letter please, and I'd prefer if you also put a full stop here.

xen/xsm/silo.c line 33

Quoted 3 lines
xen/xsm/silo.c new file +3 -0
+static bool silo_mode_dom_check(domid_t ldom, domid_t rdom)
+{
+    domid_t hd_dom = hardware_domain->domain_id;

I don't think you mean the hardware domain here, but the control domain (of which in theory there may be multiple).

Quoted 6 lines
xen/xsm/silo.c new file +6 -0
+    domid_t cur_dom = current->domain->domain_id;
+
+    if ( ldom == DOMID_SELF )
+        ldom = cur_dom;
+    if ( rdom == DOMID_SELF )
+        rdom = cur_dom;

xen/xsm/silo.c line 49

Quoted 10 lines
xen/xsm/silo.c new file +10 -0
+
+    return (hd_dom == cur_dom || hd_dom == ldom || hd_dom == rdom ||
+            ldom == rdom);
+}
+
+static int silo_evtchn_unbound(struct domain *d1, struct evtchn *chn,
+                               domid_t id2)
+{
+    if ( silo_mode_dom_check(d1->domain_id, id2) )
+        return dummy_xsm_ops.evtchn_unbound(d1, chn, id2);

Urgh. Why is this not xsm_evtchn_unbound() from dummy.h? It would be really nice to avoid such extra indirect calls here.

Furthermore, this hook is called in two contexts. Is the above really appropriate also in the alloc_unbound_xen_event_channel() case?

xen/xsm/silo.c line 67

Quoted 7 lines
xen/xsm/silo.c new file +7 -0
+static int silo_grant_mapref(struct domain *d1, struct domain *d2,
+                             uint32_t flags)
+{
+    if ( silo_mode_dom_check(d1->domain_id, d2->domain_id) )
+        return dummy_xsm_ops.grant_mapref(d1, d2, flags);
+    return -EPERM;
+}

What about the unmap counterpart?

Jan

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

#13 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

In reply to Xin Li

Hello,

Quoted 6 lines · Xin Li
xen/xsm/silo.c new file +0 -0
new file mode 100644
index 0000000000..cac22432da

xen/xsm/silo.c line 9

Quoted 9 lines
xen/xsm/silo.c new file +9 -0
@@ -0,0 +1,106 @@
+/******************************************************************************
+ * xsm/silo.c
+ *
+ * SILO module for XSM(Xen Security Modules)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.

Xen hypervisor is licensed as GPLv2 only. However, this header is allowing GPLv2+. Can you please update the header accordingly?

Cheers,

Signature · 6 lines
Julien Grall

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

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

OK.
Change to:

/******************************************************************************
* xsm/silo.c
*
* SILO module for XSM(Xen Security Modules)
*
* Copyright (c) 2018 Citrix Systems Ltd.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; If not, see <http://www.gnu.org/licenses/>.
*/

Best regards

Xin(Talons) Li

Quoted 38 lines

-----Original Message-----
From: Julien Grall [mailto:[email protected]]
Sent: Friday, June 29, 2018 9:22 PM
To: Xin Li <[email protected]>; [email protected]
Cc: Sergey Dyasli <[email protected]>; Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Xin Li (Talons) <[email protected]>; Tim (Xen.org) <[email protected]>; Jan Beulich <[email protected]>; Andrew Cooper <[email protected]>; Ming Lu <[email protected]>; Daniel De Graaf <[email protected]>
Subject: Re: [Xen-devel] [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Hello,

xen/xsm/silo.c

Quoted 6 lines · Xin Li
xen/xsm/silo.c new file +0 -0
index 0000000000..cac22432da
@@ -0,0 +1,106 @@

+/***************************************************************
*****

xen/xsm/silo.c line 9

Quoted 11 lines
xen/xsm/silo.c new file +11 -0
+**********
+ * xsm/silo.c
+ *
+ * SILO module for XSM(Xen Security Modules)
+ *
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License as published
+by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.

Xen hypervisor is licensed as GPLv2 only. However, this header is allowing GPLv2+. Can you please update the header accordingly?

Quoted 4 lines

Cheers,

--
Julien Grall

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

#3 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

In reply to Andrew Cooper

Done.

Best regards

Xin(Talons) Li

Quoted 19 lines

-----Original Message-----
From: Andrew Cooper
Sent: Friday, June 29, 2018 5:52 PM
To: Xin Li <[email protected]>; [email protected]
Cc: Xin Li (Talons) <[email protected]>; Daniel De Graaf <[email protected]>; George Dunlap <[email protected]>; Jan Beulich <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim (Xen.org) <[email protected]>; Wei Liu <[email protected]>; Sergey Dyasli <[email protected]>; Ming Lu <[email protected]>
Subject: Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

xen/xsm/silo.c line 85

Quoted 3 lines · Xin Li
xen/xsm/silo.c new file +3 -0
+void __init silo_init(void)
+{
+    printk("Initialising XSM SILO mode");

You need a newline at the end of printk here.

Quoted 3 lines

Otherwise, everything else looks in order.

~Andrew

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

#5 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

In reply to Jan Beulich

Hello Jan,

Quoted 13 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:36 PM
To: Andrew Cooper <[email protected]>; Xin Li <[email protected]>
Cc: Ming Lu <[email protected]>; Sergey Dyasli <[email protected]>; Wei Liu <[email protected]>; Xin Li (Talons) <[email protected]>; George Dunlap <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Konrad Rzeszutek Wilk <[email protected]>; Daniel de Graaf <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Quoted 5 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:28, <[email protected]> wrote:

When SILO is enabled, there would be no page-sharing between unprivileged VMs (no grant tables or event channels).

What is the relation between page sharing and event channels?

They are the two mechanisms exist for inter-domain communication, And we want to block them in SILO mode.

Quoted 36 lines

xen/common/Kconfig config XSM_FLASK_POLICY · line 151

Quoted 13 lines
xen/common/Kconfig +6 -0
@@ -143,6 +143,17 @@ config XSM_FLASK_POLICY
 
 	  If unsure, say Y.
 
+config XSM_SILO
+	def_bool y
+	prompt "SILO support"
+	depends on XSM
+	---help---
+	  Enables SILO as the access control mechanism used by the XSM

framework.

xen/common/Kconfig config XSM_FLASK_POLICY · line 152

Quoted 1 line
xen/common/Kconfig +1 -0
+	  This will deny any unmediated communication channels between

unprivileged

xen/common/Kconfig config XSM_FLASK_POLICY · line 155

Quoted 3 lines
xen/common/Kconfig +3 -0
+	  VMs.
+
+	  If unsure, say Y.

It would be helpful to clarify here that this is not the default mode of operation. In fact, another Kconfig (choice) might be useful to have to select the built-in default. In fact "deny any" suggests that this is what is going to happen regardless of command line options. At the very least I think this wants to be "This will allow to deny any ..." or "In this mode, any ... will by denied".

Andrew, the chosen name here may underline the relevance of my comment regarding XSM_FLASK vs just FLASK, albeit things are unclear/ambiguous if I also take into account the code further down.
The descriptions above make it sound as if this was an override to whatever access control mechanism was in place (dummy or flask currently). Code below suggests though that this is meant to be a clone of dummy, with just some minimal adjustments. I guess it's rather the description that needs adjustment, but the alternative of being a global override even in FLASK mode certainly exists.

Quoted 3 lines

Furthermore it is unclear here what an "unmediated communication channel" is, and what "mediated communication channels" (if any) are still available in this new mode.

Change to:

config XSM_SILO

Quoted 44 lines

-------def_bool y
-------prompt "SILO support"
-------depends on XSM
----------help---

-------  Enables SILO as the access control mechanism used by the XSM framework.
-------  This is not the default module, add boot parameter xsm=silo to choose
-------  it. This will deny any unmediated communication channels (grant tables
-------  and event channels) between unprivileged VMs.

------- If unsure, say Y.

xen/xsm/silo.c

Quoted 4 lines
xen/xsm/silo.c new file +0 -0
@@ -0,0 +1,106 @@

+/***************************************************************
*****

Quoted 26 lines
xen/xsm/silo.c new file +26 -0
+**********
+ * xsm/silo.c
+ *
+ * SILO module for XSM(Xen Security Modules)
+ *
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License as published
+by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2018 Citrix Systems Ltd.
+ */
+
+#include <xen/sched.h>
+#include <xsm/xsm.h>
+
Quoted 8 lines

xen/xsm/silo.c line 30

Quoted 6 lines
xen/xsm/silo.c new file +6 -0
+struct xsm_operations silo_xsm_ops;
+
+/*
+ * check if inter-domain communication is allowed
+ * return true when pass check
+ */

Uppercase first letter please, and I'd prefer if you also put a full stop here.

OK. Done.

Quoted 5 lines

xen/xsm/silo.c line 34

Quoted 2 lines
xen/xsm/silo.c new file +2 -0
+static bool silo_mode_dom_check(domid_t ldom, domid_t rdom) {
+    domid_t hd_dom = hardware_domain->domain_id;

I don't think you mean the hardware domain here, but the control domain (of which in theory there may be multiple).

I mean the one and only dom0.

Quoted 11 lines
Quoted 11 lines
xen/xsm/silo.c new file +10 -0
+    domid_t cur_dom = current->domain->domain_id;
+
+    if ( ldom == DOMID_SELF )
+        ldom = cur_dom;
+    if ( rdom == DOMID_SELF )
+        rdom = cur_dom;
+
+    return (hd_dom == cur_dom || hd_dom == ldom || hd_dom == rdom ||
+            ldom == rdom);
+}
Quoted 8 lines

xen/xsm/silo.c line 49

Quoted 5 lines
xen/xsm/silo.c new file +5 -0
+
+static int silo_evtchn_unbound(struct domain *d1, struct evtchn *chn,
+                               domid_t id2) {
+    if ( silo_mode_dom_check(d1->domain_id, id2) )
+        return dummy_xsm_ops.evtchn_unbound(d1, chn, id2);

Urgh. Why is this not xsm_evtchn_unbound() from dummy.h? It would be really nice to avoid such extra indirect calls here.

This makes it clearer that we are calling the counterpart of dummy ops(overriding). This indirect calls should not introduce any runtime penalty.

Quoted 4 lines

Furthermore, this hook is called in two contexts. Is the above really appropriate also in the alloc_unbound_xen_event_channel() case?

Quoted 8 lines

xen/xsm/silo.c line 67

Quoted 6 lines
xen/xsm/silo.c new file +6 -0
+static int silo_grant_mapref(struct domain *d1, struct domain *d2,
+                             uint32_t flags) {
+    if ( silo_mode_dom_check(d1->domain_id, d2->domain_id) )
+        return dummy_xsm_ops.grant_mapref(d1, d2, flags);
+    return -EPERM;
+}

What about the unmap counterpart?

This is unnecessary, since we are blocking it from setting up, Those calling unmap must pass the check of maping.

Quoted 2 lines

Jan

Best regards

Xin(Talons) Li

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

#21 lore raw
In reply to Andrew Cooper

Hell Andrew,

Quoted 49 lines

-----Original Message-----
From: Andrew Cooper
Sent: Friday, June 29, 2018 5:48 PM
To: Xin Li <[email protected]>; [email protected]
Cc: Xin Li (Talons) <[email protected]>; Daniel De Graaf <[email protected]>; George Dunlap <[email protected]>; Jan Beulich <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Stefano Stabellini <[email protected]>; Tim (Xen.org) <[email protected]>; Wei Liu <[email protected]>; Sergey Dyasli <[email protected]>; Ming Lu <[email protected]>
Subject: Re: [PATCH 1/2] xen/xsm: Introduce new boot parameter xsm

Quoted 4 lines · Xin Li

Introduce new boot parameter xsm to choose which xsm module is enabled, and set default to dummy.

As a note for other reviewers, this series is based on top of my XSM Kconfig cleanup.

As for this patch, its almost there.  Just a few minor issues.

Quoted 26 lines

---
CC: Daniel De Graaf <[email protected]>
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
CC: Sergey Dyasli <[email protected]>
CC: Andrew Cooper <[email protected]>
CC: Ming Lu <[email protected]>

---
 docs/misc/xen-command-line.markdown | 13 ++++++++++
 xen/xsm/xsm_core.c                  | 39 ++++++++++++++++++++++++++++-
 2 files changed, 51 insertions(+), 1 deletion(-)
docs/misc/xen-command-line.markdown +0 -0
index 075e5ea159..7c689b8225 100644
@@ -865,6 +865,19 @@ hardware domain is architecture dependent.
 Note that specifying zero as domU value means zero, while for dom0 it

means to use the default.

Quoted 6 lines
Quoted 2 lines

+### xsm
+> = dummy | silo | flask

This should be just "dummy | flask" in this patch, and extended with silo in the next path.  Also, options in this file should be sorted alphabetically, so ### xsm should be near the end, rather than beside flask.

Right. Done.

Quoted 55 lines
Quoted 21 lines
docs/misc/xen-command-line.markdown +12 -0
+
+> Default: `dummy`
+
+Specify which XSM module should be enabled.  This option is only
+available if the hypervisor was compiled with XSM support.
+
+* `dummy`: this is the default choice.  No special restriction will be applied.
+  it's also used when XSM is compiled out.
+* `flask`: this is the policy based access control.  To choose this,
+the
+  separated option in kconfig must also be enabled.
+
 ### flask
 > `= permissive | enforcing | late | disabled`
xen/xsm/xsm_core.c index renamed from xen/xsm/xsm_core.c +0 -0

cddcf7aa51..e002200578 100644

xen/xsm/xsm_core.c line 37

Quoted 7 lines
xen/xsm/xsm_core.c +4 -0
@@ -31,6 +31,30 @@
 
 struct xsm_operations *xsm_ops;
 
+enum xsm_bootparam {
+    XSM_BOOTPARAM_DUMMY,
+    XSM_BOOTPARAM_FLASK,
+    XSM_BOOTPARAM_INVALID,

I'd drop INVALID (See below for the parsing aspect), as it actually falls back to DUMMY.

xen/xsm/xsm_core.c

Quoted 3 lines
xen/xsm/xsm_core.c +3 -0
+};
+
+enum xsm_bootparam __read_mostly xsm_bootparam =

XSM_BOOTPARAM_DUMMY;

This should be __initdata rather than __read_mostly.  It is safe to be discarded after boot.

xen/xsm/xsm_core.c line 42

Quoted 2 lines
xen/xsm/xsm_core.c +2 -0
+
+static int __init parse_xsm_param(const char *s) {

int rc = 0;

xen/xsm/xsm_core.c line 44

Quoted 2 lines
xen/xsm/xsm_core.c +2 -0
+    if ( !strcmp(s, "dummy") )
+        xsm_bootparam = XSM_BOOTPARAM_DUMMY; #ifdef

CONFIG_XSM_FLASK

xen/xsm/xsm_core.c line 53

Quoted 6 lines
xen/xsm/xsm_core.c +6 -0
+    else if ( !strcmp(s, "flask") )
+        xsm_bootparam = XSM_BOOTPARAM_FLASK; #endif
+    else
+        xsm_bootparam = XSM_BOOTPARAM_INVALID;
+
+    return 0;
Quoted 8 lines

else
    rc = -EINVAL;

return rc;

As a result, the core command line infrastructure will inform the user if they passed an unrecognised option.

OK. Thank you.

Quoted 29 lines

~Andrew

xen/xsm/xsm_core.c

Quoted 7 lines
xen/xsm/xsm_core.c +5 -0
+}
+
+custom_param("xsm", parse_xsm_param);
+
 static inline int verify(struct xsm_operations *ops)  {
     /* verify the security_operations structure exists */ @@ -57,7
+81,20 @@ static int __init xsm_core_init(const void *policy_buffer, size_t

policy_size)

Quoted 19 lines
xen/xsm/xsm_core.c +14 -1
     }
 
     xsm_ops = &dummy_xsm_ops;
-    flask_init(policy_buffer, policy_size);
+
+    switch ( xsm_bootparam )
+    {
+    case XSM_BOOTPARAM_DUMMY:
+        /* empty */
+        break;
+
+    case XSM_BOOTPARAM_FLASK:
+        flask_init(policy_buffer, policy_size);
+        break;
+
+    default:
+        printk("XSM: Invalid value for xsm= boot parameter.\n");
+    }
Quoted 2 lines
Quoted 2 lines
     return 0;

}

Best regards

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

#6 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

In reply to Xin Li (Talons)
Quoted 11 lines
Quoted 8 lines
Quoted 1 line · On 02.07.18 at 08:57, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:36 PM

Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:28, <[email protected]> wrote:

When SILO is enabled, there would be no page-sharing between unprivileged VMs (no grant tables or event channels).

What is the relation between page sharing and event channels?

They are the two mechanisms exist for inter-domain communication, And we want to block them in SILO mode.

I understand this, but it doesn't answer my question. I agree that grant tables are a means to share pages, but the wording looks odd to me wrt event channels.

Quoted 35 lines
Quoted 35 lines

xen/common/Kconfig config XSM_FLASK_POLICY · line 151

Quoted 12 lines
xen/common/Kconfig +6 -0
@@ -143,6 +143,17 @@ config XSM_FLASK_POLICY
 
 	  If unsure, say Y.
 
+config XSM_SILO
+	def_bool y
+	prompt "SILO support"
+	depends on XSM
+	---help---
+	  Enables SILO as the access control mechanism used by the XSM

framework.

xen/common/Kconfig config XSM_FLASK_POLICY · line 152

Quoted 1 line
xen/common/Kconfig +1 -0
+	  This will deny any unmediated communication channels between

unprivileged

xen/common/Kconfig config XSM_FLASK_POLICY · line 155

Quoted 3 lines
xen/common/Kconfig +3 -0
+	  VMs.
+
+	  If unsure, say Y.

It would be helpful to clarify here that this is not the default mode of operation. In fact, another Kconfig (choice) might be useful to have to select the built-in default. In fact "deny any" suggests that this is what is going to happen regardless of command line options. At the very least I think this wants to be "This will allow to deny any ..." or "In this mode, any ... will by denied".

Andrew, the chosen name here may underline the relevance of my comment regarding XSM_FLASK vs just FLASK, albeit things are unclear/ambiguous if I also take into account the code further down.
The descriptions above make it sound as if this was an override to whatever access control mechanism was in place (dummy or flask currently). Code below suggests though that this is meant to be a clone of dummy, with just some minimal adjustments. I guess it's rather the description that needs adjustment, but the alternative of being a global override even in FLASK mode certainly exists.

Quoted 15 lines
Quoted 3 lines

Furthermore it is unclear here what an "unmediated communication channel" is, and what "mediated communication channels" (if any) are still available in this new mode.

Change to:

config XSM_SILO

Quoted 8 lines

-------def_bool y
-------prompt "SILO support"
-------depends on XSM
----------help---

-------  Enables SILO as the access control mechanism used by the XSM framework.
-------  This is not the default module, add boot parameter xsm=silo to choose
-------  it. This will deny any unmediated communication channels (grant tables
-------  and event channels) between unprivileged VMs.

With s/module/mode/ this is an improvement, but continues to leave open in particular what an "unmediated communication channel" is.

Btw, thinking about it again - do we need a Kconfig option here in the first place, when the mode isn't the default, and it's not a whole lot of code that gets added?

Quoted 7 lines
Quoted 5 lines

xen/common/Kconfig config XSM_FLASK_POLICY · line 157

Quoted 2 lines
xen/common/Kconfig +2 -0
+static bool silo_mode_dom_check(domid_t ldom, domid_t rdom) {
+    domid_t hd_dom = hardware_domain->domain_id;

I don't think you mean the hardware domain here, but the control domain (of which in theory there may be multiple).

I mean the one and only dom0.

No, for the purpose here you don't mean Dom0, which just happens to be both hardware and (the only) control domain in most setups. From a security pov though you need to distinguish all of these.

Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
xen/common/Kconfig +10 -0
+    domid_t cur_dom = current->domain->domain_id;
+
+    if ( ldom == DOMID_SELF )
+        ldom = cur_dom;
+    if ( rdom == DOMID_SELF )
+        rdom = cur_dom;
+
+    return (hd_dom == cur_dom || hd_dom == ldom || hd_dom == rdom ||
+            ldom == rdom);
+}
Quoted 8 lines

xen/common/Kconfig

Quoted 5 lines
xen/common/Kconfig +5 -0
+
+static int silo_evtchn_unbound(struct domain *d1, struct evtchn *chn,
+                               domid_t id2) {
+    if ( silo_mode_dom_check(d1->domain_id, id2) )
+        return dummy_xsm_ops.evtchn_unbound(d1, chn, id2);

Urgh. Why is this not xsm_evtchn_unbound() from dummy.h? It would be really nice to avoid such extra indirect calls here.

Quoted 2 lines

This makes it clearer that we are calling the counterpart of dummy ops(overriding).

Yes, but the same level of clarity could be achieved when naming the function in dummy.h dummy_evtchn_unbound() (aliased to xsm_evtchn_unbound() for satisfying needs elsewhere).

Quoted 1 line

This indirect calls should not introduce any runtime penalty.

How does it not, when indirect calls are more expensive than direct ones already without the Spectre v2 mitigations?

Quoted 13 lines
Quoted 1 line

Furthermore, this hook is called in two contexts. Is the above really

appropriate

Quoted 10 lines

also in the alloc_unbound_xen_event_channel() case?

xen/common/Kconfig

Quoted 6 lines
xen/common/Kconfig +6 -0
+static int silo_grant_mapref(struct domain *d1, struct domain *d2,
+                             uint32_t flags) {
+    if ( silo_mode_dom_check(d1->domain_id, d2->domain_id) )
+        return dummy_xsm_ops.grant_mapref(d1, d2, flags);
+    return -EPERM;
+}

What about the unmap counterpart?

Quoted 2 lines

This is unnecessary, since we are blocking it from setting up, Those calling unmap must pass the check of maping.

Taking that position, the unmap XSM hook's existence is questionable altogether.

Jan

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

#17 lore raw
In reply to Jan Beulich

Hello Jan,

Quoted 28 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:05 PM
To: Andrew Cooper <[email protected]>; Xin Li <[email protected]>
Cc: Ming Lu <[email protected]>; Sergey Dyasli <[email protected]>; Wei Liu <[email protected]>; Xin Li (Talons) <[email protected]>; George Dunlap <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Konrad Rzeszutek Wilk <[email protected]>; Daniel de Graaf <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: Re: [PATCH 1/2] xen/xsm: Introduce new boot parameter xsm

Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:47, <[email protected]> wrote:
Quoted 8 lines · Xin Li
docs/misc/xen-command-line.markdown +0 -0
@@ -865,6 +865,19 @@ hardware domain is architecture dependent.
 Note that specifying zero as domU value means zero, while for dom0

it means to use the default.

+### xsm
+> = dummy | silo | flask

This should be just "dummy | flask" in this patch, and extended with silo in the next path. Also, options in this file should be sorted alphabetically, so ### xsm should be near the end, rather than beside flask.

Quoted 12 lines
Quoted 10 lines

docs/misc/xen-command-line.markdown hardware domain is architecture dependent.

Quoted 10 lines
docs/misc/xen-command-line.markdown +10 -0
+
+> Default: `dummy`
+
+Specify which XSM module should be enabled.  This option is only
+available if the hypervisor was compiled with XSM support.
+
+* `dummy`: this is the default choice.  No special restriction will be applied.
+  it's also used when XSM is compiled out.
+enum xsm_bootparam __read_mostly xsm_bootparam =
+XSM_BOOTPARAM_DUMMY;

So why "dummy" instead of "none" (or one of the boolean false strings)?

It seems dummy is not fully stub. (some check by XSM_* classification) So we want to keep this "dummy" check, and override it.

Quoted 5 lines
Quoted 3 lines

This should be __initdata rather than __read_mostly. It is safe to be discarded after boot.

And static.

OK. Done.

Quoted 23 lines
Quoted 7 lines
Quoted 2 lines

+static int __init parse_xsm_param(const char *s) {

int rc = 0;

Quoted 2 lines
docs/misc/xen-command-line.markdown +2 -0
+    if ( !strcmp(s, "dummy") )
+        xsm_bootparam = XSM_BOOTPARAM_DUMMY; #ifdef

CONFIG_XSM_FLASK

Quoted 15 lines

docs/misc/xen-command-line.markdown

Quoted 6 lines
docs/misc/xen-command-line.markdown +6 -0
+    else if ( !strcmp(s, "flask") )
+        xsm_bootparam = XSM_BOOTPARAM_FLASK; #endif
+    else
+        xsm_bootparam = XSM_BOOTPARAM_INVALID;
+
+    return 0;

else

    rc = -EINVAL;

return rc;

As a result, the core command line infrastructure will inform the user if they passed an unrecognised option.

Quoted 8 lines
Quoted 5 lines

~Andrew

docs/misc/xen-command-line.markdown

Quoted 3 lines
docs/misc/xen-command-line.markdown +3 -0
+}
+
+custom_param("xsm", parse_xsm_param);

Please avoid the blank line above here - in the majority of similar cases, we have the custom_param() immediately follow the parsing function.

OK. Done.

Quoted 13 lines
Quoted 2 lines

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void

Quoted 2 lines
docs/misc/xen-command-line.markdown +0 -0
@@ -57,7 +81,20 @@ static int __init xsm_core_init(const void

*policy_buffer, size_t policy_size)

Quoted 9 lines

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void · line 88

Quoted 9 lines
docs/misc/xen-command-line.markdown +5 -1
     }
 
     xsm_ops = &dummy_xsm_ops;
-    flask_init(policy_buffer, policy_size);
+
+    switch ( xsm_bootparam )
+    {
+    case XSM_BOOTPARAM_DUMMY:
+        /* empty */
Quoted 1 line

I'm not sure of the value of this comment.

I just want avoid an empty switch case.

Quoted 12 lines
Quoted 10 lines

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void · line 97

Quoted 10 lines
docs/misc/xen-command-line.markdown +9 -0
+        break;
+
+    case XSM_BOOTPARAM_FLASK:
+        flask_init(policy_buffer, policy_size);
+        break;
+
+    default:
+        printk("XSM: Invalid value for xsm= boot parameter.\n");
+    }

Please don't omit the "break;" here.

Sure, done.

Quoted 3 lines

Jan

Best regards

Xin(Talons) Li

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

#18 lore raw
Quoted 31 lines
Quoted 18 lines
Quoted 1 line · On 02.07.18 at 09:34, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:05 PM

Quoted 15 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:47, <[email protected]> wrote:
Quoted 8 lines · Xin Li
docs/misc/xen-command-line.markdown +0 -0
@@ -865,6 +865,19 @@ hardware domain is architecture dependent.
 Note that specifying zero as domU value means zero, while for dom0

it means to use the default.

+### xsm
+> = dummy | silo | flask

This should be just "dummy | flask" in this patch, and extended with silo in the next path. Also, options in this file should be sorted alphabetically, so ### xsm should be near the end, rather than beside flask.

Quoted 12 lines
Quoted 10 lines

docs/misc/xen-command-line.markdown hardware domain is architecture dependent.

Quoted 10 lines
docs/misc/xen-command-line.markdown +10 -0
+
+> Default: `dummy`
+
+Specify which XSM module should be enabled.  This option is only
+available if the hypervisor was compiled with XSM support.
+
+* `dummy`: this is the default choice.  No special restriction will be applied.
+  it's also used when XSM is compiled out.
+enum xsm_bootparam __read_mostly xsm_bootparam =
+XSM_BOOTPARAM_DUMMY;

So why "dummy" instead of "none" (or one of the boolean false strings)?

Quoted 2 lines

It seems dummy is not fully stub. (some check by XSM_* classification) So we want to keep this "dummy" check, and override it.

Right, except that "dummy", while a reasonable name internally to the implementation, is at least of questionable use/meaning as a part of a command line option.

Quoted 12 lines
Quoted 12 lines
Quoted 1 line

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void

Quoted 1 line
docs/misc/xen-command-line.markdown +0 -0
@@ -57,7 +81,20 @@ static int __init xsm_core_init(const void

*policy_buffer, size_t policy_size)

Quoted 9 lines
Quoted 9 lines
docs/misc/xen-command-line.markdown +5 -1
     }
 
     xsm_ops = &dummy_xsm_ops;
-    flask_init(policy_buffer, policy_size);
+
+    switch ( xsm_bootparam )
+    {
+    case XSM_BOOTPARAM_DUMMY:
+        /* empty */
Quoted 2 lines
Quoted 1 line

I'm not sure of the value of this comment.

I just want avoid an empty switch case.

Well, it's not empty because of ...

Quoted 1 line
Quoted 1 line
Quoted 1 line

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void · line 89

Quoted 1 line
docs/misc/xen-command-line.markdown +1 -0
+        break;

... this (without which it would be a fall-through one).

Jan

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

#19 lore raw

Hello Jan

Quoted 45 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, July 2, 2018 4:25 PM
To: Xin Li (Talons) <[email protected]>; Xin Li <[email protected]>
Cc: Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ming Lu <[email protected]>; Sergey Dyasli <[email protected]>; Wei Liu <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Konrad Rzeszutek Wilk <[email protected]>; Daniel de Graaf <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: RE: [PATCH 1/2] xen/xsm: Introduce new boot parameter xsm

Quoted 11 lines
Quoted 11 lines
Quoted 1 line · On 02.07.18 at 09:34, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:05 PM

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:47, <[email protected]> wrote:
Quoted 6 lines · Xin Li
docs/misc/xen-command-line.markdown +0 -0
@@ -865,6 +865,19 @@ hardware domain is architecture dependent.
 Note that specifying zero as domU value means zero, while for

dom0 it means to use the default.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

+### xsm
+> = dummy | silo | flask

This should be just "dummy | flask" in this patch, and extended with silo in the next path. Also, options in this file should be sorted alphabetically, so ### xsm should be near the end, rather than

beside flask.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

docs/misc/xen-command-line.markdown hardware domain is architecture dependent.

Quoted 8 lines
docs/misc/xen-command-line.markdown +7 -0
+
+> Default: `dummy`
+
+Specify which XSM module should be enabled.  This option is only
+available if the hypervisor was compiled with XSM support.
+
+* `dummy`: this is the default choice.  No special restriction will be

applied.

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

docs/misc/xen-command-line.markdown

Quoted 3 lines
docs/misc/xen-command-line.markdown +3 -0
+  it's also used when XSM is compiled out.
+enum xsm_bootparam __read_mostly xsm_bootparam =
+XSM_BOOTPARAM_DUMMY;

So why "dummy" instead of "none" (or one of the boolean false strings)?

Quoted 6 lines
Quoted 2 lines

It seems dummy is not fully stub. (some check by XSM_* classification) So we want to keep this "dummy" check, and override it.

Right, except that "dummy", while a reasonable name internally to the implementation, is at least of questionable use/meaning as a part of a command line option.

is it better to keep them the same?

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void

Quoted 2 lines
docs/misc/xen-command-line.markdown +0 -0
@@ -57,7 +81,20 @@ static int __init xsm_core_init(const void

*policy_buffer, size_t policy_size)

Quoted 9 lines
Quoted 9 lines
docs/misc/xen-command-line.markdown +5 -1
     }
 
     xsm_ops = &dummy_xsm_ops;
-    flask_init(policy_buffer, policy_size);
+
+    switch ( xsm_bootparam )
+    {
+    case XSM_BOOTPARAM_DUMMY:
+        /* empty */
Quoted 8 lines
Quoted 2 lines
Quoted 1 line

I'm not sure of the value of this comment.

I just want avoid an empty switch case.

Well, it's not empty because of ...

Quoted 1 line
Quoted 1 line
Quoted 1 line

docs/misc/xen-command-line.markdown static int __init xsm_core_init(const void · line 89

Quoted 1 line
docs/misc/xen-command-line.markdown +1 -0
+        break;

... this (without which it would be a fall-through one).

Oh, OK, remove this comment.

Quoted 3 lines

Jan

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

#20 lore raw
Quoted 36 lines
Quoted 36 lines
Quoted 1 line · On 02.07.18 at 10:39, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Monday, July 2, 2018 4:25 PM

Quoted 11 lines
Quoted 11 lines
Quoted 1 line · On 02.07.18 at 09:34, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:05 PM

Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:47, <[email protected]> wrote:
Quoted 6 lines · Xin Li
docs/misc/xen-command-line.markdown +0 -0
@@ -865,6 +865,19 @@ hardware domain is architecture dependent.
 Note that specifying zero as domU value means zero, while for

dom0 it means to use the default.

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

+### xsm
+> = dummy | silo | flask

This should be just "dummy | flask" in this patch, and extended with silo in the next path. Also, options in this file should be sorted alphabetically, so ### xsm should be near the end, rather than

beside flask.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

docs/misc/xen-command-line.markdown hardware domain is architecture dependent.

Quoted 8 lines
docs/misc/xen-command-line.markdown +7 -0
+
+> Default: `dummy`
+
+Specify which XSM module should be enabled.  This option is only
+available if the hypervisor was compiled with XSM support.
+
+* `dummy`: this is the default choice.  No special restriction will be

applied.

Quoted 6 lines
Quoted 5 lines
Quoted 3 lines

docs/misc/xen-command-line.markdown

Quoted 3 lines
docs/misc/xen-command-line.markdown +3 -0
+  it's also used when XSM is compiled out.
+enum xsm_bootparam __read_mostly xsm_bootparam =
+XSM_BOOTPARAM_DUMMY;

So why "dummy" instead of "none" (or one of the boolean false strings)?

Quoted 7 lines
Quoted 6 lines
Quoted 2 lines

It seems dummy is not fully stub. (some check by XSM_* classification) So we want to keep this "dummy" check, and override it.

Right, except that "dummy", while a reasonable name internally to the implementation, is at least of questionable use/meaning as a part of a command line option.

is it better to keep them the same?

Well, I'm not entirely sure, hence I've made the original remark in the first place. Command line options should be reasonably meaningful to those potentially having to use / remember them, so there are cases where they're better not in 1:1 relationship with naming in source code. If "none" isn't applicable, how about "basic", "trivial", or "simple"?

Jan

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

#7 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

In reply to Jan Beulich

Hello Jan,

Quoted 19 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, July 2, 2018 3:29 PM
To: Xin Li (Talons) <[email protected]>; Xin Li <[email protected]>
Cc: Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ming Lu <[email protected]>; Sergey Dyasli <[email protected]>; Wei Liu <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Konrad Rzeszutek Wilk <[email protected]>; Daniel de Graaf <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: RE: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Quoted 7 lines
Quoted 7 lines
Quoted 1 line · On 02.07.18 at 08:57, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:36 PM

Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:28, <[email protected]> wrote:

When SILO is enabled, there would be no page-sharing between unprivileged VMs (no grant tables or event channels).

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

What is the relation between page sharing and event channels?

They are the two mechanisms exist for inter-domain communication, And we want to block them in SILO mode.

I understand this, but it doesn't answer my question. I agree that grant tables are a means to share pages, but the wording looks odd to me wrt event channels.

Do you mean add " or event notifications",
When SILO is enabled, there would be no page-sharing or event notifications between unprivileged VMs (no grant tables or event channels).

Quoted 52 lines
Quoted 14 lines
Quoted 14 lines

xen/common/Kconfig config XSM_FLASK_POLICY · line 151

Quoted 13 lines
xen/common/Kconfig +6 -0
@@ -143,6 +143,17 @@ config XSM_FLASK_POLICY
 
 	  If unsure, say Y.
 
+config XSM_SILO
+	def_bool y
+	prompt "SILO support"
+	depends on XSM
+	---help---
+	  Enables SILO as the access control mechanism used by the XSM

framework.

Quoted 7 lines
Quoted 7 lines

xen/common/Kconfig config XSM_FLASK_POLICY · line 152

Quoted 1 line
xen/common/Kconfig +1 -0
+	  This will deny any unmediated communication channels between

unprivileged

xen/common/Kconfig config XSM_FLASK_POLICY · line 155

Quoted 3 lines
xen/common/Kconfig +3 -0
+	  VMs.
+
+	  If unsure, say Y.

It would be helpful to clarify here that this is not the default mode of

operation.

Quoted 4 lines
Quoted 4 lines

In fact, another Kconfig (choice) might be useful to have to select the built-in default. In fact "deny any" suggests that this is what is going to happen regardless of command line options. At the very least I think this wants to be "This will allow to deny any ..." or "In this mode,

any ... will by denied".

Quoted 11 lines
Quoted 11 lines

Andrew, the chosen name here may underline the relevance of my comment regarding XSM_FLASK vs just FLASK, albeit things are unclear/ambiguous if I also take into account the code further down. The descriptions above make it sound as if this was an override to whatever access control mechanism was in place (dummy or flask currently). Code below suggests though that this is meant to be a clone of dummy, with just some minimal adjustments. I guess it's rather the description that needs adjustment, but the alternative of being a global override even in FLASK mode certainly exists.

Quoted 1 line
Quoted 1 line

Furthermore it is unclear here what an "unmediated communication

channel"

Quoted 11 lines
Quoted 2 lines

is, and what "mediated communication channels" (if any) are still available in this new mode.

Change to:

config XSM_SILO

Quoted 5 lines

-------def_bool y
-------prompt "SILO support"
-------depends on XSM
----------help---
------- Enables SILO as the access control mechanism used by the XSM

framework.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

------- This is not the default module, add boot parameter xsm=silo to choose
------- it. This will deny any unmediated communication channels (grant tables
------- and event channels) between unprivileged VMs.

With s/module/mode/ this is an improvement, but continues to leave open in particular what an "unmediated communication channel" is.

This can't prevent side-channel attack.

Quoted 4 lines

Btw, thinking about it again - do we need a Kconfig option here in the first place, when the mode isn't the default, and it's not a whole lot of code that gets added?

The existing XSM code use Kconfig,
I just want to follow the similar style for new module. And yes, we can handle it in CONFIG_XSM like dummy. Which way is better?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
xen/common/Kconfig +2 -0
+static bool silo_mode_dom_check(domid_t ldom, domid_t rdom) {
+    domid_t hd_dom = hardware_domain->domain_id;
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

I don't think you mean the hardware domain here, but the control domain (of which in theory there may be multiple).

I mean the one and only dom0.

No, for the purpose here you don't mean Dom0, which just happens to be both hardware and (the only) control domain in most setups. From a security pov though you need to distinguish all of these.

Yes! thanks.
I will use
is_control_domain(d)
instead of comparing the hardware domain id.

This comment is misleading then:
/* Is this guest fully privileged (aka dom0)? */
bool is_privileged;

Quoted 23 lines
Quoted 8 lines
Quoted 8 lines

xen/common/Kconfig config XSM_FLASK_POLICY

Quoted 8 lines
xen/common/Kconfig +8 -0
+    domid_t cur_dom = current->domain->domain_id;
+
+    if ( ldom == DOMID_SELF )
+        ldom = cur_dom;
+    if ( rdom == DOMID_SELF )
+        rdom = cur_dom;
+
+    return (hd_dom == cur_dom || hd_dom == ldom || hd_dom == rdom
||
>> > +            ldom == rdom);
Quoted 10 lines
Quoted 9 lines

xen/common/Kconfig

Quoted 6 lines
xen/common/Kconfig +6 -0
+}
+
+static int silo_evtchn_unbound(struct domain *d1, struct evtchn *chn,
+                               domid_t id2) {
+    if ( silo_mode_dom_check(d1->domain_id, id2) )
+        return dummy_xsm_ops.evtchn_unbound(d1, chn, id2);

Urgh. Why is this not xsm_evtchn_unbound() from dummy.h? It would be really nice to avoid such extra indirect calls here.

Quoted 2 lines

This makes it clearer that we are calling the counterpart of dummy ops(overriding).

Quoted 8 lines

Yes, but the same level of clarity could be achieved when naming the function in dummy.h dummy_evtchn_unbound() (aliased to xsm_evtchn_unbound() for satisfying needs elsewhere).

Quoted 1 line

This indirect calls should not introduce any runtime penalty.

How does it not, when indirect calls are more expensive than direct ones already without the Spectre v2 mitigations?

I only mean it's not runtime binding.

And I ran some performance test before, seems no performance penalty.

The names in dummy.h are the same as xsm.h.
If I call xsm_evtchn_unbound, that's from xsm.h, It probably call silo_evtchn_unbound, ends up in a loop.

So I may have to rename all the functions in dummy.h, And remove static...

is it necessary?

Quoted 14 lines
Quoted 14 lines
Quoted 2 lines

Furthermore, this hook is called in two contexts. Is the above really

appropriate

Quoted 10 lines

also in the alloc_unbound_xen_event_channel() case?

xen/common/Kconfig

Quoted 6 lines
xen/common/Kconfig +6 -0
+static int silo_grant_mapref(struct domain *d1, struct domain *d2,
+                             uint32_t flags) {
+    if ( silo_mode_dom_check(d1->domain_id, d2->domain_id) )
+        return dummy_xsm_ops.grant_mapref(d1, d2, flags);
+    return -EPERM;
+}

What about the unmap counterpart?

Quoted 5 lines
Quoted 2 lines

This is unnecessary, since we are blocking it from setting up, Those calling unmap must pass the check of maping.

Taking that position, the unmap XSM hook's existence is questionable altogether.

I think that's for completeness.
We can override it only when necessary.
But this change don't have to include that part.

Quoted 2 lines

Jan

Best regards

Xin(Talons) Li

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

#8 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Quoted 15 lines
Quoted 15 lines
Quoted 1 line · On 02.07.18 at 11:22, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Monday, July 2, 2018 3:29 PM

Quoted 11 lines
Quoted 8 lines
Quoted 1 line · On 02.07.18 at 08:57, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:36 PM

Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:28, <[email protected]> wrote:

When SILO is enabled, there would be no page-sharing between unprivileged VMs (no grant tables or event channels).

What is the relation between page sharing and event channels?

They are the two mechanisms exist for inter-domain communication, And we want to block them in SILO mode.

Quoted 6 lines
Quoted 3 lines

I understand this, but it doesn't answer my question. I agree that grant tables are a means to share pages, but the wording looks odd to me wrt event channels.

Do you mean add " or event notifications",
When SILO is enabled, there would be no page-sharing or event notifications between unprivileged VMs (no grant tables or event channels).

Yes, that's one way to clarify things.

Quoted 15 lines
Quoted 15 lines
Quoted 8 lines

Change to:

config XSM_SILO

Quoted 5 lines

-------def_bool y
-------prompt "SILO support"
-------depends on XSM
----------help---
------- Enables SILO as the access control mechanism used by the XSM

framework.

Quoted 5 lines
Quoted 5 lines

------- This is not the default module, add boot parameter xsm=silo to choose
------- it. This will deny any unmediated communication channels (grant tables
------- and event channels) between unprivileged VMs.

Quoted 3 lines
Quoted 2 lines

With s/module/mode/ this is an improvement, but continues to leave open in particular what an "unmediated communication channel" is.

This can't prevent side-channel attack.

???

Quoted 8 lines
Quoted 2 lines

Btw, thinking about it again - do we need a Kconfig option here in the first place, when the mode isn't the default, and it's not a whole lot of code

that gets

Quoted 1 line

added?

The existing XSM code use Kconfig,
I just want to follow the similar style for new module. And yes, we can handle it in CONFIG_XSM like dummy. Which way is better?

Daniel, Andrew?

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+static bool silo_mode_dom_check(domid_t ldom, domid_t rdom) {
+    domid_t hd_dom = hardware_domain->domain_id;

I don't think you mean the hardware domain here, but the control domain (of which in theory there may be multiple).

I mean the one and only dom0.

No, for the purpose here you don't mean Dom0, which just happens to be both hardware and (the only) control domain in most setups. From a security pov though you need to distinguish all of these.

Quoted 8 lines

Yes! thanks.
I will use
is_control_domain(d)
instead of comparing the hardware domain id.

This comment is misleading then:
/* Is this guest fully privileged (aka dom0)? */
bool is_privileged;

Yes, but it's likely going to remain that way until further disaggregation work would happen.

Quoted 27 lines
Quoted 27 lines
Quoted 8 lines
Quoted 8 lines

xen/xsm/silo.c

Quoted 8 lines
xen/xsm/silo.c new file +8 -0
+    domid_t cur_dom = current->domain->domain_id;
+
+    if ( ldom == DOMID_SELF )
+        ldom = cur_dom;
+    if ( rdom == DOMID_SELF )
+        rdom = cur_dom;
+
+    return (hd_dom == cur_dom || hd_dom == ldom || hd_dom == rdom
||
>> > +            ldom == rdom);
Quoted 10 lines
Quoted 9 lines

xen/xsm/silo.c line 49

Quoted 6 lines
xen/xsm/silo.c new file +6 -0
+}
+
+static int silo_evtchn_unbound(struct domain *d1, struct evtchn *chn,
+                               domid_t id2) {
+    if ( silo_mode_dom_check(d1->domain_id, id2) )
+        return dummy_xsm_ops.evtchn_unbound(d1, chn, id2);

Urgh. Why is this not xsm_evtchn_unbound() from dummy.h? It would be really nice to avoid such extra indirect calls here.

Quoted 2 lines

This makes it clearer that we are calling the counterpart of dummy ops(overriding).

Yes, but the same level of clarity could be achieved when naming the function in dummy.h dummy_evtchn_unbound() (aliased to xsm_evtchn_unbound() for satisfying needs elsewhere).

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

This indirect calls should not introduce any runtime penalty.

How does it not, when indirect calls are more expensive than direct ones already without the Spectre v2 mitigations?

I only mean it's not runtime binding.

And I ran some performance test before, seems no performance penalty.

Sure, these paths aren't normally performance critical. But by doing what you do we'd have a bad precedent, and if someone later cloned your solution into something that does sit on a performance critical path, we'd have a problem.

Quoted 5 lines

The names in dummy.h are the same as xsm.h.
If I call xsm_evtchn_unbound, that's from xsm.h, It probably call silo_evtchn_unbound, ends up in a loop.

So I may have to rename all the functions in dummy.h,

Note how I've said "naming the function in dummy.h dummy_evtchn_unbound() (aliased to xsm_evtchn_unbound() for satisfying needs elsewhere)."

Quoted 1 line

And remove static...

I don't think so, no.

Quoted 1 line

is it necessary?

It should imo be at least considered. But Daniel as the maintainer may have something to say here as well...

Jan

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

#9 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Hi
I think the main questions here are:
1. Do we need a separated KConfig option for SILO
2. Can we use indirect call like "dummy_xsm_ops.grant_copy" Any suggestion?

Best regards

Xin(Talons) Li

Quoted 146 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, July 2, 2018 5:39 PM
To: Xin Li (Talons) <[email protected]>; Xin Li <[email protected]>
Cc: Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ming Lu <[email protected]>; Sergey Dyasli <[email protected]>; Wei Liu <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Konrad Rzeszutek Wilk <[email protected]>; Daniel de Graaf <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: RE: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Quoted 15 lines
Quoted 15 lines
Quoted 1 line · On 02.07.18 at 11:22, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Monday, July 2, 2018 3:29 PM

Quoted 11 lines
Quoted 8 lines
Quoted 1 line · On 02.07.18 at 08:57, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:36 PM

Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:28, <[email protected]> wrote:

When SILO is enabled, there would be no page-sharing between unprivileged VMs (no grant tables or event channels).

What is the relation between page sharing and event channels?

They are the two mechanisms exist for inter-domain communication, And we want to block them in SILO mode.

Quoted 6 lines
Quoted 3 lines

I understand this, but it doesn't answer my question. I agree that grant tables are a means to share pages, but the wording looks odd to me wrt event channels.

Do you mean add " or event notifications", When SILO is enabled, there would be no page-sharing or event notifications between unprivileged VMs (no grant tables or event channels).

Yes, that's one way to clarify things.

Quoted 16 lines
Quoted 16 lines
Quoted 9 lines

Change to:

config XSM_SILO

Quoted 6 lines

-------def_bool y
-------prompt "SILO support"
-------depends on XSM
----------help---
------- Enables SILO as the access control mechanism used by the XSM

framework.

Quoted 5 lines
Quoted 5 lines

------- This is not the default module, add boot parameter xsm=silo to choose
------- it. This will deny any unmediated communication channels (grant tables
------- and event channels) between unprivileged VMs.

Quoted 3 lines
Quoted 2 lines

With s/module/mode/ this is an improvement, but continues to leave open in particular what an "unmediated communication channel" is.

This can't prevent side-channel attack.

???

Quoted 9 lines
Quoted 3 lines

Btw, thinking about it again - do we need a Kconfig option here in the first place, when the mode isn't the default, and it's not a whole lot of code

that gets

Quoted 1 line

added?

The existing XSM code use Kconfig,
I just want to follow the similar style for new module. And yes, we can handle it in CONFIG_XSM like dummy. Which way is better?

Daniel, Andrew?

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+static bool silo_mode_dom_check(domid_t ldom, domid_t rdom) {
+    domid_t hd_dom = hardware_domain->domain_id;

I don't think you mean the hardware domain here, but the control domain (of which in theory there may be multiple).

I mean the one and only dom0.

No, for the purpose here you don't mean Dom0, which just happens to be both hardware and (the only) control domain in most setups. From a security pov though you need to distinguish all of these.

Quoted 8 lines

Yes! thanks.
I will use
is_control_domain(d)
instead of comparing the hardware domain id.

This comment is misleading then:
/* Is this guest fully privileged (aka dom0)? */
bool is_privileged;

Yes, but it's likely going to remain that way until further disaggregation work would happen.

Quoted 28 lines
Quoted 28 lines
Quoted 9 lines
Quoted 9 lines

xen/xsm/silo.c

Quoted 9 lines
xen/xsm/silo.c new file +9 -0
+    domid_t cur_dom = current->domain->domain_id;
+
+    if ( ldom == DOMID_SELF )
+        ldom = cur_dom;
+    if ( rdom == DOMID_SELF )
+        rdom = cur_dom;
+
+    return (hd_dom == cur_dom || hd_dom == ldom || hd_dom ==
+ rdom
||
>> > +            ldom == rdom);
Quoted 10 lines
Quoted 9 lines

xen/xsm/silo.c line 49

Quoted 6 lines
xen/xsm/silo.c new file +6 -0
+}
+
+static int silo_evtchn_unbound(struct domain *d1, struct evtchn *chn,
+                               domid_t id2) {
+    if ( silo_mode_dom_check(d1->domain_id, id2) )
+        return dummy_xsm_ops.evtchn_unbound(d1, chn, id2);

Urgh. Why is this not xsm_evtchn_unbound() from dummy.h? It would be really nice to avoid such extra indirect calls here.

Quoted 2 lines

This makes it clearer that we are calling the counterpart of dummy ops(overriding).

Yes, but the same level of clarity could be achieved when naming the function in dummy.h dummy_evtchn_unbound() (aliased to xsm_evtchn_unbound() for satisfying needs elsewhere).

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

This indirect calls should not introduce any runtime penalty.

How does it not, when indirect calls are more expensive than direct ones already without the Spectre v2 mitigations?

I only mean it's not runtime binding.

And I ran some performance test before, seems no performance penalty.

Sure, these paths aren't normally performance critical. But by doing what you do we'd have a bad precedent, and if someone later cloned your solution into something that does sit on a performance critical path, we'd have a problem.

Quoted 5 lines

The names in dummy.h are the same as xsm.h.
If I call xsm_evtchn_unbound, that's from xsm.h, It probably call silo_evtchn_unbound, ends up in a loop.

So I may have to rename all the functions in dummy.h,

Note how I've said "naming the function in dummy.h dummy_evtchn_unbound() (aliased to xsm_evtchn_unbound() for satisfying needs elsewhere)."

Quoted 1 line

And remove static...

Quoted 8 lines

I don't think so, no.

Quoted 1 line

is it necessary?

It should imo be at least considered. But Daniel as the maintainer may have something to say here as well...

Jan

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

#10 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 23.07.18 at 12:45, <[email protected]> wrote:

I think the main questions here are:
1. Do we need a separated KConfig option for SILO
2. Can we use indirect call like "dummy_xsm_ops.grant_copy" Any suggestion?

I'm afraid the addressing of your mail is misleading: I've voiced my opinion, so I'm unlikely the one you've meant to be on the To list.

Jan

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

#11 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

In reply to Jan Beulich

Hi Daniel,

I think the main questions here are:
1. Do we need a separated KConfig option for SILO
2. Can we use indirect call like "dummy_xsm_ops.grant_copy" Any suggestion?

Best regards

Xin(Talons) Li

Quoted 127 lines
Quoted 127 lines

-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: Monday, July 2, 2018 5:39 PM
To: Xin Li (Talons) <[email protected]>; Xin Li <[email protected]>
Cc: Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ming Lu <[email protected]>; Sergey Dyasli <[email protected]>; Wei Liu <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Konrad Rzeszutek Wilk <[email protected]>; Daniel de Graaf <[email protected]>; Tim
(Xen.org) <[email protected]>
Subject: RE: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Quoted 15 lines
Quoted 15 lines
Quoted 1 line · On 02.07.18 at 11:22, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Monday, July 2, 2018 3:29 PM

Quoted 11 lines
Quoted 8 lines
Quoted 1 line · On 02.07.18 at 08:57, <[email protected]> wrote:

From: Jan Beulich [mailto:[email protected]]
Sent: Friday, June 29, 2018 6:36 PM

Quoted 3 lines
Quoted 1 line
Quoted 1 line · On 29.06.18 at 11:28, <[email protected]> wrote:

When SILO is enabled, there would be no page-sharing between unprivileged VMs (no grant tables or event channels).

What is the relation between page sharing and event channels?

They are the two mechanisms exist for inter-domain communication, And we want to block them in SILO mode.

Quoted 6 lines
Quoted 3 lines

I understand this, but it doesn't answer my question. I agree that grant tables are a means to share pages, but the wording looks odd to me wrt event channels.

Do you mean add " or event notifications", When SILO is enabled, there would be no page-sharing or event notifications between unprivileged VMs (no grant tables or event channels).

Yes, that's one way to clarify things.

Quoted 16 lines
Quoted 16 lines
Quoted 9 lines

Change to:

config XSM_SILO

Quoted 6 lines

-------def_bool y
-------prompt "SILO support"
-------depends on XSM
----------help---
------- Enables SILO as the access control mechanism used by the XSM

framework.

Quoted 5 lines
Quoted 5 lines

------- This is not the default module, add boot parameter xsm=silo to choose
------- it. This will deny any unmediated communication channels (grant tables
------- and event channels) between unprivileged VMs.

Quoted 3 lines
Quoted 2 lines

With s/module/mode/ this is an improvement, but continues to leave open in particular what an "unmediated communication channel" is.

This can't prevent side-channel attack.

???

Quoted 9 lines
Quoted 3 lines

Btw, thinking about it again - do we need a Kconfig option here in the first place, when the mode isn't the default, and it's not a whole lot of code

that gets

Quoted 1 line

added?

The existing XSM code use Kconfig,
I just want to follow the similar style for new module. And yes, we can handle it in CONFIG_XSM like dummy. Which way is better?

Daniel, Andrew?

Quoted 12 lines
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+static bool silo_mode_dom_check(domid_t ldom, domid_t rdom) {
+    domid_t hd_dom = hardware_domain->domain_id;

I don't think you mean the hardware domain here, but the control domain (of which in theory there may be multiple).

I mean the one and only dom0.

No, for the purpose here you don't mean Dom0, which just happens to be both hardware and (the only) control domain in most setups. From a security pov though you need to distinguish all of these.

Quoted 8 lines

Yes! thanks.
I will use
is_control_domain(d)
instead of comparing the hardware domain id.

This comment is misleading then:
/* Is this guest fully privileged (aka dom0)? */
bool is_privileged;

Yes, but it's likely going to remain that way until further disaggregation work would happen.

Quoted 32 lines
Quoted 32 lines
Quoted 9 lines
Quoted 9 lines

xen/xsm/silo.c

Quoted 9 lines
xen/xsm/silo.c new file +9 -0
+    domid_t cur_dom = current->domain->domain_id;
+
+    if ( ldom == DOMID_SELF )
+        ldom = cur_dom;
+    if ( rdom == DOMID_SELF )
+        rdom = cur_dom;
+
+    return (hd_dom == cur_dom || hd_dom == ldom || hd_dom ==
+ rdom
||
>> > +            ldom == rdom);
Quoted 10 lines
Quoted 9 lines

xen/xsm/silo.c line 49

Quoted 6 lines
xen/xsm/silo.c new file +6 -0
+}
+
+static int silo_evtchn_unbound(struct domain *d1, struct evtchn *chn,
+                               domid_t id2) {
+    if ( silo_mode_dom_check(d1->domain_id, id2) )
+        return dummy_xsm_ops.evtchn_unbound(d1, chn, id2);

Urgh. Why is this not xsm_evtchn_unbound() from dummy.h? It would be really nice to avoid such extra indirect calls here.

Quoted 2 lines

This makes it clearer that we are calling the counterpart of dummy ops(overriding).

Yes, but the same level of clarity could be achieved when naming the function in dummy.h dummy_evtchn_unbound() (aliased to xsm_evtchn_unbound() for satisfying needs elsewhere).

Quoted 1 line

This indirect calls should not introduce any runtime penalty.

How does it not, when indirect calls are more expensive than direct ones already without the Spectre v2 mitigations?

Quoted 29 lines
Quoted 7 lines
Quoted 3 lines

I only mean it's not runtime binding.

And I ran some performance test before, seems no performance penalty.

Sure, these paths aren't normally performance critical. But by doing what you do we'd have a bad precedent, and if someone later cloned your solution into something that does sit on a performance critical path,

we'd have a problem.

Quoted 21 lines
Quoted 6 lines

The names in dummy.h are the same as xsm.h.
If I call xsm_evtchn_unbound, that's from xsm.h, It probably call silo_evtchn_unbound, ends up in a loop.

So I may have to rename all the functions in dummy.h,

Note how I've said "naming the function in dummy.h dummy_evtchn_unbound() (aliased to xsm_evtchn_unbound() for satisfying needs elsewhere)."

Quoted 1 line

And remove static...

I don't think so, no.

Quoted 1 line

is it necessary?

It should imo be at least considered. But Daniel as the maintainer may have something to say here as well...

Jan

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

#12 lore raw

Re: [PATCH 2/2] xen/xsm: Add new SILO mode for XSM

Quoted 4 lines · Xin Li (Talons)

Hi Daniel,

I think the main questions here are:
1. Do we need a separated KConfig option for SILO

Yes; I made comments on your patch doing so

Quoted 2 lines

2. Can we use indirect call like "dummy_xsm_ops.grant_copy" Any suggestion?

It would be nice to avoid it. Making a global dummy_xsm_grant_copy() function would be better, though the best location of the prototype and code isn't obvious.

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