gnttab: fix unmap pin accounting race
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:32:03 +0000 (14:32 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Jun 2017 12:32:03 +0000 (14:32 +0200)
commit9a0bd460cfc28564d39fa23541bb872b13e7f7ea
tree9eedcf3346e83947d8addc9f75d24a7c95658967
parentfae7d5be8bb8b7a5b7005c4f3b812a47661a721e
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@google.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
xen/common/grant_table.c