linux-imx/drivers/xen
Roger Pau Monne 33bab9221e xen: fix bio vec merging
commit 462cdace79 upstream.

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.

Reported-by: "Jan H. Schönherr" <jschoenh@amazon.de>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
[bwh: Backported to 3.2:
 - s/bfn/mfn/g
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2017-09-15 18:30:57 +01:00
..
xen-pciback xen/pciback: Fix conf_space read/write overlap check. 2016-08-22 22:37:16 +01:00
xenbus xen/xenbus: Add quirk to deal with misconfigured backends. 2012-05-11 13:13:53 +01:00
xenfs xenbus: don't look up transaction IDs for ordinary writes 2016-11-20 01:01:44 +00:00
balloon.c xen/balloon: Avoid OOM when requesting highmem 2011-11-16 12:13:43 -05:00
biomerge.c xen: fix bio vec merging 2017-09-15 18:30:57 +01:00
cpu_hotplug.c
events.c xen/events: Don't move disabled irqs 2016-08-22 22:37:12 +01:00
evtchn.c xen: close evtchn port if binding to irq fails 2013-03-06 03:24:07 +00:00
features.c
gntalloc.c xen-gntalloc: signedness bug in add_grefs() 2011-11-16 12:13:48 -05:00
gntdev.c xen/gntdevt: Fix race condition in gntdev_release() 2015-10-13 03:46:01 +01:00
grant-table.c xen-gnt: prevent adding duplicate gnt callbacks 2013-10-26 21:05:57 +01:00
Kconfig xen: remove XEN_PLATFORM_PCI config option 2011-09-29 10:52:16 -04:00
Makefile xen: remove XEN_PLATFORM_PCI config option 2011-09-29 10:52:16 -04:00
manage.c xen/manage: Fix USB interaction issues when resuming 2015-05-09 23:16:15 +01:00
pci.c Merge branch 'stable/cleanups-3.2' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2011-11-06 20:13:34 -08:00
platform-pci.c xen: no need to delay xen_setup_shutdown_event for hvm guests anymore 2011-02-25 16:43:03 +00:00
swiotlb-xen.c xen: Use correct masking in xen_swiotlb_alloc_coherent. 2012-09-19 15:04:43 +01:00
sys-hypervisor.c drivers/xen/sys-hypervisor: Cleanup code/data sections definitions 2011-05-19 11:30:41 -04:00
tmem.c xen: prepare tmem shim to handle frontswap 2011-06-17 15:06:20 -06:00
xen-balloon.c xen: use static initializers in xen-balloon.c 2011-07-29 13:45:45 -04:00
xen-selfballoon.c Merge branches 'stable/bug.fixes-3.2' and 'stable/mmu.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen 2011-10-25 09:17:47 +02:00
xencomm.c