linux-sg2042/drivers
Souptick Joarder 8d1502f629 xen/gntdev.c: Replace vm_map_pages() with vm_map_pages_zero()
'commit df9bde015a ("xen/gntdev.c: convert to use vm_map_pages()")'
breaks gntdev driver. If vma->vm_pgoff > 0, vm_map_pages()
will:
 - use map->pages starting at vma->vm_pgoff instead of 0
 - verify map->count against vma_pages()+vma->vm_pgoff instead of just
   vma_pages().

In practice, this breaks using a single gntdev FD for mapping multiple
grants.

relevant strace output:
[pid   857] ioctl(7, IOCTL_GNTDEV_MAP_GRANT_REF, 0x7ffd3407b6d0) = 0
[pid   857] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 7, 0) =
0x777f1211b000
[pid   857] ioctl(7, IOCTL_GNTDEV_SET_UNMAP_NOTIFY, 0x7ffd3407b710) = 0
[pid   857] ioctl(7, IOCTL_GNTDEV_MAP_GRANT_REF, 0x7ffd3407b6d0) = 0
[pid   857] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 7,
0x1000) = -1 ENXIO (No such device or address)

details here:
https://github.com/QubesOS/qubes-issues/issues/5199

The reason is -> ( copying Marek's word from discussion)

vma->vm_pgoff is used as index passed to gntdev_find_map_index. It's
basically using this parameter for "which grant reference to map".
map struct returned by gntdev_find_map_index() describes just the pages
to be mapped. Specifically map->pages[0] should be mapped at
vma->vm_start, not vma->vm_start+vma->vm_pgoff*PAGE_SIZE.

When trying to map grant with index (aka vma->vm_pgoff) > 1,
__vm_map_pages() will refuse to map it because it will expect map->count
to be at least vma_pages(vma)+vma->vm_pgoff, while it is exactly
vma_pages(vma).

Converting vm_map_pages() to use vm_map_pages_zero() will fix the
problem.

Marek has tested and confirmed the same.

Cc: stable@vger.kernel.org # v5.2+
Fixes: df9bde015a ("xen/gntdev.c: convert to use vm_map_pages()")

Reported-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
2019-07-31 08:13:59 +02:00
..
accessibility
acpi pci-v5.3-changes 2019-07-15 20:44:49 -07:00
amba Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
android
ata for-5.3/libata-20190708 2019-07-09 10:59:26 -07:00
atm
auxdisplay It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
base Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
bcma
block for-linus-20190715 2019-07-15 21:20:52 -07:00
bluetooth Bluetooth: btusb: Add protocol support for MediaTek MT7663U USB devices 2019-07-06 21:44:25 +02:00
bus
cdrom
char Some small fixes for various things, nothing huge, mostly found 2019-07-13 15:07:02 -07:00
clk - Core Frameworks 2019-07-15 20:18:40 -07:00
clocksource clocksource/drivers/npcm: Fix misuse of GENMASK macro 2019-07-10 11:05:26 +02:00
connector
counter Staging / IIO driver update for 5.3-rc1 2019-07-11 15:36:02 -07:00
cpufreq Merge branch 'pm-cpufreq' 2019-07-08 11:00:02 +02:00
cpuidle
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2019-07-08 20:57:08 -07:00
dax device-dax: use the dev_pagemap internal refcount 2019-07-02 14:32:44 -03:00
dca
devfreq
dio
dma This pull-request contains the following changes for MTD: 2019-07-13 15:42:44 -07:00
dma-buf drm main pull request for v5.3-rc1 (sans mm changes) 2019-07-15 19:04:27 -07:00
edac
eisa
extcon
firewire
firmware Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
fpga Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
fsi
gnss
gpio Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
gpu pci-v5.3-changes 2019-07-15 20:44:49 -07:00
hid stream_open related bits for Linux 5.3 2019-07-14 17:08:08 -07:00
hsi
hv - Add a module description to the Hyper-V vmbus module. 2019-07-12 15:28:38 -07:00
hwmon Char / Misc driver patches for 5.3-rc1 2019-07-11 15:34:05 -07:00
hwspinlock
hwtracing coresight: Make the coresight_device_fwnode_match declaration's fwnode parameter const 2019-07-12 14:42:05 -07:00
i2c Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
i3c * Drop support for 10-bit I2C addresses 2019-07-09 09:04:31 -07:00
ide It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
idle
iio Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
infiniband 5.3 Merge window RDMA pull request 2019-07-15 20:38:15 -07:00
input stream_open related bits for Linux 5.3 2019-07-14 17:08:08 -07:00
interconnect
iommu dma-mapping updates for Linux 5.3 2019-07-12 15:13:55 -07:00
ipack TTY / Serial driver updates for 5.3-rc1 2019-07-11 15:38:21 -07:00
irqchip irqchip/gic-v3-its: Fix misuse of GENMASK macro 2019-07-10 11:04:17 +02:00
isdn Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-07-11 10:55:49 -07:00
leds LED updates for 5.3-rc1 2019-07-09 08:59:39 -07:00
lightnvm
macintosh powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
mailbox - stm32: race fix by adding a spinlock 2019-07-14 16:36:51 -07:00
mcb
md for-linus-20190715 2019-07-15 21:20:52 -07:00
media Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-07-11 10:55:49 -07:00
memory Char / Misc driver patches for 5.3-rc1 2019-07-11 15:34:05 -07:00
memstick MMC core: 2019-07-11 18:11:21 -07:00
message SCSI misc on 20190709 2019-07-11 15:14:01 -07:00
mfd - Core Frameworks 2019-07-15 20:18:40 -07:00
misc Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
mmc MMC core: 2019-07-11 18:11:21 -07:00
mtd This pull-request contains the following changes for MTD: 2019-07-13 15:42:44 -07:00
mux
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2019-07-13 15:57:37 -07:00
nfc nfc: st-nci: remove redundant assignment to variable r 2019-07-02 12:00:50 -07:00
ntb
nubus
nvdimm Revert "Merge tag 'keys-acl-20190703' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs" 2019-07-10 18:43:43 -07:00
nvme for-linus-20190715 2019-07-15 21:20:52 -07:00
nvmem Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
of Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
opp pci-v5.3-changes 2019-07-15 20:44:49 -07:00
oprofile
parisc
parport It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
pci pci-v5.3-changes 2019-07-15 20:44:49 -07:00
pcmcia It's been a relatively busy cycle for docs: 2019-07-09 12:34:26 -07:00
perf arm64 updates for 5.3: 2019-07-08 09:54:55 -07:00
phy phy: for 5.3 2019-07-01 15:04:59 +02:00
pinctrl This is the bulk of pin control changes for the v5.3 kernel 2019-07-13 15:02:27 -07:00
platform Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
pnp
power power supply and reset changes for the v5.3 series 2019-07-15 21:06:15 -07:00
powercap Merge branch 'x86-topology-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-07-08 18:28:44 -07:00
pps
ps3
ptp
pwm pwm: Changes for v5.3-rc1 2019-07-09 08:57:45 -07:00
rapidio
ras
regulator - Core Frameworks 2019-07-15 20:18:40 -07:00
remoteproc
reset
rpmsg
rtc - Core Frameworks 2019-07-15 20:18:40 -07:00
s390 s390 updates for the 5.3 merge window #2 2019-07-12 15:39:22 -07:00
sbus
scsi for-linus-20190715 2019-07-15 21:20:52 -07:00
sfi
sh
siox
slimbus
sn
soc pci-v5.3-changes 2019-07-15 20:44:49 -07:00
soundwire soundwire updates for v5.3-rc1 2019-07-05 08:15:08 +02:00
spi Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
spmi
ssb
staging drm main pull request for v5.3-rc1 (sans mm changes) 2019-07-15 19:04:27 -07:00
target SCSI misc on 20190709 2019-07-11 15:14:01 -07:00
tc
tee
thermal Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
thunderbolt Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
tty powerpc updates for 5.3 2019-07-13 16:08:36 -07:00
uio
usb Merge branch 'i2c/for-5.3' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux 2019-07-15 21:10:39 -07:00
uwb
vfio
vhost Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2019-07-11 10:55:49 -07:00
video drm main pull request for v5.3-rc1 (sans mm changes) 2019-07-15 19:04:27 -07:00
virt
virtio
visorbus
vlynq
vme
w1
watchdog Driver Core and debugfs changes for 5.3-rc1 2019-07-12 12:24:03 -07:00
xen xen/gntdev.c: Replace vm_map_pages() with vm_map_pages_zero() 2019-07-31 08:13:59 +02:00
zorro
Kconfig
Makefile