gnttab: add preemption check to gnttab_release_mappings()
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 12:18:18 +0000 (14:18 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 12:18:18 +0000 (14:18 +0200)
commitb1ee10be5625b7d502cef1e6ee3818610ab0d29c
tree6127add9cd2db02919a4f9af3931b2b3f5919610
parentf147422bf9476fb8161b43e35f5901571ed17c35
gnttab: add preemption check to gnttab_release_mappings()

A guest may die with many grant mappings still in place, or simply with
a large maptrack table. Iterating through this may take more time than
is reasonable without intermediate preemption (to run softirqs and
perhaps the scheduler).

Move the invocation of the function to the section where other
restartable functions get invoked, and have the function itself check
for preemption every once in a while. Have it iterate the table
backwards, such that decreasing the maptrack limit is all it takes to
convey restart information.

In domain_teardown() introduce PROG_none such that inserting at the
front will be easier going forward.

This is part of CVE-2021-28698 / XSA-380.

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
xen/common/domain.c
xen/common/grant_table.c
xen/include/xen/grant_table.h