All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Julien Grall <julien.grall@linaro.org>, xen-devel@lists.xenproject.org
Cc: "Wei Liu" <wei.liu2@citrix.com>,
	"Ian Campbell" <ian.campbell@citrix.com>,
	"Stefano Stabellini" <stefano.stabellini@eu.citrix.com>,
	"Ian Jackson" <ian.jackson@eu.citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH] libxc: introduce a per architecture scratch pfn for temporary grant mapping
Date: Wed, 14 Jan 2015 12:58:45 +0000	[thread overview]
Message-ID: <54B66805.4080902@citrix.com> (raw)
In-Reply-To: <1421179848-31833-1-git-send-email-julien.grall@linaro.org>

On 13/01/15 20:10, Julien Grall wrote:
> The code to initialize the grant table in libxc uses
> xc_domain_maximum_gpfn() + 1 to get a guest pfn for mapping the grant
> frame and to initialize it.
>
> This solution has two major issues:
>     - The check of the return of xc_domain_maximum_gpfn is buggy because
>     xen_pfn_t is unsigned and in case of an error -ERRNO is returned.
>     Which is never catch with ( pfn <= 0 ).

Wow - xc_domain_maximum_gpfn() will currently truncate long to int on
64bit systems.  That is unhelpful of it.

>     - The guest memory layout maybe filled up to the end, i.e
>     xc_domain_maximum_gpfn() + 1 gives either 0 or an invalid PFN due to
>     hardware limitation.

I realise I am throwing a spanner in the works here, but if you are
looking to fix it, lets fix this properly rather than hacking around the
problem further.

There is currently no way for the toolstack to map something on behalf
of a guest which is not in the guest physmap.  As a workaround, the code
here shoots a guest ram page, adds a non-ram page to the physmap, maps,
edits, unmaps and replaces the ram.

This is inefficient, liable to shatter superpages, and likely to end up
with with the returned ram allocated from the wrong numa node.

Furthermore, we have had security vulnerabilities in the past because
toolstack/device model components use guest pages (because of no
alternate mechanism) for emulation state/ring buffers without preventing
the guest itself from having access if it can find them.

Both of these issues are caused by the underlying inability for the
toolstack to map anything other than gfn space.

In the general case, an "alloc/map emulation page for" interface would
fix the security issue side of things (and make some existing code far
more simple).

However, in this case a mapping hypercall for pages which a guest could
add to its own physmap (but are not necessarily present at the moment)
would be the correct solution.

~Andrew

  parent reply	other threads:[~2015-01-14 12:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 20:10 [PATCH] libxc: introduce a per architecture scratch pfn for temporary grant mapping Julien Grall
2015-01-14 11:03 ` Ian Campbell
2015-01-14 13:32   ` Julien Grall
2015-01-14 12:58 ` Andrew Cooper [this message]
2015-01-14 13:20   ` Julien Grall
2015-01-14 13:23     ` Andrew Cooper
2015-01-14 13:26       ` Julien Grall
2015-01-14 13:31       ` Ian Campbell
2015-01-14 13:56         ` Andrew Cooper
2015-01-15 10:45   ` Tim Deegan
2015-01-15 13:14     ` Andrew Cooper
2015-01-15 13:20       ` Julien Grall
2015-01-21 12:03 ` Julien Grall
2015-01-21 12:07   ` Andrew Cooper

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=54B66805.4080902@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@linaro.org \
    --cc=roger.pau@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@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.