xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andres Lagar Cavilla <andres@lagarcavilla.org>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Tim Deegan <tim@xen.org>, Jan Beulich <JBeulich@suse.com>,
	Xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH 1/2] Xen/mem_event: Validate the response vcpu_id before acting on it.
Date: Thu, 17 Jul 2014 14:33:38 -0400	[thread overview]
Message-ID: <CADzFZPvmSoT2FTDNNLeJRRpGOg_Jr943y-erD8H0+Eh1L-heXg@mail.gmail.com> (raw)
In-Reply-To: <1405602637-8321-2-git-send-email-andrew.cooper3@citrix.com>


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

On Thu, Jul 17, 2014 at 9:10 AM, Andrew Cooper <andrew.cooper3@citrix.com>
wrote:

> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> CC: Jan Beulich <JBeulich@suse.com>
> CC: Tim Deegan <tim@xen.org>
> CC: Andres Lagar-Cavilla <andres@lagarcavilla.org>
>
Reviewed-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

> ---
>  xen/arch/x86/mm/mem_sharing.c |   11 ++++++++++-
>  xen/arch/x86/mm/p2m.c         |   22 ++++++++++++++++++++--
>  2 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
> index 7293f31..ec99266 100644
> --- a/xen/arch/x86/mm/mem_sharing.c
> +++ b/xen/arch/x86/mm/mem_sharing.c
> @@ -596,11 +596,20 @@ int mem_sharing_sharing_resume(struct domain *d)
>      /* Get all requests off the ring */
>      while ( mem_event_get_response(d, &d->mem_event->share, &rsp) )
>      {
> +        struct vcpu *v;
> +
>          if ( rsp.flags & MEM_EVENT_FLAG_DUMMY )
>              continue;
> +
> +        /* Validate the vcpu_id in the response. */
> +        if ( (rsp.vcpu_id >= d->max_vcpus) || !d->vcpu[rsp.vcpu_id] )
> +            continue;
> +
> +        v = d->vcpu[rsp.vcpu_id];
> +
>          /* Unpause domain/vcpu */
>          if ( rsp.flags & MEM_EVENT_FLAG_VCPU_PAUSED )
> -            vcpu_unpause(d->vcpu[rsp.vcpu_id]);
> +            vcpu_unpause(v);
>      }
>
>      return 0;
> diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
> index 642ec28..f213a39 100644
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -1290,8 +1290,17 @@ void p2m_mem_paging_resume(struct domain *d)
>      /* Pull all responses off the ring */
>      while( mem_event_get_response(d, &d->mem_event->paging, &rsp) )
>      {
> +        struct vcpu *v;
> +
>          if ( rsp.flags & MEM_EVENT_FLAG_DUMMY )
>              continue;
> +
> +        /* Validate the vcpu_id in the response. */
> +        if ( (rsp.vcpu_id >= d->max_vcpus) || !d->vcpu[rsp.vcpu_id] )
> +            continue;
> +
> +        v = d->vcpu[rsp.vcpu_id];
> +
>          /* Fix p2m entry if the page was not dropped */
>          if ( !(rsp.flags & MEM_EVENT_FLAG_DROP_PAGE) )
>          {
> @@ -1310,7 +1319,7 @@ void p2m_mem_paging_resume(struct domain *d)
>          }
>          /* Unpause domain */
>          if ( rsp.flags & MEM_EVENT_FLAG_VCPU_PAUSED )
> -            vcpu_unpause(d->vcpu[rsp.vcpu_id]);
> +            vcpu_unpause(v);
>      }
>  }
>
> @@ -1418,11 +1427,20 @@ void p2m_mem_access_resume(struct domain *d)
>      /* Pull all responses off the ring */
>      while( mem_event_get_response(d, &d->mem_event->access, &rsp) )
>      {
> +        struct vcpu *v;
> +
>          if ( rsp.flags & MEM_EVENT_FLAG_DUMMY )
>              continue;
> +
> +        /* Validate the vcpu_id in the response. */
> +        if ( (rsp.vcpu_id >= d->max_vcpus) || !d->vcpu[rsp.vcpu_id] )
> +            continue;
> +
> +        v = d->vcpu[rsp.vcpu_id];
> +
>          /* Unpause domain */
>          if ( rsp.flags & MEM_EVENT_FLAG_VCPU_PAUSED )
> -            vcpu_unpause(d->vcpu[rsp.vcpu_id]);
> +            vcpu_unpause(v);
>      }
>  }
>
> --
> 1.7.10.4
>
>

[-- Attachment #1.2: Type: text/html, Size: 4519 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-17 18:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-17 13:10 [PATCH 0/2] Xen/mem_event: Do not rely on the toolstack being bug-free Andrew Cooper
2014-07-17 13:10 ` [PATCH 1/2] Xen/mem_event: Validate the response vcpu_id before acting on it Andrew Cooper
2014-07-17 18:33   ` Andres Lagar Cavilla [this message]
2014-07-17 13:10 ` [PATCH 2/2] Xen/mem_event: Prevent underflow of vcpu pause counts Andrew Cooper
2014-07-17 18:38   ` Andres Lagar Cavilla
     [not found]     ` <CAGU+auv8zMj+xqU8KhbQSZXM+J+HovjV=TZMab5Z+nzNCvpjaQ@mail.gmail.com>
2014-07-17 18:51       ` Aravindh Puthiyaparambil (aravindp)
2014-07-17 18:54         ` Andres Lagar Cavilla
2014-07-17 18:57           ` Aravindh Puthiyaparambil (aravindp)
2014-07-17 19:07           ` Andrew Cooper
2014-07-17 19:18             ` Aravindh Puthiyaparambil (aravindp)
2014-07-17 18:55     ` Andrew Cooper
2014-07-18  9:42     ` Ian Campbell
2014-07-18 10:41   ` [PATCH v2 " Andrew Cooper
2014-07-18 13:47     ` Razvan Cojocaru
2014-07-18 13:53     ` [PATCH v3 " Andrew Cooper
2014-07-18 16:37       ` Andres Lagar Cavilla
2014-07-18 16:44         ` Andrew Cooper
2014-07-18 17:29       ` Aravindh Puthiyaparambil (aravindp)
2014-07-17 13:23 ` [PATCH 0/2] Xen/mem_event: Do not rely on the toolstack being bug-free Tim Deegan
2014-07-17 14:40 ` Razvan Cojocaru
2014-07-17 14:46   ` Andrew Cooper
2014-07-17 14:50     ` Razvan Cojocaru
     [not found] ` <CAGU+auuzOr5HSErrxmyhtxtP74gn=0L5TAZGR8FWBF6MeGFxUA@mail.gmail.com>
2014-07-17 19:01   ` Aravindh Puthiyaparambil (aravindp)
2014-07-17 20:26     ` Razvan Cojocaru
2014-07-17 22:17       ` Tamas Lengyel
2014-07-17 22:42         ` 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=CADzFZPvmSoT2FTDNNLeJRRpGOg_Jr943y-erD8H0+Eh1L-heXg@mail.gmail.com \
    --to=andres@lagarcavilla.org \
    --cc=JBeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=tim@xen.org \
    --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).