Skip to contentSkip to conversation

xsm: hide detailed Xen version

PATCH In review Sergey Dyasli 3 participants 8 messages Feb 11, 2020 – Sep 4, 2020

lore
Share & tools
lore
#0 lore raw

v4 cover xsm: hide detailed Xen version

Now a proper 2 patches series.

Sergey Dyasli (2):
xsm: add Kconfig option for denied string
xsm: hide detailed Xen version from unprivileged guests

 tools/firmware/hvmloader/hvmloader.c |  1 +
 tools/firmware/hvmloader/smbios.c    |  1 +
 tools/firmware/hvmloader/util.c      | 11 +++++++++++
 tools/firmware/hvmloader/util.h      |  2 ++
 xen/common/Kconfig                   |  8 ++++++++
 xen/common/kernel.c                  | 11 +++++++++++
 xen/common/version.c                 |  4 ++++
 xen/include/public/version.h         |  5 +++++
 xen/include/xsm/dummy.h              | 16 ++++++++++++----
 9 files changed, 55 insertions(+), 4 deletions(-)
Signature · 7 lines
2.17.1


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

PATCH v4 1/2 xsm: add Kconfig option for denied string

Add Kconfig option to make it possible to configure the string returned to non-privileged guests instead of the default "<denied>" which could propagate to UI / logs after the subsequent patch that hides detailed Xen version information from unprivileged guests.

Introduce XENVER_denied_string to allow guests to set up UI / logs filtering which dependens on the new CONFIG_XSM_DENIED_STRING.

---
v3 --> v4:
- Updated kconfig prompt description
- Added XENVER_denied_string
- Added #ifdef to fix build when CONFIG_XSM is not set

v2 --> v3:
- new patch

---
 xen/common/Kconfig           |  8 ++++++++
 xen/common/kernel.c          | 11 +++++++++++
 xen/common/version.c         |  4 ++++
 xen/include/public/version.h |  5 +++++
 xen/include/xsm/dummy.h      |  1 +
 5 files changed, 29 insertions(+)
xen/common/Kconfig +8 -0
index a6914fcae9..4a1a9398cd 100644
@@ -228,6 +228,14 @@ choice
 		bool "SILO" if XSM_SILO
 endchoice
 
+config XSM_DENIED_STRING
+	string "xen_version hypercall denied information replacement string"
+	default "<denied>"
+	depends on XSM
+	---help---
+	  A string which substitutes sensitive information returned via
+	  xen_version hypercall to non-privileged guests
+
 config LATE_HWDOM
 	bool "Dedicated hardware domain"
 	default n
xen/common/kernel.c +11 -0
index 22941cec94..1c22e5d167 100644
@@ -561,6 +561,17 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 
         return sz;
     }
+
+    case XENVER_denied_string:
+    {
+        xen_denied_string_t str;
+
+        safe_strcpy(str, xen_deny());
+        if ( copy_to_guest(arg, str, XEN_DENIED_STRING_LEN) )
+            return -EFAULT;
+
+        return 0;
+    }
     }
 
     return -ENOSYS;
xen/common/version.c +4 -0
index 937eb1281c..fbd0ef4668 100644
@@ -67,7 +67,11 @@ const char *xen_banner(void)
 
 const char *xen_deny(void)
 {
+#ifdef CONFIG_XSM_DENIED_STRING
+    return CONFIG_XSM_DENIED_STRING;
+#else
     return "<denied>";
+#endif
 }
 
 static const void *build_id_p __read_mostly;
xen/include/public/version.h +5 -0
index 17a81e23cd..f65001d2d9 100644
@@ -100,6 +100,11 @@ struct xen_build_id {
 };
 typedef struct xen_build_id xen_build_id_t;
 
+/* arg == xen_denied_string_t. */
+#define XENVER_denied_string 11
+typedef char xen_denied_string_t[64];
+#define XEN_DENIED_STRING_LEN (sizeof(xen_denied_string_t))
+
 #endif /* __XEN_PUBLIC_VERSION_H__ */
 
 /*
xen/include/xsm/dummy.h +1 -0
index b8e185e6fa..72a101b106 100644
@@ -748,6 +748,7 @@ static XSM_INLINE int xsm_xen_version (XSM_DEFAULT_ARG uint32_t op)
     case XENVER_version:
     case XENVER_platform_parameters:
     case XENVER_get_features:
+    case XENVER_denied_string:
         /* These sub-ops ignore the permission checks and return data. */
         return 0;
     case XENVER_extraversion:
