[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen stable-4.17] x86/EPT: correct special page checking in epte_get_entry_emt()



commit a86a0df4c0af15df36a6b4fa397c8cc2e876cbfa
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Jun 26 14:09:50 2024 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Jun 26 14:09:50 2024 +0200

    x86/EPT: correct special page checking in epte_get_entry_emt()
    
    mfn_valid() granularity is (currently) 256Mb. Therefore the start of a
    1Gb page passing the test doesn't necessarily mean all parts of such a
    range would also pass. Yet using the result of mfn_to_page() on an MFN
    which doesn't pass mfn_valid() checking is liable to result in a crash
    (the invocation of mfn_to_page() alone is presumably "just" UB in such a
    case).
    
    Fixes: ca24b2ffdbd9 ("x86/hvm: set 'ipat' in EPT for special pages")
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    master commit: 5540b94e8191059eb9cbbe98ac316232a42208f6
    master date: 2024-06-13 16:53:34 +0200
---
 xen/arch/x86/mm/p2m-ept.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c
index d61d66c20e..54fa13fa7e 100644
--- a/xen/arch/x86/mm/p2m-ept.c
+++ b/xen/arch/x86/mm/p2m-ept.c
@@ -530,8 +530,12 @@ int epte_get_entry_emt(struct domain *d, gfn_t gfn, mfn_t 
mfn,
     }
 
     for ( special_pgs = i = 0; i < (1ul << order); i++ )
-        if ( is_special_page(mfn_to_page(mfn_add(mfn, i))) )
+    {
+        mfn_t cur = mfn_add(mfn, i);
+
+        if ( mfn_valid(cur) && is_special_page(mfn_to_page(cur)) )
             special_pgs++;
+    }
 
     if ( special_pgs )
     {
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.