# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID b246f429f683cce73bf7486c37bf6842983fa49f
# Parent 6ba371536f5cbc2f0973c0e86881fec337828638
Prevent a guest from specifying its own domain id when
making a 'foreign' page mapping. It must use DOMID_SELF.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
diff -r 6ba371536f5c -r b246f429f683 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Wed Feb 8 16:25:14 2006
+++ b/xen/arch/x86/mm.c Wed Feb 8 16:26:20 2006
@@ -1641,14 +1641,18 @@
struct domain *e, *d = current->domain;
int okay = 1;
- if ( (e = percpu_info[cpu].foreign) != NULL )
- put_domain(e);
- percpu_info[cpu].foreign = NULL;
-
- if ( domid == DOMID_SELF )
+ ASSERT(percpu_info[cpu].foreign == NULL);
+
+ if ( likely(domid == DOMID_SELF) )
goto out;
- if ( !IS_PRIV(d) )
+ if ( domid == d->domain_id )
+ {
+ MEM_LOG("Dom %u tried to specify itself as foreign domain",
+ d->domain_id);
+ okay = 0;
+ }
+ else if ( !IS_PRIV(d) )
{
switch ( domid )
{
@@ -1734,7 +1738,7 @@
if ( !set_foreigndom(cpu, foreigndom) )
{
- rc = -EINVAL;
+ rc = -ESRCH;
goto out;
}
@@ -1993,7 +1997,7 @@
if ( !set_foreigndom(cpu, foreigndom) )
{
- rc = -EINVAL;
+ rc = -ESRCH;
goto out;
}
@@ -2580,18 +2584,13 @@
domid_t domid)
{
unsigned int cpu = smp_processor_id();
- struct domain *d;
int rc;
if ( unlikely(!IS_PRIV(current->domain)) )
return -EPERM;
- percpu_info[cpu].foreign = d = find_domain_by_id(domid);
- if ( unlikely(d == NULL) )
- {
- MEM_LOG("Unknown domain '%u'", domid);
+ if ( !set_foreigndom(cpu, domid) )
return -ESRCH;
- }
rc = do_update_va_mapping(va, val64, flags);
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|