xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Andres Lagar Cavilla <andres@lagarcavilla.org>,
	Dushyant Behl <myselfdushyantbehl@gmail.com>
Cc: David Scott <dave.scott@eu.citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Ian Campbell <Ian.Campbell@citrix.com>,
	Xen Devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH v2 3/3] [GSOC14] FIX:- Race condition between initializing shared ring and mempaging.
Date: Mon, 21 Jul 2014 10:01:33 +0100	[thread overview]
Message-ID: <53CCD6ED.3020303@citrix.com> (raw)
In-Reply-To: <CADzFZPu90JFxAfc0EgZO5H6FtYYzB2xdYASHq0F7YU8M-H+v4Q@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 3444 bytes --]

On 21/07/14 08:31, Andres Lagar Cavilla wrote:
> On Sun, Jul 20, 2014 at 5:49 PM, Dushyant Behl
> <myselfdushyantbehl@gmail.com <mailto:myselfdushyantbehl@gmail.com>>
> wrote:
>
>     Ian,
>
>     Sorry for this extremely late response.
>
>     On Fri, Jun 27, 2014 at 4:03 PM, Ian Campbell
>     <Ian.Campbell@citrix.com <mailto:Ian.Campbell@citrix.com>> wrote:
>     > On Mon, 2014-06-16 at 23:50 +0530, Dushyant Behl wrote:
>     >> This patch is part of the work done under the gsoc project -
>     >> Lazy Restore Using Memory Paging.
>     >>
>     >> This patch is meant to fix a known race condition bug in mempaging
>     >> ring setup routines. The race conditon was between initializing
>     >
>     > "condition"
>     >
>     >> mem paging and initializing shared ring, earlier the code
>     initialized
>     >> mem paging before removing the ring page from guest's physical map
>     >> which could enable the guest to interfere with the ring
>     initialisation.
>     >> Now the code removes the page from the guest's physical map before
>     >> enabling mempaging so that the guest cannot clobber the ring after
>     >> we initialise it.
>     >>
>     >> Signed-off-by: Dushyant Behl <myselfdushyantbehl@gmail.com
>     <mailto:myselfdushyantbehl@gmail.com>>
>     >> Reviewed-by: Andres Lagar-Cavilla <andres@lagarcavilla.org
>     <mailto:andres@lagarcavilla.org>>
>     >> Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com
>     <mailto:andrew.cooper3@citrix.com>>
>     >> ---
>     >>  tools/libxc/xc_mem_paging_setup.c | 24 ++++++++++++++++++++----
>     >>  1 file changed, 20 insertions(+), 4 deletions(-)
>     >>
>     >> diff --git a/tools/libxc/xc_mem_paging_setup.c
>     b/tools/libxc/xc_mem_paging_setup.c
>     >> index 679c606..a4c4798 100644
>     >> --- a/tools/libxc/xc_mem_paging_setup.c
>     >> +++ b/tools/libxc/xc_mem_paging_setup.c
>     >> @@ -73,6 +73,24 @@ int xc_mem_paging_ring_setup(xc_interface *xch,
>     >>          }
>     >>      }
>     >>
>     >> +    /*
>     >> +     * Remove the page from guest's physical map so that the
>     guest will not
>     >> +     * be able to break security by pretending to be toolstack
>     for a while.
>     >> +     */
>     >> +    if ( xc_domain_decrease_reservation_exact(xch, domain_id,
>     1, 0, ring_page) )
>     >
>     > ring_page here is a void * mapping of the page, isn't it? Not a
>     > xen_pfn_t[] array of pfns, so surely this isn't right.
>
>     Yes, you are correct and the invocation should be with ring_pfn. But
>     if I change this with
>     the invocation done below as -
>     if ( xc_domain_decrease_reservation_exact(xch, domain_id, 1, 0,
>     &ring_pfn) ) 
>
>
>     then the code fails to enable mem paging.
>     Can anyone help as to why this would happen?
>
> The call that enables paging will use the hvm param in the hypervisor
> to look up the page by its pfn within the guest physical address
> space. If you call decrease reservation, then the page is removed from
> the guest phys address space, and the hvm param will point to a hole.
> And the call will fail of course. So you need to call decrease
> reservation strictly after enable paging.
>

You cannot have a period of time where the paging/access/events are
enabled and the guest can interfere with the ring page, as the Xen side
of ring pages are not robust to untrusted input.

How does this series interact with 6ae2df93 ?

~Andrew

[-- Attachment #1.2: Type: text/html, Size: 6599 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2014-07-21  9:01 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-16 18:20 [PATCH v2 0/3] Refactoring mempaging code from xenpaging to libxc and few updates Dushyant Behl
2014-06-16 18:20 ` [PATCH v2 1/3] [GSOC14] refactored mempaging code from xenpaging to libxc Dushyant Behl
2014-06-27 10:27   ` Ian Campbell
2014-06-27 10:37     ` Ian Campbell
2014-06-27 10:41       ` Andrew Cooper
2014-06-27 10:39     ` Dushyant Behl
2014-06-27 12:39       ` Ian Campbell
2014-06-28  3:32         ` Dushyant Behl
2014-06-30 10:37           ` Ian Campbell
2014-06-27 10:39   ` Ian Campbell
2014-06-16 18:20 ` [PATCH v2 2/3] [GSOC14] Replacing Deprecated Function Calls Dushyant Behl
2014-06-16 18:20 ` [PATCH v2 3/3] [GSOC14] FIX:- Race condition between initializing shared ring and mempaging Dushyant Behl
2014-06-27 10:33   ` Ian Campbell
2014-07-20 21:49     ` Dushyant Behl
2014-07-21  7:31       ` Andres Lagar Cavilla
2014-07-21  9:01         ` Andrew Cooper [this message]
2014-07-21 14:11           ` Andres Lagar Cavilla
2014-07-21 14:40             ` Andrew Cooper
2014-07-21 15:59               ` Andres Lagar Cavilla
2014-07-22 18:21                 ` Dushyant Behl
2014-07-23 10:14               ` Ian Campbell
2014-07-23 10:32                 ` Andrew Cooper
2014-07-23 10:35                   ` Ian Campbell
2014-07-23 10:46                     ` 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=53CCD6ED.3020303@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=andres@lagarcavilla.org \
    --cc=dave.scott@eu.citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=myselfdushyantbehl@gmail.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=xen-devel@lists.xen.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).