]> xenbits.xensource.com Git - people/pauldu/xen.git/commitdiff
memory: fix off-by-one in XSA-346 change
authorJan Beulich <jbeulich@suse.com>
Tue, 24 Nov 2020 13:01:31 +0000 (14:01 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 24 Nov 2020 13:01:31 +0000 (14:01 +0100)
The comparison against ARRAY_SIZE() needs to be >= in order to avoid
overrunning the pages[] array.

This is XSA-355.

Fixes: 5777a3742d88 ("IOMMU: hold page ref until after deferred TLB flush")
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/common/memory.c

index df85b550a1b17baa18da0d30f3c4d539b4716c43..2c86934ae8b172aa84a3538086a4b5d1c8f37429 100644 (file)
@@ -854,7 +854,7 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,
             ++extra.ppage;
 
         /* Check for continuation if it's not the last iteration. */
-        if ( (++done > ARRAY_SIZE(pages) && extra.ppage) ||
+        if ( (++done >= ARRAY_SIZE(pages) && extra.ppage) ||
              (xatp->size > done && hypercall_preempt_check()) )
         {
             rc = start + done;