From: Wei Liu <wei.liu2@citrix.com>
To: Paul Durrant <paul.durrant@citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Jennifer Herbert <jennifer.herbert@citrix.com>,
Jan Beulich <jbeulich@suse.com>,
Ian Jackson <ian.jackson@citrix.com>,
xen-devel@lists.xenproject.org,
Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v2 1/8] public / x86: Introduce __HYPERCALL_dm_op...
Date: Mon, 12 Dec 2016 13:27:32 +0000 [thread overview]
Message-ID: <20161212132732.GU2709@citrix.com> (raw)
In-Reply-To: <1481031979-4751-2-git-send-email-paul.durrant@citrix.com>
On Tue, Dec 06, 2016 at 01:46:12PM +0000, Paul Durrant wrote:
> ...as a set of hypercalls to be used by a device model.
[...]
> +Introduction
> +------------
> +
> +A previous proposal for a 'DMOP' was put forward by Ian Jackson on the 1st
> +of August. This proposal seem very promising, however a problem was
> +identified with it, that this proposal addresses.
> +
> +The aim of DMOP, as before, is to prevent a compromised device model from
> +compromising domains other then the one it is associated with. (And is
> +therefore likely already compromised).
> +
> +The previous proposal adds a DMOP hypercall, for use by the device models,
> +which places the domain ID in a fixed place, within the calling args,
> +such that the priv driver can always find it, and not need to know any
> +further details about the particular DMOP in order to validate it against
> +previously set (vie ioctl) domain.
> +
> +The problem occurs when you have a DMOP with references to other user memory
> +objects, such as with Track dirty VRAM (As used with the VGA buffer).
> +Is this case, the address of this other user object needs to be vetted,
> +to ensure it is not within a restricted address ranges, such as kernel
> +memory. The real problem comes down to how you would vet this address -
> +the idea place to do this is within the privcmd driver, since it would have
> +knowledge of the address space involved. However, with a principal goal
> +of DMOP to allow privcmd to be free from any knowledge of DMOP's sub ops,
> +it would have no way to identify any user buffer addresses that need
> +checking. The alternative of allowing the hypervisor to vet the address
> +is also problematic, since it has no knowledge of the guest memory layout.
> +
Could you perhaps rewrite this section? The reference to "Ian Jackson on
the ..." and some other bits aren't really useful in the context of a
design doc.
The comparison between the old and new proposal isn't needed IMHO. There
has never been an old implementation / design doc in xen.git.
> +Validation by privcmd driver
> +------------------------------
> +
> +If the privcmd driver has been restricted to specific domain (using a
> + new ioctl), when it received an op, it will:
> +
> +1. Check hypercall is DMOP.
> +
> +2. Check domid == restricted domid.
> +
> +3. For each @nr_buffers in @buffers: Check @h and @len give a buffer
> + wholey in the user space part of the virtual address space. (e.g.,
> + on Linux use access_ok()).
> +
> +
> +Xen Implementation
> +------------------
> +
> +Since a DMOP sub of may need to copy or return a buffer from the guest,
"sub of" -> "sub op" ?
> +as well as the DMOP itself to git the initial buffer, functions for doing
> +this would be written as below. Note that care is taken to prevent
> +damage from buffer under or over run situations. If the DMOP is called
> +with insufficient buffers, zeros will be read, while extra is ignored.
> +
[...]
> # make_device_model(priv, dm_dom, hvm_dom)
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 2c83544..cc37752 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
Is DMOP considered stable in this patch? I guess not, given the header
is enclosed by __XEN__ and __XEN_TOOLS__.
Let's keep it in libxc for now. Eventually it will need to be moved to
tools/libs.
> @@ -41,6 +41,7 @@
> #include <xen/sched.h>
> #include <xen/memory.h>
> #include <xen/grant_table.h>
> +#include <xen/hvm/dm_op.h>
> #include <xen/hvm/params.h>
> #include <xen/xsm/flask_op.h>
> #include <xen/tmem.h>
> diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
> index d57c39a..8e49635 100644
> --- a/tools/libxc/xc_private.c
> +++ b/tools/libxc/xc_private.c
> @@ -776,6 +776,76 @@ int xc_ffs64(uint64_t x)
> return l ? xc_ffs32(l) : h ? xc_ffs32(h) + 32 : 0;
> }
>
> +int do_dm_op(xc_interface *xch, domid_t domid, unsigned int nr_bufs, ...)
> +{
> + int ret = -1;
> + struct {
> + void *u;
> + void *h;
> + } *bounce;
> + DECLARE_HYPERCALL_BUFFER(xen_dm_op_buf_t, bufs);
> + va_list args;
> + unsigned int idx;
> +
> + bounce = calloc(nr_bufs, sizeof(*bounce));
> + if ( bounce == NULL )
> + goto fail1;
> +
> + bufs = xc_hypercall_buffer_alloc(xch, bufs, sizeof(*bufs) * nr_bufs);
> + if ( bufs == NULL )
> + goto fail2;
> +
> + va_start(args, nr_bufs);
> + for (idx = 0; idx < nr_bufs; idx++)
for ( idx .. idx++ )
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-12-12 13:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-06 13:46 [PATCH v2 0/8] New hypercall for device models Paul Durrant
2016-12-06 13:46 ` [PATCH v2 1/8] public / x86: Introduce __HYPERCALL_dm_op Paul Durrant
2016-12-12 13:27 ` Wei Liu [this message]
2016-12-15 15:22 ` Jan Beulich
2016-12-15 15:55 ` Paul Durrant
2016-12-06 13:46 ` [PATCH v2 2/8] dm_op: convert HVMOP_*ioreq_server* Paul Durrant
2016-12-12 13:30 ` Wei Liu
2016-12-15 15:37 ` Jan Beulich
2016-12-06 13:46 ` [PATCH v2 3/8] dm_op: convert HVMOP_track_dirty_vram Paul Durrant
2016-12-15 15:44 ` Jan Beulich
2016-12-15 16:23 ` Paul Durrant
2016-12-06 13:46 ` [PATCH v2 4/8] dm_op: convert HVMOP_set_pci_intx_level, HVMOP_set_isa_irq_level, and Paul Durrant
2016-12-15 15:51 ` Jan Beulich
2016-12-06 13:46 ` [PATCH v2 5/8] dm_op: convert HVMOP_modified_memory Paul Durrant
2016-12-15 16:05 ` Jan Beulich
2016-12-15 16:25 ` Paul Durrant
2016-12-06 13:46 ` [PATCH v2 6/8] dm_op: convert HVMOP_set_mem_type Paul Durrant
2016-12-15 16:11 ` Jan Beulich
2016-12-06 13:46 ` [PATCH v2 7/8] dm_op: convert HVMOP_inject_trap and HVMOP_inject_msi Paul Durrant
2016-12-15 16:23 ` Jan Beulich
2016-12-15 16:32 ` Paul Durrant
2016-12-06 13:46 ` [PATCH v2 8/8] x86/hvm: serialize trap injecting producer and consumer Paul Durrant
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=20161212132732.GU2709@citrix.com \
--to=wei.liu2@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=ian.jackson@citrix.com \
--cc=jbeulich@suse.com \
--cc=jennifer.herbert@citrix.com \
--cc=paul.durrant@citrix.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 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.