summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2017-03-06 11:23:35 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-12-14 09:28:21 +0100
commit36a14374b5684ad2a09d9f89adef3ab5e114cf0d (patch)
treeddc412e3a10c646fc314b4ef4dc8610c1cc74e59 /drivers
parentbc8859174d984975d10f47c55ade762bbf46b5f1 (diff)
downloadlinux-stable-36a14374b5684ad2a09d9f89adef3ab5e114cf0d.tar.gz
linux-stable-36a14374b5684ad2a09d9f89adef3ab5e114cf0d.tar.bz2
linux-stable-36a14374b5684ad2a09d9f89adef3ab5e114cf0d.zip
zram: set physical queue limits to avoid array out of bounds accesses
[ Upstream commit 0bc315381fe9ed9fb91db8b0e82171b645ac008f ] zram can handle at most SECTORS_PER_PAGE sectors in a bio's bvec. When using the NVMe over Fabrics loopback target which potentially sends a huge bulk of pages attached to the bio's bvec this results in a kernel panic because of array out of bounds accesses in zram_decompress_page(). Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/zram/zram_drv.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index c9914d653968..b7c0b69a02f5 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1286,6 +1286,8 @@ static int zram_add(void)
blk_queue_io_min(zram->disk->queue, PAGE_SIZE);
blk_queue_io_opt(zram->disk->queue, PAGE_SIZE);
zram->disk->queue->limits.discard_granularity = PAGE_SIZE;
+ zram->disk->queue->limits.max_sectors = SECTORS_PER_PAGE;
+ zram->disk->queue->limits.chunk_sectors = 0;
blk_queue_max_discard_sectors(zram->disk->queue, UINT_MAX);
/*
* zram_bio_discard() will clear all logical blocks if logical block