Signature · 7 lines
2.17.1


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

Re: [Xen-devel] [PATCH v4 1/2] xsm: add Kconfig option for denied string

Quoted 7 lines · Sergey Dyasli

Add Kconfig option to make it possible to configure the string returned to non-privileged guests instead of the default "<denied>" which could propagate to UI / logs after the subsequent patch that hides detailed Xen version information from unprivileged guests.

Introduce XENVER_denied_string to allow guests to set up UI / logs filtering which dependens on the new CONFIG_XSM_DENIED_STRING.

No.  This is even worse than other suggestions.

It is entirely unacceptable to expect guests to have to modify them to figure out when they're being lied to.

And it is now possible *without source code modifications* to create a Xen which reports one string in this hypercall, and has empty strings elsewhere, which is even more chaotic for guests.

~Andrew

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

#3 lore raw

Re: [Xen-devel] [PATCH v4 1/2] xsm: add Kconfig option for denied string

Quoted 6 lines · Andrew Cooper
Quoted 5 lines · Sergey Dyasli

Add Kconfig option to make it possible to configure the string returned to non-privileged guests instead of the default "<denied>" which could propagate to UI / logs after the subsequent patch that hides detailed Xen version information from unprivileged guests.

Quoted 7 lines
Quoted 2 lines

Introduce XENVER_denied_string to allow guests to set up UI / logs filtering which dependens on the new CONFIG_XSM_DENIED_STRING.

No.  This is even worse than other suggestions.

It is entirely unacceptable to expect guests to have to modify them to figure out when they're being lied to.

Why "lied to"? Denying data access is different from lying imo. Plus your proposal to return empty strings then is even more of a lie, for being not even recognizable a "access denied".

Quoted 3 lines

And it is now possible *without source code modifications* to create a Xen which reports one string in this hypercall, and has empty strings elsewhere, which is even more chaotic for guests.

Empty strings elsewhere? Do you mean because of access having been denied, or because they in fact are empty? In the former case I'd like to ask for at least one example, while in the latter case I don't see what wrong you see.

Jan

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

#4 lore raw

Re: [Xen-devel] [PATCH v4 1/2] xsm: add Kconfig option for denied string

In reply to Sergey Dyasli

xen/common/Kconfig choice · line 234

Quoted 10 lines · Sergey Dyasli
xen/common/Kconfig +4 -0
@@ -228,6 +228,14 @@ choice
 		bool "SILO" if XSM_SILO
 endchoice
 
+config XSM_DENIED_STRING
+	string "xen_version hypercall denied information replacement string"
+	default "<denied>"
+	depends on XSM

Why would this string want to be configurable only in XSM- enabled builds?

Jan

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

#5 lore raw

Re: [Xen-devel] [PATCH v4 1/2] xsm: add Kconfig option for denied string

Quoted 7 lines · Jan Beulich
Quoted 6 lines · Sergey Dyasli
xen/common/Kconfig +0 -0
@@ -228,6 +228,14 @@ choice
 		bool "SILO" if XSM_SILO
 endchoice
 
Quoted 7 lines

xen/common/Kconfig choice · line 234

Quoted 4 lines
xen/common/Kconfig +4 -0
+config XSM_DENIED_STRING
+	string "xen_version hypercall denied information replacement string"
+	default "<denied>"
+	depends on XSM

Why would this string want to be configurable only in XSM- enabled builds?

For some reason I assumed that xsm_xen_version() is a no-op when CONFIG_XSM is undefined. I can now see that it doesn't depend on any config in which case the dependency (and #ifdef) should indeed be removed.

--
Thanks,
Sergey

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

#6 lore raw

PATCH v4 2/2 xsm: hide detailed Xen version from unprivileged guests

In reply to Sergey Dyasli

Hide the following information that can help identify the running Xen binary version: XENVER_[extraversion|compile_info|changeset] This makes harder for malicious guests to fingerprint Xen to identify exploitable systems.

Introduce xsm_filter_denied() to hvmloader to remove "<denied>" string from guest's DMI tables that otherwise would be shown in tools like dmidecode.

While at it, add explicit cases for XENVER_[commandline|build_id] for better code readability. Add a default case with an ASSERT to make sure that every case is explicitly listed as well.

---
v3 --> v4:
- Updated commit message
- Re-add hvmloader filtering

