From patchwork Fri Jan 10 10:37:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 11327153 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 5F49F6C1 for ; Fri, 10 Jan 2020 10:38:37 +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 3B86A2072E for ; Fri, 10 Jan 2020 10:38:37 +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="OzPvw5sk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B86A2072E 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 1iprfe-0003y7-O7; Fri, 10 Jan 2020 10:37:38 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iprfd-0003y1-Co for xen-devel@lists.xen.org; Fri, 10 Jan 2020 10:37:37 +0000 X-Inumbo-ID: 32638d14-3395-11ea-ac27-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 32638d14-3395-11ea-ac27-bc764e2007e4; Fri, 10 Jan 2020 10:37:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1578652648; h=from:to:cc:subject:date:message-id:mime-version; bh=QR1yi6CJli1sWvx0XJRETp0lksT04VhUlAGTKTMy684=; b=OzPvw5skVcyTDXuuL0KYkAjLmSUBtg0SUHm0X7p33R7lDHRZN5nKUsQh eVCR26YLsGENBLWICpePcawSdP4JoQOXDqOd0N7EFyQItT9YaKj8sNrgj P5v69RawTA/8oEuF6jJ9Qibm+rcjMHENJm2/2ETkVD2ecmpG8Yiib+dcW 8=; Authentication-Results: esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="sergey.dyasli@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.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=esa6.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 (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="sergey.dyasli@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: R71nNg6DPzmLCjU+V2HhAZ7uapYbpJEJWTRDCwGG1WTUXVcQXde3RHGQHY4UQjS7h6wCrncoUH TcsZKij+NBF1glm4l/+Ffr/5WbebT0hAsRc0rt7Pcw4sXL1ofdNbBE9lMsLlz7LmQ/q9I9iU+P QHtfkKHXHWCxbnbaKEe3ZXDopJFYyPqvKH6yv03D/hJ4qkjJEt0WJLruz35pbS66RlLkbugJRW PG4yoSOACSbuosCxTcNIHhqu4ZRyuZm32e7S047Cfp1QJihldYzpqh+DG6Bxr/UAs+Q+CaOTGj x9s= X-SBRS: 2.7 X-MesageID: 11165651 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,416,1571716800"; d="scan'208";a="11165651" From: Sergey Dyasli To: Date: Fri, 10 Jan 2020 10:37:23 +0000 Message-ID: <20200110103723.29538-1-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2] 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 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, XENVER_compile_info, XENVER_changeset. Add explicit cases for XENVER_commandline and XENVER_build_id as well. Introduce xsm_filter_denied() to hvmloader to remove "" string from guest's DMI tables that otherwise would be shown in tools like dmidecode. Signed-off-by: Sergey Dyasli --- 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 CC: Andrew Cooper CC: George Dunlap CC: Ian Jackson CC: Jan Beulich CC: Julien Grall CC: Konrad Rzeszutek Wilk CC: Stefano Stabellini CC: Wei Liu CC: Daniel De Graaf --- tools/firmware/hvmloader/hvmloader.c | 1 + tools/firmware/hvmloader/smbios.c | 1 + tools/firmware/hvmloader/util.c | 6 ++++++ tools/firmware/hvmloader/util.h | 2 ++ xen/include/xsm/dummy.h | 9 ++++++--- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index 598a226278..e760ed5fa6 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, sizeof(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..1ba352ed2c 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, sizeof(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..09e355fa3d 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -995,6 +995,12 @@ 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, size_t len) +{ + if ( strcmp(str, "") == 0 ) + memset(str, 0, len); +} + /* * Local variables: * mode: C diff --git a/tools/firmware/hvmloader/util.h b/tools/firmware/hvmloader/util.h index 7bca6418d2..f7d907ca00 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, size_t len); + #endif /* __HVMLOADER_UTIL_H__ */ /* diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index b8e185e6fa..d15b078f10 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -750,14 +750,17 @@ static XSM_INLINE int xsm_xen_version (XSM_DEFAULT_ARG uint32_t op) case XENVER_get_features: /* 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); + + case XENVER_extraversion: + case XENVER_compile_info: + case XENVER_changeset: + case XENVER_commandline: + case XENVER_build_id: default: return xsm_default_action(XSM_PRIV, current->domain, NULL); }