From: Jan Beulich Date: Tue, 24 Nov 2020 13:01:31 +0000 (+0100) Subject: memory: fix off-by-one in XSA-346 change X-Git-Tag: archive/raspbian/4.16.0+51-g0941d6cb-1+rpi1~2^2~42^2~1386 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9b156bcc3ffcc7949edd4460b718a241e87ae302;p=xen.git memory: fix off-by-one in XSA-346 change 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 Reviewed-by: Julien Grall --- diff --git a/xen/common/memory.c b/xen/common/memory.c index df85b550a1..2c86934ae8 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -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;