]> www.infradead.org Git - users/jedix/linux-maple.git/commit
xen: fix bio vec merging
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 18 Jul 2017 14:01:00 +0000 (15:01 +0100)
committerChuck Anderson <chuck.anderson@oracle.com>
Tue, 22 Aug 2017 15:30:02 +0000 (08:30 -0700)
commit2df95d69537c471a542ecfcb8d56520c6da15c07
treeb22de3ddb0b27bfbf7b0b03b899447819e2ddf4c
parent2a9857f39ef77bf8bd18f35daf6654fbe1d965ed
xen: fix bio vec merging

The current test for bio vec merging is not fully accurate and can be
tricked into merging bios when certain grant combinations are used.
The result of these malicious bio merges is a bio that extends past
the memory page used by any of the originating bios.

Take into account the following scenario, where a guest creates two
grant references that point to the same mfn, ie: grant 1 -> mfn A,
grant 2 -> mfn A.

These references are then used in a PV block request, and mapped by
the backend domain, thus obtaining two different pfns that point to
the same mfn, pfn B -> mfn A, pfn C -> mfn A.

If those grants happen to be used in two consecutive sectors of a disk
IO operation becoming two different bios in the backend domain, the
checks in xen_biovec_phys_mergeable will succeed, because bfn1 == bfn2
(they both point to the same mfn). However due to the bio merging,
the backend domain will end up with a bio that expands past mfn A into
mfn A + 1.

Fix this by making sure the check in xen_biovec_phys_mergeable takes
into account the offset and the length of the bio, this basically
replicates whats done in __BIOVEC_PHYS_MERGEABLE using mfns (bus
addresses). While there also remove the usage of
__BIOVEC_PHYS_MERGEABLE, since that's already checked by the callers
of xen_biovec_phys_mergeable.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Orabug: 26564183
CVE: CVE-2017-12134

Reviewed-by: Chuck Anderson <chuck.anderson@oracle.com>
drivers/xen/biomerge.c