gnttab: deal with status frame mapping race
authorJan Beulich <jbeulich@suse.com>
Wed, 8 Sep 2021 12:53:04 +0000 (14:53 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 8 Sep 2021 12:53:04 +0000 (14:53 +0200)
commitef6455a3707cf1c7c61ad8af12558811eeee4ba8
treec1f70f9f10b85ff91e120bf004bab2a4d945037f
parent4ff1d3b86fe901ac558310f41ab0331ed4a249ea
gnttab: deal with status frame mapping race

Once gnttab_map_frame() drops the grant table lock, the MFN it reports
back to its caller is free to other manipulation. In particular
gnttab_unpopulate_status_frames() might free it, by a racing request on
another CPU, thus resulting in a reference to a deallocated page getting
added to a domain's P2M.

Obtain a page reference in gnttab_map_frame() to prevent freeing of the
page until xenmem_add_to_physmap_one() has actually completed its acting
on the page. Do so uniformly, even if only strictly required for v2
status pages, to avoid extra conditionals (which then would all need to
be kept in sync going forward).

This is CVE-2021-28701 / XSA-384.

Reported-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
master commit: eb6bbf7b30da5bae87932514d54d0e3c68b23757
master date: 2021-09-08 14:37:45 +0200
xen/arch/arm/mm.c
xen/arch/x86/mm.c
xen/common/grant_table.c