]> xenbits.xensource.com Git - xen.git/commit
xen/page_alloc: Harden assign_pages()
authorJulien Grall <jgrall@amazon.com>
Tue, 23 Nov 2021 12:32:26 +0000 (13:32 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 23 Nov 2021 12:32:26 +0000 (13:32 +0100)
commit0b28069aa7c26288376040e6ee9ca145245db39e
tree245428ac1e7e69b6f551c72cdb0d9ed515e4ea69
parentb4bb02d5999a56c93f0733b589b717e7cece9c09
xen/page_alloc: Harden assign_pages()

domain_tot_pages() and d->max_pages are 32-bit values. While the order
should always be quite small, it would still be possible to overflow
if domain_tot_pages() is near to (2^32 - 1).

As this code may be called by a guest via XENMEM_increase_reservation
and XENMEM_populate_physmap, we want to make sure the guest is not going
to be able to allocate more than it is allowed.

Rework the allocation check to avoid any possible overflow. While the
check domain_tot_pages() < d->max_pages should technically not be
necessary, it is probably best to have it to catch any possible
inconsistencies in the future.

This is CVE-2021-28706 / part of XSA-385.

Signed-off-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
master commit: 143501861d48e1bfef495849fd68584baac05849
master date: 2021-11-22 11:11:05 +0000
xen/common/grant_table.c
xen/common/page_alloc.c