]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mm: don't bypass preemption checks
authorJan Beulich <jbeulich@suse.com>
Thu, 28 Jun 2018 10:26:25 +0000 (12:26 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 28 Jun 2018 10:26:25 +0000 (12:26 +0200)
While unlikely, it is not impossible for a multi-vCPU guest to leverage
bypasses of preemption checks to drive Xen into an unbounded loop.

This is XSA-264.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/arch/x86/mm.c

index 48111f5fee0c7d5c409f269e87f391f0d1a3b8d5..a43002259589901af864ace54dd02c1335c5875b 100644 (file)
@@ -2546,7 +2546,7 @@ static int _put_page_type(struct page_info *page, bool_t preemptible,
                 nx = x & ~(PGT_validated|PGT_partial);
                 if ( unlikely((y = cmpxchg(&page->u.inuse.type_info,
                                            x, nx)) != x) )
-                    continue;
+                    goto maybe_preempt;
                 /* We cleared the 'valid bit' so we do the clean up. */
                 rc = _put_final_page_type(page, x, preemptible, ptpg);
                 ptpg = NULL;
@@ -2581,12 +2581,13 @@ static int _put_page_type(struct page_info *page, bool_t preemptible,
              */
             cpu_relax();
             y = page->u.inuse.type_info;
-            continue;
+            goto maybe_preempt;
         }
 
         if ( likely((y = cmpxchg(&page->u.inuse.type_info, x, nx)) == x) )
             break;
 
+    maybe_preempt:
         if ( preemptible && hypercall_preempt_check() )
             return -EINTR;
     }
@@ -2690,12 +2691,11 @@ static int __get_page_type(struct page_info *page, unsigned long type,
             if ( !(x & PGT_partial) )
             {
                 /* Someone else is updating validation of this page. Wait... */
-                while ( (y = page->u.inuse.type_info) == x )
-                {
+                do {
                     if ( preemptible && hypercall_preempt_check() )
                         return -EINTR;
                     cpu_relax();
-                }
+                } while ( (y = page->u.inuse.type_info) == x );
                 continue;
             }
             /* Type ref count was left at 1 when PGT_partial got set. */