From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Prasad J Pandit" <pjp@fedoraproject.org>,
qemu-block@nongnu.org, "Michael S. Tsirkin" <mst@redhat.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
qemu-devel@nongnu.org, xen-devel@lists.xenproject.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eric Blake" <eblake@redhat.com>,
"Eduardo Habkost" <ehabkost@redhat.com>
Subject: Re: [RFC PATCH 06/10] qdev: Use qemu_security_policy_taint() API
Date: Thu, 9 Sep 2021 12:03:48 +0100 [thread overview]
Message-ID: <YTnqFHnolMLeY9c8@redhat.com> (raw)
In-Reply-To: <20210908232024.2399215-7-philmd@redhat.com>
On Thu, Sep 09, 2021 at 01:20:20AM +0200, Philippe Mathieu-Daudé wrote:
> Add DeviceClass::taints_security_policy field to allow an
> unsafe device to eventually taint the global security policy
> in DeviceRealize().
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> include/hw/qdev-core.h | 6 ++++++
> hw/core/qdev.c | 11 +++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index bafc311bfa1..ff9ce6671be 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -122,6 +122,12 @@ struct DeviceClass {
> */
> bool user_creatable;
> bool hotpluggable;
> + /*
> + * %false if the device is within the QEMU security policy boundary,
> + * %true if there is no guarantee this device can be used safely.
> + * See: https://www.qemu.org/contribute/security-process/
> + */
> + bool taints_security_policy;
>
> /* callbacks */
> /*
Although your use case is for devices, it probably makes more sense
to push this up into the Object base class.
I think it will need to be a tri-state value too, not a simple
bool. It isn't feasible to mark all devices with this property,
so initially we'll have no information about whether most
devices are secure or insecure. This patch gives the implication
that all devices are secure, except for the few that have been
marked otherwise, which is not a good default IMHO.
We want to be able to make it clear when introspecting, that we
have no information on security available for most devices ie
- unset => no information on security (the current default)
- true => considered secure against malicious guest
- false => considered insecure against malicious guest
Then we can also extend 'ObjectTypeInfo' to have a
'*secure': 'bool'
to make 'qom-list-types' be able to introspect this upfront.
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index cefc5eaa0a9..a5a00f3564c 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -31,6 +31,7 @@
> #include "qapi/qmp/qerror.h"
> #include "qapi/visitor.h"
> #include "qemu/error-report.h"
> +#include "qemu-common.h"
> #include "qemu/option.h"
> #include "hw/hotplug.h"
> #include "hw/irq.h"
> @@ -257,6 +258,13 @@ bool qdev_hotplug_allowed(DeviceState *dev, Error **errp)
> MachineClass *mc;
> Object *m_obj = qdev_get_machine();
>
> + if (qemu_security_policy_is_strict()
> + && DEVICE_GET_CLASS(dev)->taints_security_policy) {
> + error_setg(errp, "Device '%s' can not be hotplugged when"
> + " 'strict' security policy is in place",
> + object_get_typename(OBJECT(dev)));
Do you need a 'return' here to stop execution after reportig
the error ?
> + }
> +
> if (object_dynamic_cast(m_obj, TYPE_MACHINE)) {
> machine = MACHINE(m_obj);
> mc = MACHINE_GET_CLASS(machine);
> @@ -385,6 +393,9 @@ bool qdev_realize(DeviceState *dev, BusState *bus, Error **errp)
> } else {
> assert(!DEVICE_GET_CLASS(dev)->bus_type);
> }
> + qemu_security_policy_taint(DEVICE_GET_CLASS(dev)->taints_security_policy,
> + "device type %s",
> + object_get_typename(OBJECT(dev)));
>
> return object_property_set_bool(OBJECT(dev), "realized", true, errp);
> }
> --
> 2.31.1
>
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 :|
next prev parent reply other threads:[~2021-09-09 11:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 23:20 [RFC PATCH 00/10] security: Introduce qemu_security_policy_taint() API Philippe Mathieu-Daudé
2021-09-08 23:20 ` [RFC PATCH 01/10] sysemu: " Philippe Mathieu-Daudé
2021-09-09 10:01 ` Paolo Bonzini
2021-09-09 18:45 ` Eric Blake
2021-09-08 23:20 ` [RFC PATCH 02/10] accel: Use qemu_security_policy_taint(), mark KVM and Xen as safe Philippe Mathieu-Daudé
2021-09-09 10:37 ` Daniel P. Berrangé
2021-10-21 14:47 ` Markus Armbruster
2021-09-09 18:46 ` Eric Blake
2021-09-08 23:20 ` [RFC PATCH 03/10] block: Use qemu_security_policy_taint() API Philippe Mathieu-Daudé
2021-09-09 9:53 ` Philippe Mathieu-Daudé
2021-09-09 10:40 ` Daniel P. Berrangé
2021-09-09 10:55 ` Daniel P. Berrangé
2021-09-09 19:05 ` Eric Blake
2021-09-08 23:20 ` [RFC PATCH 04/10] block/vvfat: Mark the driver as unsafe Philippe Mathieu-Daudé
2021-09-08 23:20 ` [RFC PATCH 05/10] block/null: Mark 'read-zeroes=off' option " Philippe Mathieu-Daudé
2021-09-08 23:20 ` [RFC PATCH 06/10] qdev: Use qemu_security_policy_taint() API Philippe Mathieu-Daudé
2021-09-09 11:03 ` Daniel P. Berrangé [this message]
2021-09-08 23:20 ` [RFC PATCH 07/10] hw/display: Mark ATI and Artist devices as unsafe Philippe Mathieu-Daudé
2021-09-08 23:20 ` [RFC PATCH 08/10] hw/misc: Mark testdev " Philippe Mathieu-Daudé
2021-09-08 23:20 ` [RFC PATCH 09/10] hw/net: Mark Tulip device " Philippe Mathieu-Daudé
2021-09-08 23:20 ` [RFC PATCH 10/10] hw/sd: Mark sdhci-pci " Philippe Mathieu-Daudé
2021-09-09 10:28 ` [RFC PATCH 00/10] security: Introduce qemu_security_policy_taint() API Daniel P. Berrangé
2021-09-14 13:30 ` P J P
2021-09-28 11:39 ` P J P
2021-09-30 10:30 ` Daniel P. Berrangé
2021-09-09 12:03 ` Alexander Bulekov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YTnqFHnolMLeY9c8@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=eblake@redhat.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).