linux/drivers
Damien Le Moal b091ac6168 sd_zbc: Fix report zones buffer allocation
During disk scan and revalidation done with sd_revalidate(), the zones
of a zoned disk are checked using the helper function
blk_revalidate_disk_zones() if a configuration change is detected
(change in the number of zones or zone size). The function
blk_revalidate_disk_zones() issues report_zones calls that are very
large, that is, to obtain zone information for all zones of the disk
with a single command. The size of the report zones command buffer
necessary for such large request generally is lower than the disk
max_hw_sectors and KMALLOC_MAX_SIZE (4MB) and succeeds on boot (no
memory fragmentation), but often fail at run time (e.g. hot-plug
event). This causes the disk revalidation to fail and the disk
capacity to be changed to 0.

This problem can be avoided by using vmalloc() instead of kmalloc() for
the buffer allocation. To limit the amount of memory to be allocated,
this patch also introduces the arbitrary SD_ZBC_REPORT_MAX_ZONES
maximum number of zones to report with a single report zones command.
This limit may be lowered further to satisfy the disk max_hw_sectors
limit. Finally, to ensure that the vmalloc-ed buffer can always be
mapped in a request, the buffer size is further limited to at most
queue_max_segments() pages, allowing successful mapping of the buffer
even in the worst case scenario where none of the buffer pages are
contiguous.

