From: David Vrabel <david.vrabel@citrix.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Stefano Stabellini <stefano.stabellini@citrix.com>,
Jan Beulich <JBeulich@suse.com>,
xen-devel@lists.xen.org
Subject: Re: [PATCHv3] xen/p2m: check MFN is in range before using the m2p table
Date: Wed, 25 Sep 2013 10:46:10 +0100 [thread overview]
Message-ID: <5242B0E2.6000701@citrix.com> (raw)
In-Reply-To: <20130924143227.GA4712@phenom.dumpdata.com>
On 24/09/13 15:32, Konrad Rzeszutek Wilk wrote:
> On Fri, Sep 13, 2013 at 03:13:30PM +0100, David Vrabel wrote:
>> From: David Vrabel <david.vrabel@citrix.com>
>>
>> On hosts with more than 168 GB of memory, a 32-bit guest may attempt
>> to grant map an MFN that is not cannot lookup in its mapping of the
>> m2p table. There is an m2p lookup as part of m2p_add_override() and
>> m2p_remove_override(). The lookup falls off the end of the mapped
>> portion of the m2p and (because the mapping is at the highest virtual
>> address) wraps around and the lookup causes a fault on what appears to
>> be a user space address.
>>
>> do_page_fault() (thinking it's a fault to a userspace address), tries
>> to lock mm->mmap_sem. If the gntdev device is used for the grant map,
>> m2p_add_override() is called from from gnttab_mmap() with mm->mmap_sem
>> already locked. do_page_fault() then deadlocks.
>>
>> The deadlock would most commonly occur when a 64-bit guest is started
>> and xenconsoled attempts to grant map its console ring.
>>
>> Introduce mfn_to_pfn_no_overrides() which checks the MFN is within the
>> mapped portion of the m2p table before accessing the table and use
>> this in m2p_add_override(), m2p_remove_override(), and mfn_to_pfn()
>> (which already had the correct range check).
>>
>> All faults caused by accessing the non-existant parts of the m2p are
>> thus within the kernel address space and exception_fixup() is called
>> without trying to lock mm->mmap_sem.
>>
>> This means that for MFNs that are outside the mapped range of the m2p
>> then mfn_to_pfn() will always look in the m2p overrides. This is
>> correct because it must be a foreign MFN (and the PFN in the m2p in
>> this case is only relevant for the other domain).
>>
>> Signed-off-by: David Vrabel <david.vrabel@citrix.com>
>> Cc: Stefano Stabellini <stefano.stabellini@citrix.com>
>> Cc: Jan Beulich <JBeulich@suse.com>
>
> This looks like it should also go in stable?
It only really affects 32-bit dom0 and I've generally not been tagging
fixes for this use case for stable. Your call though.
David
next prev parent reply other threads:[~2013-09-25 9:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-13 14:13 [PATCHv3] xen/p2m: check MFN is in range before using the m2p table David Vrabel
2013-09-24 14:32 ` Konrad Rzeszutek Wilk
2013-09-25 9:46 ` David Vrabel [this message]
2013-09-25 11:26 ` Stefano Stabellini
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=5242B0E2.6000701@citrix.com \
--to=david.vrabel@citrix.com \
--cc=JBeulich@suse.com \
--cc=boris.ostrovsky@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=stefano.stabellini@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).