aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Jackson <Ian.Jackson@eu.citrix.com>2012-11-14 11:40:51 +0000
committerIan Jackson <Ian.Jackson@eu.citrix.com>2012-11-14 11:40:51 +0000
commite7dc3458699a97d8bdac6be9bde94751ef12bb3f (patch)
tree13bf1ff58bc29bb5ef12ab39668e00e06d6d8826
parent3e41893507b563c15b8d46a4717d2b7e92622502 (diff)
downloadxen-e7dc3458699a97d8bdac6be9bde94751ef12bb3f.tar.gz
xen-e7dc3458699a97d8bdac6be9bde94751ef12bb3f.tar.bz2
xen-e7dc3458699a97d8bdac6be9bde94751ef12bb3f.zip
x86/physmap: Prevent incorrect updates of m2p mappings
In certain conditions, such as low memory, set_p2m_entry() can fail. Currently, the p2m and m2p tables will get out of sync because we still update the m2p table after the p2m update has failed. If that happens, subsequent guest-invoked memory operations can cause BUG()s and ASSERT()s to kill Xen. This is fixed by only updating the m2p table iff the p2m was successfully updated. This is a security problem, XSA-22 / CVE-2012-4537. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
-rw-r--r--xen/arch/x86/mm/p2m.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 54940338d2..043a044626 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2207,7 +2207,10 @@ guest_physmap_add_entry(struct domain *d, unsigned long gfn,
if ( mfn_valid(_mfn(mfn)) )
{
if ( !set_p2m_entry(d, gfn, _mfn(mfn), page_order, t) )
+ {
rc = -EINVAL;
+ goto out; /* Failed to update p2m, bail without updating m2p. */
+ }
if ( !p2m_is_grant(t) )
{
for ( i = 0; i < (1UL << page_order); i++ )
@@ -2228,6 +2231,7 @@ guest_physmap_add_entry(struct domain *d, unsigned long gfn,
}
}
+out:
audit_p2m(d);
p2m_unlock(d->arch.p2m);