gnttab: fix unmap pin accounting race
authorJan Beulich <jbeulich@suse.com>
Fri, 2 Jun 2017 11:22:42 +0000 (12:22 +0100)
committerIan Jackson <ian.jackson@eu.citrix.com>
Thu, 7 Sep 2017 18:17:58 +0000 (19:17 +0100)
commit03ea5ee847c1d80f6d9c0a12de88058d0d401ce0
tree4dc43df54c624acc10aeed95d89e5b4428663ca3
parentab6ff8a970d1d590513a14ca0ec7f28768ae2385
gnttab: fix unmap pin accounting race

Once all {writable} mappings of a grant entry have been unmapped, the
hypervisor informs the guest that the grant entry has been released by
clearing the _GTF_{reading,writing} usage flags in the guest's grant
table as appropriate.

Unfortunately, at the moment, the code that updates the accounting
happens in a different critical section than the one which updates the
usage flags; this means that under the right circumstances, there may be
a window in time after the hypervisor reported the grant as being free
during which the grant referee still had access to the page.

Move the grant accounting code into the same critical section as the
reporting code to make sure this kind of race can't happen.

This is part of XSA-218.

Reported-by: Jann Horn <jannh.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Gbp-Pq: Name gnttab-fix-unmap-pin-accounting-race
xen/common/grant_table.c