x86/mm: widen locked region in xenmem_add_to_physmap_one()
authorJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 13:07:09 +0000 (15:07 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Aug 2021 13:07:09 +0000 (15:07 +0200)
commit98bcd536c24ea35dcaed84cc35ce0f6c938ba9d6
tree727020eb478a126c2a384224ae19ea4720941c06
parent6f4c2146893c10ec17e854242613428f96e86757
x86/mm: widen locked region in xenmem_add_to_physmap_one()

For pages which can be made part of the P2M by the guest, but which can
also later be de-allocated (grant table v2 status pages being the
present example), it is imperative that they be mapped at no more than a
single GFN. We therefore need to make sure that of two parallel
XENMAPSPACE_grant_table requests for the same status page one completes
before the second checks at which other GFN the underlying MFN is
presently mapped.

Pull ahead the respective get_gfn() and push down the respective
put_gfn(). This leverages that gfn_lock() really aliases p2m_lock(), but
the function makes this assumption already anyway: In the
XENMAPSPACE_gmfn case lock nesting constraints for both involved GFNs
would otherwise need to be enforced to avoid ABBA deadlocks.

This is CVE-2021-28697 / XSA-379.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
master commit: f147422bf9476fb8161b43e35f5901571ed17c35
master date: 2021-08-25 14:17:56 +0200
xen/arch/x86/mm.c