[OE-core] [warrior][PATCH] qemu: Fix CVE-2019-8934

akuster808 akuster808 at gmail.com
Sat Oct 5 21:19:59 UTC 2019



On 9/25/19 10:05 AM, msft.dantran at gmail.com wrote:
> From: Dan Tran <dantran at microsoft.com>
>
> Signed-off-by: Dan Tran <dantran at microsoft.com>
> ---
>  meta/recipes-devtools/qemu/qemu.inc           |   3 +-
>  .../qemu/qemu/CVE-2019-8934.patch             | 215 ++++++++++++++++++
>  2 files changed, 217 insertions(+), 1 deletion(-)
>  create mode 100644 meta/recipes-devtools/qemu/qemu/CVE-2019-8934.patch
>
> diff --git a/meta/recipes-devtools/qemu/qemu.inc b/meta/recipes-devtools/qemu/qemu.inc
> index e503aa866d..1f8c1b3135 100644
> --- a/meta/recipes-devtools/qemu/qemu.inc
> +++ b/meta/recipes-devtools/qemu/qemu.inc
> @@ -30,7 +30,8 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
>             file://0018-fix-CVE-2018-20191.patch \
>             file://0019-fix-CVE-2018-20216.patch \
>             file://CVE-2019-3812.patch \
> -           "
> +	   file://CVE-2019-8934.patch \

This is causing build errors in YP AB. Maybe its related to this patch
not being against what got merged to mainline warrior.

see https://errors.yoctoproject.org/Errors/Details/272786/

