]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
x86/tboot: Drop mfn_in_guarded_stack()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 26 Jul 2022 11:53:20 +0000 (12:53 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 8 Dec 2022 17:30:23 +0000 (17:30 +0000)
To support CET Shadow Stacks, guard pages changed unilaterally from being
holes to being read-only (i.e. they're never holes any more).

Furthermore, being real shadow stacks in some cases, the frames explicitly
should be included in the integrity check.

Fixes: 60016604739b ("x86/shstk: Rework the stack layout to support shadow stacks")
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/tboot.c

index fe1abfdf08ff13efc33f8e85950592b4961daf48..03098450f788a177c4c881ac6c7918124e633703 100644 (file)
@@ -242,29 +242,6 @@ static void tboot_gen_domain_integrity(const uint8_t key[TB_KEY_SIZE],
     memset(&ctx, 0, sizeof(ctx));
 }
 
-/*
- * For stack overflow detection in debug build, a guard page is set up.
- * This fn is used to detect whether a page is in the guarded pages for
- * the above reason.
- */
-static int mfn_in_guarded_stack(unsigned long mfn)
-{
-    void *p;
-    int i;
-
-    for ( i = 0; i < nr_cpu_ids; i++ )
-    {
-        if ( !stack_base[i] )
-            continue;
-        p = (void *)((unsigned long)stack_base[i] + STACK_SIZE -
-                     PRIMARY_STACK_SIZE - PAGE_SIZE);
-        if ( mfn == virt_to_mfn(p) )
-            return -1;
-    }
-
-    return 0;
-}
-
 static void tboot_gen_xenheap_integrity(const uint8_t key[TB_KEY_SIZE],
                                         vmac_t *mac)
 {
@@ -288,15 +265,7 @@ static void tboot_gen_xenheap_integrity(const uint8_t key[TB_KEY_SIZE],
             continue; /* skip tboot and its page tables */
 
         if ( is_page_in_use(page) && is_special_page(page) )
-        {
-            void *pg;
-
-            if ( mfn_in_guarded_stack(mfn) )
-                continue; /* skip guard stack, see memguard_guard_stack() in mm.c */
-
-            pg = mfn_to_virt(mfn);
-            vmac_update((uint8_t *)pg, PAGE_SIZE, &ctx);
-        }
+            vmac_update(mfn_to_virt(mfn), PAGE_SIZE, &ctx);
     }
     *mac = vmac(NULL, 0, nonce, NULL, &ctx);