From patchwork Tue Feb 11 13:42:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 11375519 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A2F3392A for ; Tue, 11 Feb 2020 13:43:26 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7FB0E20714 for ; Tue, 11 Feb 2020 13:43:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="SrA/gFMW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7FB0E20714 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1Vo8-0005op-K6; Tue, 11 Feb 2020 13:42:32 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1Vo7-0005oj-Dl for xen-devel@lists.xen.org; Tue, 11 Feb 2020 13:42:31 +0000 X-Inumbo-ID: 58b77afe-4cd4-11ea-8d48-bc764e2007e4 Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 58b77afe-4cd4-11ea-8d48-bc764e2007e4; Tue, 11 Feb 2020 13:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1581428549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=LzZdjxeovOAjuW2fRy9P0iCKqWm7ctYmXUJ6+k/RVNM=; b=SrA/gFMWsTkItFue9v8ApPF5n1iu/UqyTqLQBx8ILCuFkHFkJQrdMzdu OM1ehnrAhRnq2dz4a4Ei9BDZm+W5RoJ+X784EOcAn2TC7X7cKGHG3Qr8+ MCZTMohMtd6goXLb27B7jpTWBUIc/A9TOySh/54h9kfSfTrmlbE40iHEh E=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=sergey.dyasli@citrix.com; spf=Pass smtp.mailfrom=sergey.dyasli@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of sergey.dyasli@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of sergey.dyasli@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: bNxA+R7gyur1Sj2L3TtRRoObJ5CYr0WG215h7iTjx3fQ3bIV2wfJe3sIEq0l0g/Mqaycgdj2O7 Lr6SKHdNv5LGUGeHNeh5LYonnQUDAZP6n54mGHxK7rHi9pJg0xjRXbQoCifh7vM5VoQ19k5gsX oTpElFjoSQOF3GcUlZBJaXMd/Jx03iM+jARSFJfSx6Kzu7s4I8x1ZLrPdsU2SwSyxCUrY2n3Ql CRKjT4XkAV/v65dFSDXf1mUsYFzvJcV6vdAXc9sy9Juz9bGPsJY7IjJ+9LvWSn/G8JSN8IhF8Z 4MU= X-SBRS: 2.7 X-MesageID: 12638711 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,428,1574139600"; d="scan'208";a="12638711" From: Sergey Dyasli To: Date: Tue, 11 Feb 2020 13:42:20 +0000 Message-ID: <20200211134220.9194-3-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211134220.9194-1-sergey.dyasli@citrix.com> References: <20200211134220.9194-1-sergey.dyasli@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 2/2] xsm: hide detailed Xen version from unprivileged guests X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Sergey Dyasli , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , Daniel De Graaf , Doug Goldstein Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 "" 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. Signed-off-by: Sergey Dyasli --- 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(-) diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 598a226278..b35899f2fb 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -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); } diff --git a/tools/firmware/hvmloader/smbios.c b/tools/firmware/hvmloader/smbios.c index 97a054e9e3..a71bfe8392 100644 --- a/tools/firmware/hvmloader/smbios.c +++ b/tools/firmware/hvmloader/smbios.c @@ -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; diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index 0c3f2d24cd..49b4b321e3 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -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 diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 7bca6418d2..e4fd26de9d 100644 --- a/tools/firmware/hvmloader/util.h +++ b/tools/firmware/hvmloader/util.h @@ -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__ */ /* diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index 72a101b106..2567ccaa0a 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -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; } }