- armin
> +	   "
>  UPSTREAM_CHECK_REGEX = "qemu-(?P<pver>\d+(\.\d+)+)\.tar"
>  
>  SRC_URI[md5sum] = "fb687ce0b02d3bf4327e36d3b99427a8"
> diff --git a/meta/recipes-devtools/qemu/qemu/CVE-2019-8934.patch b/meta/recipes-devtools/qemu/qemu/CVE-2019-8934.patch
> new file mode 100644
> index 0000000000..d1d7d23968
> --- /dev/null
> +++ b/meta/recipes-devtools/qemu/qemu/CVE-2019-8934.patch
> @@ -0,0 +1,215 @@
> +From 8c2e30a92d95d89e2cf45d229bce274881026cf7 Mon Sep 17 00:00:00 2001
> +From: Prasad J Pandit <pjp at fedoraproject.org>
> +Date: Mon, 18 Feb 2019 23:43:49 +0530
> +Subject: [PATCH] ppc: add host-serial and host-model machine attributes
> + (CVE-2019-8934)
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +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é <berrange at redhat.com>
> +Fix-suggested-by: Daniel P. Berrangé <berrange at redhat.com>
> +Signed-off-by: Prasad J Pandit <pjp at fedoraproject.org>
> +Message-Id: <20190218181349.23885-1-ppandit at redhat.com>
> +Reviewed-by: Daniel P. Berrangé <berrange at redhat.com>
> +Reviewed-by: Greg Kurz <groug at kaod.org>
> +Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
> +
> +CVE: CVE-2019-8934
> +Upstream-Status: Backport
> +[https://github.com/qemu/qemu/commit/27461d69a0f108dea756419251acc3ea65198f1b]
> +
> +Signed-off-by: Dan Tran <dantran at microsoft.com>
> +---
> + hw/ppc/spapr.c         | 128 ++++++++++++++++++++++++++++++++++++++---
> + include/hw/ppc/spapr.h |   2 +
> + 2 files changed, 123 insertions(+), 7 deletions(-)
> +
> +diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> +index 7afd1a175b..bcee7c162d 100644
> +--- a/hw/ppc/spapr.c
> ++++ b/hw/ppc/spapr.c
> +@@ -1244,13 +1244,30 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,
> +      * 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=passthrough */
> ++            if (kvmppc_get_host_model(&buf)) {
> ++                _FDT(fdt_setprop_string(fdt, 0, "host-model", buf));
> ++                g_free(buf);
> ++            }
> ++        } else {
> ++            /* -M host-model=<user-string> */
> ++            _FDT(fdt_setprop_string(fdt, 0, "host-model", spapr->host_model));
> ++        }
> +     }
> +-    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=passthrough */
> ++            if (kvmppc_get_host_serial(&buf)) {
> ++                _FDT(fdt_setprop_string(fdt, 0, "host-serial", buf));
> ++                g_free(buf);
> ++            }
> ++        } else {
> ++            /* -M host-serial=<user-string> */
> ++            _FDT(fdt_setprop_string(fdt, 0, "host-serial", spapr->host_serial));
> ++        }
> +     }
> + 
> +     buf = qemu_uuid_unparse_strdup(&qemu_uuid);
> +@@ -3031,6 +3048,73 @@ static void spapr_set_vsmt(Object *obj, Visitor *v, const char *name,
> +     visit_type_uint32(v, name, (uint32_t *)opaque, errp);
> + }
> + 
> ++static char *spapr_get_ic_mode(Object *obj, Error **errp)
> ++{
> ++    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> ++
> ++    if (spapr->irq == &spapr_irq_xics_legacy) {
> ++        return g_strdup("legacy");
> ++    } else if (spapr->irq == &spapr_irq_xics) {
> ++        return g_strdup("xics");
> ++    } else if (spapr->irq == &spapr_irq_xive) {
> ++        return g_strdup("xive");
> ++    } else if (spapr->irq == &spapr_irq_dual) {
> ++        return g_strdup("dual");
> ++    }
> ++    g_assert_not_reached();
> ++}
> ++
> ++static void spapr_set_ic_mode(Object *obj, const char *value, Error **errp)
> ++{
> ++    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> ++
> ++    if (SPAPR_MACHINE_GET_CLASS(spapr)->legacy_irq_allocation) {
> ++        error_setg(errp, "This machine only uses the legacy XICS backend, don't pass ic-mode");
> ++        return;
> ++    }
> ++
> ++    /* The legacy IRQ backend can not be set */
> ++    if (strcmp(value, "xics") == 0) {
> ++        spapr->irq = &spapr_irq_xics;
> ++    } else if (strcmp(value, "xive") == 0) {
> ++        spapr->irq = &spapr_irq_xive;
> ++    } else if (strcmp(value, "dual") == 0) {
> ++        spapr->irq = &spapr_irq_dual;
> ++    } else {
> ++        error_setg(errp, "Bad value for \"ic-mode\" property");
> ++    }
> ++}
> ++
> ++static char *spapr_get_host_model(Object *obj, Error **errp)
> ++{
> ++    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> ++
> ++    return g_strdup(spapr->host_model);
> ++}
> ++
> ++static void spapr_set_host_model(Object *obj, const char *value, Error **errp)
> ++{
> ++    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> ++
> ++    g_free(spapr->host_model);
> ++    spapr->host_model = g_strdup(value);
> ++}
> ++
> ++static char *spapr_get_host_serial(Object *obj, Error **errp)
> ++{
> ++    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> ++
> ++    return g_strdup(spapr->host_serial);
> ++}
> ++
> ++static void spapr_set_host_serial(Object *obj, const char *value, Error **errp)
> ++{
> ++    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> ++
> ++    g_free(spapr->host_serial);
> ++    spapr->host_serial = g_strdup(value);
> ++}
> ++
> + static void spapr_instance_init(Object *obj)
> + {
> +     sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
> +@@ -3067,6 +3151,25 @@ static void spapr_instance_init(Object *obj)
> +                                     " the host's SMT mode", &error_abort);
> +     object_property_add_bool(obj, "vfio-no-msix-emulation",
> +                              spapr_get_msix_emulation, NULL, NULL);
> ++
> ++    /* The machine class defines the default interrupt controller mode */
> ++    spapr->irq = smc->irq;
> ++    object_property_add_str(obj, "ic-mode", spapr_get_ic_mode,
> ++                            spapr_set_ic_mode, NULL);
> ++    object_property_set_description(obj, "ic-mode",
> ++                 "Specifies the interrupt controller mode (xics, xive, dual)",
> ++                 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_abort);
> ++    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_abort);
> + }
> + 
> + static void spapr_machine_finalizefn(Object *obj)
> +@@ -3965,7 +4068,18 @@ static void spapr_machine_3_1_instance_options(MachineState *machine)
> + 
> + static void spapr_machine_3_1_class_options(MachineClass *mc)
> + {
> +-    /* Defaults for the latest behaviour inherited from the base class */
> ++    sPAPRMachineClass *smc = SPAPR_MACHINE_CLASS(mc);
> ++    static GlobalProperty compat[] = {
> ++        { TYPE_SPAPR_MACHINE, "host-model", "passthrough" },
> ++        { TYPE_SPAPR_MACHINE, "host-serial", "passthrough" },
> ++    };
> ++
> ++    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 = POWERPC_CPU_TYPE_NAME("power8_v2.0");
> ++    smc->update_dt_enabled = false;
> + }
> + 
> + DEFINE_SPAPR_MACHINE(3_1, "3.1", true);
> +diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> +index 6279711fe8..63692a13bd 100644
> +--- a/include/hw/ppc/spapr.h
> ++++ b/include/hw/ppc/spapr.h
> +@@ -171,6 +171,8 @@ struct sPAPRMachineState {
> + 
> +     /*< public >*/
> +     char *kvm_type;
> ++    char *host_model;
> ++    char *host_serial;
> + 
> +     const char *icp_type;
> +     int32_t irq_map_nr;
> +-- 
> +2.22.0.vfs.1.1.57.gbaf16c8
> +



More information about the Openembedded-core mailing list