Fixes: 515ce60613 ("scsi: sd_zbc: Fix sd_zbc_report_zones() buffer allocation")
Fixes: e76239a374 ("block: add a report_zones method")
Cc: stable@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2019-07-11 20:04:39 -06:00
..
accessibility
acpi Device properties framework updates for 5.3-rc1 2019-07-09 10:28:47 -07:00
amba treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
android binder: fix possible UAF when freeing buffer 2019-06-13 10:35:55 +02:00
ata for-5.3/libata-20190708 2019-07-09 10:59:26 -07:00
atm
auxdisplay auxdisplay/ht16k33.c: Convert to use vm_map_pages_zero() 2019-06-20 15:06:24 +02:00
base Device properties framework updates for 5.3-rc1 2019-07-09 10:28:47 -07:00
bcma
block block: Kill gfp_t argument of blkdev_report_zones() 2019-07-11 20:04:37 -06:00
bluetooth
bus SPDX update for 5.2-rc6 2019-06-21 09:58:42 -07:00
cdrom
char 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
clk A handful of clk driver fixes and one core framework fix 2019-06-28 08:50:09 +08:00
clocksource clocksource/drivers: Continue making Hyper-V clocksource ISA agnostic 2019-07-03 11:00:59 +02:00
connector
counter Second set of IIO fixes for the 5.2 cycle. 2019-06-17 22:28:29 +02:00
cpufreq Merge branch 'pm-cpufreq' 2019-07-08 11:00:02 +02:00
cpuidle treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
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 mm/devm_memremap_pages: fix final page put race 2019-06-13 17:34:56 -10:00
dca
devfreq treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
dio
dma dmaengine fixes for v5.2 2019-07-06 10:06:37 -07:00
dma-buf treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
edac EDAC: Fix global-out-of-bounds write when setting edac_mc_poll_msec 2019-06-27 10:24:47 -07:00
eisa
extcon treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
firewire
firmware tpmdd updates for Linux v5.3 2019-07-08 18:47:42 -07:00
fpga SPDX update for 5.2-rc4 2019-06-08 12:52:42 -07:00
fsi treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 469 2019-06-19 17:09:11 +02:00
gnss
gpio regulator: Updates for v5.3 2019-07-09 09:15:03 -07:00
gpu sound updates for 5.3 2019-07-09 09:59:43 -07:00
hid fbdev changes for v5.3: 2019-07-09 09:55:45 -07:00
hsi
hv Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-07-08 17:49:45 -07:00
hwmon 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
hwspinlock
hwtracing
i2c 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
i3c * Drop support for 10-bit I2C addresses 2019-07-09 09:04:31 -07:00
ide treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
idle
iio Merge branch 'timers/vdso' into timers/core 2019-07-03 10:50:21 +02:00
infiniband Merge branch 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity 2019-07-08 20:28:59 -07:00
input Power management updates for 5.3-rc1 2019-07-09 10:05:22 -07:00
interconnect
iommu Merge branches 'x86/vt-d', 'x86/amd', 'arm/smmu', 'arm/omap', 'generic-dma-ops' and 'core' into next 2019-07-04 17:26:48 +02:00
ipack treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
irqchip Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-07-08 11:01:13 -07:00
isdn
leds LED updates for 5.3-rc1 2019-07-09 08:59:39 -07:00
lightnvm lightnvm: fix uninitialized pointer in nvm_remove_tgt() 2019-06-21 03:14:30 -06:00
macintosh treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 247 2019-06-19 17:09:08 +02:00
mailbox treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mcb treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 441 2019-06-05 17:37:17 +02:00
md block: Kill gfp_t argument of blkdev_report_zones() 2019-07-11 20:04:37 -06:00
media fbdev changes for v5.3: 2019-07-09 09:55:45 -07:00
memory Bulk GPIO changes for the v5.3 kernel cycle: 2019-07-09 09:07:00 -07:00
memstick treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
message
mfd LED updates for 5.3-rc1 2019-07-09 08:59:39 -07:00
misc Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2019-07-08 21:48:15 -07:00
mmc SPDX update for 5.2-rc6 2019-06-21 09:58:42 -07:00
mtd mtd: rawnand: sunxi: Add A23/A33 DMA support with extra MBUS configuration 2019-07-05 22:30:58 +02:00
mux
net 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
nfc treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 417 2019-06-05 17:37:15 +02:00
ntb
nubus
nvdimm Keyrings ACL 2019-07-08 19:56:57 -07:00
nvme nvme: fix NULL deref for fabrics options 2019-07-11 16:02:26 -06:00
nvmem treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
of treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 428 2019-06-05 17:37:16 +02:00
opp Merge branch 'opp/linux-next' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm 2019-06-26 10:53:57 +02:00
oprofile
parisc SPDX update for 5.2-rc4 2019-06-08 12:52:42 -07:00
parport treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
pci Merge branch 'pm-sleep' 2019-07-08 10:51:25 +02:00
pcmcia treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
perf arm64 updates for 5.3: 2019-07-08 09:54:55 -07:00
phy treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
pinctrl Pin control fixes for the v5.2 cycle: 2019-06-29 16:51:10 +08:00
platform Device properties framework updates for 5.3-rc1 2019-07-09 10:28:47 -07:00
pnp
power Merge branches 'pm-opp', 'pm-misc', 'pm-avs' and 'pm-tools' 2019-07-08 10:59:38 +02: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 RAS/CEC: Add copyright 2019-06-08 17:40:28 +02:00
regulator regulator: Updates for v5.3 2019-07-09 09:15:03 -07:00
remoteproc treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
reset treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
rpmsg
rtc treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
s390 s390 updates for the 5.3 merge window 2019-07-08 10:06:12 -07:00
sbus
scsi sd_zbc: Fix report zones buffer allocation 2019-07-11 20:04:39 -06:00
sfi
sh
siox
slimbus
sn
soc Power management updates for 5.3-rc1 2019-07-09 10:05:22 -07:00
soundwire soundwire fixes for v5.2-rc4 2019-06-10 18:07:39 +02:00
spi Merge remote-tracking branch 'spi/topic/pump-rt' into spi-next 2019-07-04 17:35:11 +01:00
spmi
ssb
staging fbdev changes for v5.3: 2019-07-09 09:55:45 -07:00
target SCSI fixes on 20190705 2019-07-06 09:56:20 -07:00
tc
tee
thermal 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
thunderbolt thunderbolt: Implement CIO reset correctly for Titan Ridge 2019-06-14 14:25:43 +03:00
tty fbdev changes for v5.3: 2019-07-09 09:55:45 -07:00
uio treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
usb Device properties framework updates for 5.3-rc1 2019-07-09 10:28:47 -07:00
uwb treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 234 2019-06-19 17:09:07 +02:00
vfio treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
vhost treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 482 2019-06-19 17:09:52 +02:00
video fbdev changes for v5.3: 2019-07-09 09:55:45 -07:00
virt
virtio
visorbus
vlynq
vme
w1 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
watchdog treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
xen treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
zorro
Kconfig fmc: Delete the FMC subsystem 2019-06-12 14:23:50 +02:00
Makefile fmc: Delete the FMC subsystem 2019-06-12 14:23:50 +02:00