gnttab: fix out of range shift count
authorJan Beulich <jbeulich@suse.com>
Tue, 7 Jul 2015 08:28:25 +0000 (10:28 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 7 Jul 2015 08:28:25 +0000 (10:28 +0200)
Commit 213f145114 ("gnttab: fix/adjust gnttab_transfer()") wasn't
careful enough in this regard.

Coverity ID: 1306859
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/common/grant_table.c

index db5e5db0108527d02619d733e2f09b20b5845216..999817dad3dae98e7d0db2ab36eb5f5af9d37a43 100644 (file)
@@ -1829,7 +1829,8 @@ gnttab_transfer(
         max_bitsize = domain_clamp_alloc_bitsize(
             e, e->grant_table->gt_version > 1 || paging_mode_translate(e)
                ? BITS_PER_LONG + PAGE_SHIFT : 32 + PAGE_SHIFT);
-        if ( (1UL << (max_bitsize - PAGE_SHIFT)) <= mfn )
+        if ( max_bitsize < BITS_PER_LONG + PAGE_SHIFT &&
+             (mfn >> (max_bitsize - PAGE_SHIFT)) )
         {
             struct page_info *new_page;