Skip to contentSkip to conversation

Ping: [PATCH v2 1/4] x86/PV: tighten page table ownership check in emul-priv-op.c:read_cr()

Xen-devel Jan Beulich 2 participants 2 messages Jul 17, 2019

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 04.06.19 at 14:41, wrote:

Rather than checking that a page table is _not_ "owned" by the fake COW domain, check that it's owned by the domain actually wanting to install it.

Switch away from BUG_ON() at the same time.

I've got Roger's R-b - any chance to get an ack here so it can go in?

Quoted 5 lines

---
v2: Split out from larger patch to make further adjustments.
---
Thinking about it I wonder why we have such a check here and no-where else. An alternative would seem to be to simply drop the BUG_ON().

Or would you prefer me to go this (or yet another) route?

Jan

Quoted 18 lines
xen/arch/x86/pv/emul-priv-op.c +2 -3
@@ -706,7 +706,7 @@ static int read_cr(unsigned int reg, uns
 
     case 3: /* Read CR3 */
     {
-        const struct domain *currd = curr->domain;
+        struct domain *currd = curr->domain;
         mfn_t mfn;
 
         if ( !is_pv_32bit_domain(currd) )
@@ -723,8 +723,14 @@ static int read_cr(unsigned int reg, uns
             unmap_domain_page(pl4e);
             *val = compat_pfn_to_cr3(mfn_to_gmfn(currd, mfn_x(mfn)));
         }
-        /* PTs should not be shared */
-        BUG_ON(page_get_owner(mfn_to_page(mfn)) == dom_cow);
+

xen/arch/x86/pv/emul-priv-op.c static int read_cr(unsigned int reg, uns · line 736

Quoted 10 lines
xen/arch/x86/pv/emul-priv-op.c +7 -0
+        /* PTs should be owned by their domains */
+        if ( page_get_owner(mfn_to_page(mfn)) != currd )
+        {
+            ASSERT_UNREACHABLE();
+            domain_crash(currd);
+        }
+
         return X86EMUL_OKAY;
     }
     }

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#1 lore raw
Quoted 9 lines · Jan Beulich
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 04.06.19 at 14:41, wrote:

Rather than checking that a page table is _not_ "owned" by the fake COW domain, check that it's owned by the domain actually wanting to install it.

Switch away from BUG_ON() at the same time.

I've got Roger's R-b - any chance to get an ack here so it can go in?

I already replied, and while I've got the email in my sent messages, I can't see any evidence of it being on the list.  ISTR we were having email troubles around that time.

Attached.

Quoted 4 lines · Jan Beulich

Rather than checking that a page table is _not_ "owned" by the fake COW domain, check that it's owned by the domain actually wanting to install it.

Quoted 8 lines

Switch away from BUG_ON() at the same time.

---
v2: Split out from larger patch to make further adjustments.
---
Thinking about it I wonder why we have such a check here and no-where else. An alternative would seem to be to simply drop the BUG_ON().

Looking at the history, af909e7e1 added this BUG_ON() long with a load of other COW/shared sanity checking, so it is quite possibly here out of an abundance of paranoia.

I'd be happy taking this out entirely, but if you're going to keep this patch, then...

xen/arch/x86/pv/emul-priv-op.c static int read_cr(unsigned int reg, uns · line 729

Quoted 13 lines
xen/arch/x86/pv/emul-priv-op.c +4 -2
@@ -723,8 +723,14 @@ static int read_cr(unsigned int reg, uns
             unmap_domain_page(pl4e);
             *val = compat_pfn_to_cr3(mfn_to_gmfn(currd, mfn_x(mfn)));
         }
-        /* PTs should not be shared */
-        BUG_ON(page_get_owner(mfn_to_page(mfn)) == dom_cow);
+
+        /* PTs should be owned by their domains */
+        if ( page_get_owner(mfn_to_page(mfn)) != currd )
+        {

... I need to refresh my patches which disallow the use of domain_crash() without a printk.

printk(XENLOG_G_ERR "%pv read cr3: mfn %"PRI_mfn" owner %pd != %pd\n" ...

With this printk (or something similar), or with the BUG_ON() removed entirely, Reviewed-by: Andrew Cooper <[email protected]>

~Andrew

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel