* [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes
@ 2019-02-18 18:13 P J P
2019-02-18 18:29 ` Daniel P. Berrangé
2019-02-19 2:55 ` David Gibson
0 siblings, 2 replies; 6+ messages in thread
From: P J P @ 2019-02-18 18:13 UTC (permalink / raw)
To: QEMU Developers
Cc: David Gibson, qemu-ppc, Daniel P . Berrange, Greg Kurz, Prasad J Pandit
From: Prasad J Pandit <pjp@fedoraproject.org>
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@redhat.com>
Fix-suggested-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
hw/ppc/spapr.c | 76 ++++++++++++++++++++++++++++++++++++++----
include/hw/ppc/spapr.h | 2 ++
2 files changed, 72 insertions(+), 6 deletions(-)
Update v4: remove NULL initializations in spapr_instance_init()
-> https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg04554.html
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0942f35bf8..8786c4c4ca 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1249,13 +1249,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);
@@ -3138,6 +3155,36 @@ static void spapr_set_ic_mode(Object *obj, const char *value, Error **errp)
}
}
+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);
@@ -3183,6 +3230,17 @@ static void spapr_instance_init(Object *obj)
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)
@@ -4080,9 +4138,15 @@ DEFINE_SPAPR_MACHINE(4_0, "4.0", true);
static void spapr_machine_3_1_class_options(MachineClass *mc)
{
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;
}
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index a947a0a0dc..e004a570d8 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -177,6 +177,8 @@ struct sPAPRMachineState {
/*< public >*/
char *kvm_type;
+ char *host_model;
+ char *host_serial;
const char *icp_type;
int32_t irq_map_nr;
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes
2019-02-18 18:13 [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes P J P
@ 2019-02-18 18:29 ` Daniel P. Berrangé
2019-02-19 2:55 ` David Gibson
1 sibling, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2019-02-18 18:29 UTC (permalink / raw)
To: P J P; +Cc: QEMU Developers, David Gibson, qemu-ppc, Greg Kurz, Prasad J Pandit
On Mon, Feb 18, 2019 at 11:43:49PM +0530, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> 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@redhat.com>
> Fix-suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
> hw/ppc/spapr.c | 76 ++++++++++++++++++++++++++++++++++++++----
> include/hw/ppc/spapr.h | 2 ++
> 2 files changed, 72 insertions(+), 6 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes
2019-02-18 18:13 [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes P J P
2019-02-18 18:29 ` Daniel P. Berrangé
@ 2019-02-19 2:55 ` David Gibson
2019-02-21 9:25 ` Daniel P. Berrangé
1 sibling, 1 reply; 6+ messages in thread
From: David Gibson @ 2019-02-19 2:55 UTC (permalink / raw)
To: P J P
Cc: QEMU Developers, qemu-ppc, Daniel P . Berrange, Greg Kurz,
Prasad J Pandit
[-- Attachment #1: Type: text/plain, Size: 6008 bytes --]
On Mon, Feb 18, 2019 at 11:43:49PM +0530, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> 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@redhat.com>
> Fix-suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Applied to ppc-for-4.0, thanks.
> ---
> hw/ppc/spapr.c | 76 ++++++++++++++++++++++++++++++++++++++----
> include/hw/ppc/spapr.h | 2 ++
> 2 files changed, 72 insertions(+), 6 deletions(-)
>
> Update v4: remove NULL initializations in spapr_instance_init()
> -> https://lists.gnu.org/archive/html/qemu-devel/2019-02/msg04554.html
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 0942f35bf8..8786c4c4ca 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -1249,13 +1249,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);
> @@ -3138,6 +3155,36 @@ static void spapr_set_ic_mode(Object *obj, const char *value, Error **errp)
> }
> }
>
> +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);
> @@ -3183,6 +3230,17 @@ static void spapr_instance_init(Object *obj)
> 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)
> @@ -4080,9 +4138,15 @@ DEFINE_SPAPR_MACHINE(4_0, "4.0", true);
> static void spapr_machine_3_1_class_options(MachineClass *mc)
> {
> 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;
> }
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index a947a0a0dc..e004a570d8 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -177,6 +177,8 @@ struct sPAPRMachineState {
>
> /*< public >*/
> char *kvm_type;
> + char *host_model;
> + char *host_serial;
>
> const char *icp_type;
> int32_t irq_map_nr;
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes
2019-02-19 2:55 ` David Gibson
@ 2019-02-21 9:25 ` Daniel P. Berrangé
2019-02-21 10:02 ` Greg Kurz
2019-02-21 22:30 ` David Gibson
0 siblings, 2 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2019-02-21 9:25 UTC (permalink / raw)
To: David Gibson; +Cc: P J P, QEMU Developers, qemu-ppc, Greg Kurz, Prasad J Pandit
On Tue, Feb 19, 2019 at 01:55:01PM +1100, David Gibson wrote:
> On Mon, Feb 18, 2019 at 11:43:49PM +0530, P J P wrote:
> > From: Prasad J Pandit <pjp@fedoraproject.org>
> >
> > 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@redhat.com>
> > Fix-suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> > Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
>
> Applied to ppc-for-4.0, thanks.
Could you add the word "CVE-2019-8934" to the commit message for this
patch before sending a pulll request - either end of subject line, or
just before the Reported-by line.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes
2019-02-21 9:25 ` Daniel P. Berrangé
@ 2019-02-21 10:02 ` Greg Kurz
2019-02-21 22:30 ` David Gibson
1 sibling, 0 replies; 6+ messages in thread
From: Greg Kurz @ 2019-02-21 10:02 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: David Gibson, P J P, QEMU Developers, qemu-ppc, Prasad J Pandit
On Thu, 21 Feb 2019 09:25:46 +0000
Daniel P. Berrangé <berrange@redhat.com> wrote:
> On Tue, Feb 19, 2019 at 01:55:01PM +1100, David Gibson wrote:
> > On Mon, Feb 18, 2019 at 11:43:49PM +0530, P J P wrote:
> > > From: Prasad J Pandit <pjp@fedoraproject.org>
> > >
> > > 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@redhat.com>
> > > Fix-suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> > > Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> >
> > Applied to ppc-for-4.0, thanks.
>
> Could you add the word "CVE-2019-8934" to the commit message for this
> patch before sending a pulll request - either end of subject line, or
> just before the Reported-by line.
>
While here, please add my R-b tag as well:
Reviewed-by: Greg Kurz <groug@kaod.org>
> Regards,
> Daniel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes
2019-02-21 9:25 ` Daniel P. Berrangé
2019-02-21 10:02 ` Greg Kurz
@ 2019-02-21 22:30 ` David Gibson
1 sibling, 0 replies; 6+ messages in thread
From: David Gibson @ 2019-02-21 22:30 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: P J P, QEMU Developers, qemu-ppc, Greg Kurz, Prasad J Pandit
[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]
On Thu, Feb 21, 2019 at 09:25:46AM +0000, Daniel P. Berrangé wrote:
> On Tue, Feb 19, 2019 at 01:55:01PM +1100, David Gibson wrote:
> > On Mon, Feb 18, 2019 at 11:43:49PM +0530, P J P wrote:
> > > From: Prasad J Pandit <pjp@fedoraproject.org>
> > >
> > > 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@redhat.com>
> > > Fix-suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> > > Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> >
> > Applied to ppc-for-4.0, thanks.
>
> Could you add the word "CVE-2019-8934" to the commit message for this
> patch before sending a pulll request - either end of subject line, or
> just before the Reported-by line.
Done, thanks.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-02-21 22:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-18 18:13 [Qemu-devel] [PATCH v4] ppc: add host-serial and host-model machine attributes P J P
2019-02-18 18:29 ` Daniel P. Berrangé
2019-02-19 2:55 ` David Gibson
2019-02-21 9:25 ` Daniel P. Berrangé
2019-02-21 10:02 ` Greg Kurz
2019-02-21 22:30 ` David Gibson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.