v2 --> v3:
- Remove hvmloader filtering
- Add ASSERT_UNREACHABLE

v1 --> v2:
- Added xsm_filter_denied() to hvmloader instead of modifying xen_deny()
- Made behaviour the same for both Release and Debug builds
- XENVER_capabilities is no longer hided

---
 tools/firmware/hvmloader/hvmloader.c |  1 +
 tools/firmware/hvmloader/smbios.c    |  1 +
 tools/firmware/hvmloader/util.c      | 11 +++++++++++
 tools/firmware/hvmloader/util.h      |  2 ++
 xen/include/xsm/dummy.h              | 15 +++++++++++----
 5 files changed, 26 insertions(+), 4 deletions(-)
tools/firmware/hvmloader/hvmloader.c +1 -0
index 598a226278..b35899f2fb 100644
@@ -147,6 +147,7 @@ static void init_hypercalls(void)
     /* Print version information. */
     cpuid(base + 1, &eax, &ebx, &ecx, &edx);
     hypercall_xen_version(XENVER_extraversion, extraversion);
+    xsm_filter_denied(extraversion);
     printf("Detected Xen v%u.%u%s\n", eax >> 16, eax & 0xffff, extraversion);
 }
 
tools/firmware/hvmloader/smbios.c +1 -0
index 97a054e9e3..a71bfe8392 100644
@@ -275,6 +275,7 @@ hvm_write_smbios_tables(
     xen_minor_version = (uint16_t) xen_version;
 
     hypercall_xen_version(XENVER_extraversion, xen_extra_version);
+    xsm_filter_denied(xen_extra_version);
 
     /* build up human-readable Xen version string */
     p = xen_version_str;
tools/firmware/hvmloader/util.c +11 -0
index 0c3f2d24cd..49b4b321e3 100644
@@ -28,6 +28,7 @@
 #include <xen/xen.h>
 #include <xen/memory.h>
 #include <xen/sched.h>
+#include <xen/version.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/params.h>
 
@@ -995,6 +996,16 @@ void hvmloader_acpi_build_tables(struct acpi_config *config,
     hvm_param_set(HVM_PARAM_VM_GENERATION_ID_ADDR, config->vm_gid_addr);
 }
 
+void xsm_filter_denied(char *str)
+{
+    xen_denied_string_t deny_str = "";
+
+    hypercall_xen_version(XENVER_denied_string, deny_str);
+
+    if ( strcmp(str, deny_str) == 0 )
+        *str = '\0';
+}
+
 /*
  * Local variables:
  * mode: C
tools/firmware/hvmloader/util.h +2 -0
index 7bca6418d2..e4fd26de9d 100644
@@ -286,6 +286,8 @@ struct acpi_config;
 void hvmloader_acpi_build_tables(struct acpi_config *config,
                                  unsigned int physical);
 
+void xsm_filter_denied(char *str);
+
 #endif /* __HVMLOADER_UTIL_H__ */
 
 /*
xen/include/xsm/dummy.h +11 -4
index 72a101b106..2567ccaa0a 100644
@@ -751,16 +751,23 @@ static XSM_INLINE int xsm_xen_version (XSM_DEFAULT_ARG uint32_t op)
     case XENVER_denied_string:
         /* These sub-ops ignore the permission checks and return data. */
         return 0;
-    case XENVER_extraversion:
-    case XENVER_compile_info:
+
     case XENVER_capabilities:
-    case XENVER_changeset:
     case XENVER_pagesize:
     case XENVER_guest_handle:
         /* These MUST always be accessible to any guest by default. */
         return xsm_default_action(XSM_HOOK, current->domain, NULL);
-    default:
+
+    case XENVER_extraversion:
+    case XENVER_compile_info:
+    case XENVER_changeset:
+    case XENVER_commandline:
+    case XENVER_build_id:
         return xsm_default_action(XSM_PRIV, current->domain, NULL);
+
+    default:
+        ASSERT_UNREACHABLE();
+        return -EPERM;
     }
 }
 
Signature · 7 lines
2.17.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#7 lore raw
In reply to Sergey Dyasli
Quoted 5 lines · Sergey Dyasli

Now a proper 2 patches series.

Sergey Dyasli (2):
xsm: add Kconfig option for denied string
xsm: hide detailed Xen version from unprivileged guests

As we don't look to be coming to an agreement how to deal with the situation, I'm going to drop this from my pending patches folder.

Jan