From nobody Sun Nov 9 16:22:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551157306726398.2932729727919; Mon, 25 Feb 2019 21:01:46 -0800 (PST) Received: from localhost ([127.0.0.1]:48869 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyUs2-0002MQ-Rh for importer@patchew.org; Tue, 26 Feb 2019 00:01:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyUkd-0004og-SX for qemu-devel@nongnu.org; Mon, 25 Feb 2019 23:53:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyUka-0001v9-68 for qemu-devel@nongnu.org; Mon, 25 Feb 2019 23:53:54 -0500 Received: from ozlabs.org ([203.11.71.1]:58599) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gyUkQ-0000g7-Nu; Mon, 25 Feb 2019 23:53:46 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 447mfH26WTz9sMM; Tue, 26 Feb 2019 15:53:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1551156791; bh=2UQGw6CAl6c6P95w830BuG63HjN//T7TrKL2ovbPPmo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ALPw+K1o1iYTcj9kojPViD9rhEzXZkw8xmx5KBKkAQ0kzufzWAP4hWjq/GOKPpC9m mRGuydJsb/Um2SdgmzHTW7zJ9py+SUrZ2Y33GzBImhiY8ixY53kO4yCc1HmteK5uYt mfx4k04kdgwd6WABaeqR0OGo6fjNzzv6E6tnRmbA= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 26 Feb 2019 15:52:25 +1100 Message-Id: <20190226045304.25618-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226045304.25618-1-david@gibson.dropbear.id.au> References: <20190226045304.25618-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 11/50] ppc: add host-serial and host-model machine attributes (CVE-2019-8934) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Prasad J Pandit , gkurz@kaod.org, qemu-devel@nongnu.org, Greg Kurz , qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit On ppc hosts, hypervisor shares following system attributes - /proc/device-tree/system-id - /proc/device-tree/model with a guest. This could lead to information leakage and misuse.[*] Add machine attributes to control such system information exposure to a guest. [*] https://wiki.openstack.org/wiki/OSSN/OSSN-0028 Reported-by: Daniel P. Berrang=C3=A9 Fix-suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Prasad J Pandit Message-Id: <20190218181349.23885-1-ppandit@redhat.com> Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/spapr.c | 76 ++++++++++++++++++++++++++++++++++++++---- include/hw/ppc/spapr.h | 2 ++ 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index abf9ebce59..b3631e22c4 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1247,13 +1247,30 @@ static void *spapr_build_fdt(sPAPRMachineState *spa= pr) * Add info to guest to indentify which host is it being run on * and what is the uuid of the guest */ - if (kvmppc_get_host_model(&buf)) { - _FDT(fdt_setprop_string(fdt, 0, "host-model", buf)); - g_free(buf); + if (spapr->host_model && !g_str_equal(spapr->host_model, "none")) { + if (g_str_equal(spapr->host_model, "passthrough")) { + /* -M host-model=3Dpassthrough */ + if (kvmppc_get_host_model(&buf)) { + _FDT(fdt_setprop_string(fdt, 0, "host-model", buf)); + g_free(buf); + } + } else { + /* -M host-model=3D */ + _FDT(fdt_setprop_string(fdt, 0, "host-model", spapr->host_mode= l)); + } } - if (kvmppc_get_host_serial(&buf)) { - _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf)); - g_free(buf); + + if (spapr->host_serial && !g_str_equal(spapr->host_serial, "none")) { + if (g_str_equal(spapr->host_serial, "passthrough")) { + /* -M host-serial=3Dpassthrough */ + if (kvmppc_get_host_serial(&buf)) { + _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf)); + g_free(buf); + } + } else { + /* -M host-serial=3D */ + _FDT(fdt_setprop_string(fdt, 0, "host-serial", spapr->host_ser= ial)); + } } =20 buf =3D qemu_uuid_unparse_strdup(&qemu_uuid); @@ -3144,6 +3161,36 @@ static void spapr_set_ic_mode(Object *obj, const cha= r *value, Error **errp) } } =20 +static char *spapr_get_host_model(Object *obj, Error **errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); + + return g_strdup(spapr->host_model); +} + +static void spapr_set_host_model(Object *obj, const char *value, Error **e= rrp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); + + g_free(spapr->host_model); + spapr->host_model =3D g_strdup(value); +} + +static char *spapr_get_host_serial(Object *obj, Error **errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); + + return g_strdup(spapr->host_serial); +} + +static void spapr_set_host_serial(Object *obj, const char *value, Error **= errp) +{ + sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); + + g_free(spapr->host_serial); + spapr->host_serial =3D g_strdup(value); +} + static void spapr_instance_init(Object *obj) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(obj); @@ -3189,6 +3236,17 @@ static void spapr_instance_init(Object *obj) object_property_set_description(obj, "ic-mode", "Specifies the interrupt controller mode (xics, xive, dua= l)", NULL); + + object_property_add_str(obj, "host-model", + spapr_get_host_model, spapr_set_host_model, + &error_abort); + object_property_set_description(obj, "host-model", + "Set host's model-id to use - none|passthrough|string", &error_abo= rt); + object_property_add_str(obj, "host-serial", + spapr_get_host_serial, spapr_set_host_serial, + &error_abort); + object_property_set_description(obj, "host-serial", + "Set host's system-id to use - none|passthrough|string", &error_ab= ort); } =20 static void spapr_machine_finalizefn(Object *obj) @@ -4086,9 +4144,15 @@ DEFINE_SPAPR_MACHINE(4_0, "4.0", true); static void spapr_machine_3_1_class_options(MachineClass *mc) { sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); + static GlobalProperty compat[] =3D { + { TYPE_SPAPR_MACHINE, "host-model", "passthrough" }, + { TYPE_SPAPR_MACHINE, "host-serial", "passthrough" }, + }; =20 spapr_machine_4_0_class_options(mc); compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len); + compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat)); + mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("power8_v2.0"); smc->update_dt_enabled =3D false; } diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 631fc5103b..fec0f26f49 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -177,6 +177,8 @@ struct sPAPRMachineState { =20 /*< public >*/ char *kvm_type; + char *host_model; + char *host_serial; =20 int32_t irq_map_nr; unsigned long *irq_map; --=20 2.20.1