From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <ian.campbell@citrix.com>, xen-devel@lists.xen.org
Cc: tim@xen.org, stefano.stabellini@eu.citrix.com
Subject: Re: [PATCH] xen: arm: do not BUG on guest paddrs which are very high
Date: Fri, 06 Dec 2013 16:05:47 +0000 [thread overview]
Message-ID: <52A1F5DB.5060005@linaro.org> (raw)
In-Reply-To: <1386248008-10820-1-git-send-email-ian.campbell@citrix.com>
On 12/05/2013 12:53 PM, Ian Campbell wrote:
> The BUG_ON in p2m_map_first was over aggressive since the paddr_t can have
> come from the guest, via add_to_physmap. Instead return failure to the caller.
>
> Also the check was simultaneously too lose. The valid offsets are
> 0..P2M_FIRST_ENTRIES-1 inclusive.
>
> Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
> ---
> xen/arch/arm/p2m.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
> index 1d5c841..cd134d4 100644
> --- a/xen/arch/arm/p2m.c
> +++ b/xen/arch/arm/p2m.c
> @@ -58,7 +58,8 @@ static lpae_t *p2m_map_first(struct p2m_domain *p2m, paddr_t addr)
> {
> struct page_info *page;
>
> - BUG_ON(first_linear_offset(addr) > P2M_FIRST_ENTRIES);
> + if ( first_linear_offset(addr) >= P2M_FIRST_ENTRIES )
> + return NULL;
>
> page = p2m->first_level + p2m_first_level_index(addr);
>
> @@ -80,6 +81,8 @@ paddr_t p2m_lookup(struct domain *d, paddr_t paddr)
> spin_lock(&p2m->lock);
>
> first = p2m_map_first(p2m, paddr);
> + if ( !first )
> + goto done;
If you jump to done, you will use pte which is uninitialized. Unlock the
spinlock should be enough here.
--
Julien Grall
next prev parent reply other threads:[~2013-12-06 16:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-05 12:53 [PATCH] xen: arm: do not BUG on guest paddrs which are very high Ian Campbell
2013-12-06 16:05 ` Julien Grall [this message]
2013-12-06 17:05 ` Ian Campbell
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=52A1F5DB.5060005@linaro.org \
--to=julien.grall@linaro.org \
--cc=ian.campbell@citrix.com \
--cc=stefano.stabellini@eu.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).